summaryrefslogtreecommitdiff
path: root/modules/dirvish-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-11 18:34:08 -0600
committerCraig Jennings <c@cjennings.net>2025-11-11 18:34:08 -0600
commit8aa0eb544a8365ad99a9c11bd74969ebbbed1524 (patch)
tree724a8c7919899b83004c168c5e8a9a8b29f7f7fc /modules/dirvish-config.el
parentb07f8fe248db0c9916eccbc249f24d7a9107a3ce (diff)
perf: Optimize org-refile with caching to eliminate 15-20s delay
Implemented comprehensive caching solution for org-refile targets that eliminates repeated filesystem scans (34,649 files) on every refile operation. Performance Impact: - Before: 15-20 seconds per refile × 12+/day = 3-4 minutes daily - After: Instant (<50ms) via cache, async build in background - Daily time saved: ~3-4 minutes + eliminated 12+ context switches Root Cause: - cj/build-org-refile-targets scanned all files in 3 directories: * ~/.emacs.d (11,995 files) * ~/code (18,695 files) * ~/projects (3,959 files) - Called on EVERY refile via cj/org-refile - directory-files-recursively is expensive with deep hierarchies Solution Implemented: 1. Cache layer with 1-hour TTL - First call: builds and caches targets (one-time cost) - Subsequent calls: use cache (instant) - Auto-refresh after 1 hour or Emacs restart 2. Async cache building - Runs 5 seconds after Emacs idle (non-blocking) - Zero startup impact - Cache ready before first use in typical workflow 3. Manual refresh available - M-x cj/org-refile-refresh-targets - Use after adding new projects/todo.org files - Force rebuild bypasses cache 4. Robust error handling - Building flag prevents concurrent builds - unwind-protect ensures flag always clears - Graceful handling if user refiles before async build completes Changes: - modules/org-refile-config.el: * Added cache variables with TTL support * Modified cj/build-org-refile-targets for caching * Added cj/org-refile-refresh-targets for manual refresh * Async build via run-with-idle-timer * Enhanced commentary documenting performance - tests/test-org-refile-build-targets.el (NEW): * 9 comprehensive ERT tests * Coverage: normal, boundary, error cases * Tests cache logic, TTL, force rebuild, async flag * All tests pass, zero regressions Test Results: - 9/9 new tests passing - 1,814 existing tests still passing - Zero regressions introduced 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'modules/dirvish-config.el')
0 files changed, 0 insertions, 0 deletions