Idle CPU: VaultWatcher.scan and VaultSpotlightIndex.apply run continuously #31

Open
opened 2026-09-15 16:24:13 +00:00 by kayg · 1 comment
Owner

Finding (Main, 2026-09-15, sample on the VM with the app idle)

VaultSpotlightIndex.apply(full:paths:from:token:operation:) via startWorker/drain (814 samples / 6 s) and VaultWatcher.scheduleScan → emitDiff → scan (566 samples) run continuously with getattrlist/stat/lstat while nothing changes in the vault. Expected: the watcher sleeps until FSEvents fires; the Spotlight index applies once per change batch. Find why the scan re-schedules itself (timer? watcher re-arming on its own writes under .calternal/? thumbnails cache writes triggering rescans?) and fix; verify with a 30 s idle sample showing zero scan/apply frames.

## Finding (Main, 2026-09-15, sample on the VM with the app idle) VaultSpotlightIndex.apply(full:paths:from:token:operation:) via startWorker/drain (814 samples / 6 s) and VaultWatcher.scheduleScan → emitDiff → scan (566 samples) run continuously with getattrlist/stat/lstat while nothing changes in the vault. Expected: the watcher sleeps until FSEvents fires; the Spotlight index applies once per change batch. Find why the scan re-schedules itself (timer? watcher re-arming on its own writes under .calternal/? thumbnails cache writes triggering rescans?) and fix; verify with a 30 s idle sample showing zero scan/apply frames.
Author
Owner

IdleFinish — worktree /home/kayg/Developer/calternal-apple/.worktrees/idle-churn, final head 8bdcb56a.

Root cause and correction:

  • The app-level watcher callback in App/Sources/Shell/DeepLinks.swift converted every empty refresh batch into mirror.syncAll, which restarted a full Core Spotlight projection. This produced the observed apply full=true paths=0 recurrence about every 31 seconds.
  • Commit 8bdcb56a changes the callback to call mirror.sync only for nonempty changed paths. Full projection remains launch/index-rebuild work.
  • Scripts/build-mbp.sh idle-churn app passed: BUILT_APP=/Users/agents/Developer/Worktrees/idle-churn/App/build/Build/Products/Debug/Calternal.app.

Clean VM evidence (contaminated prior sample discarded after Main reported it had been overwritten by another deployment):

  • Deployed the corrected app, allowed the launch projection to settle, then executed sample Calternal 30 -file /tmp/vm/idle-sample-fixed.txt on the VM.
  • Copied clean sample to /tmp/idle-churn-evidence-fixed/idle-sample-settled.txt; zero matches for VaultWatcher.scan and zero matches for VaultSpotlightIndex.apply.
  • Ran open -n --env CALTERNAL_IDLE_DIAGNOSTIC=1 ~/Apps/Calternal-idle-churn.app, idled 70 s, and read log show --last 1m --predicate 'subsystem == "org.kayg.calternal"'. /tmp/vm/idle-diagnostic-fixed.log contains only the table header: no apply/re-arm diagnostic messages.
  • UI artifacts: /tmp/idle-churn-evidence-fixed/idle-launch-clean.png, idle-after-30s-settled.png, and idle-window-settled.mp4.

VM lease released and Calternal stopped.

IdleFinish — worktree `/home/kayg/Developer/calternal-apple/.worktrees/idle-churn`, final head `8bdcb56a`. Root cause and correction: - The app-level watcher callback in `App/Sources/Shell/DeepLinks.swift` converted every empty refresh batch into `mirror.syncAll`, which restarted a full Core Spotlight projection. This produced the observed `apply full=true paths=0` recurrence about every 31 seconds. - Commit `8bdcb56a` changes the callback to call `mirror.sync` only for nonempty changed paths. Full projection remains launch/index-rebuild work. - `Scripts/build-mbp.sh idle-churn app` passed: `BUILT_APP=/Users/agents/Developer/Worktrees/idle-churn/App/build/Build/Products/Debug/Calternal.app`. Clean VM evidence (contaminated prior sample discarded after Main reported it had been overwritten by another deployment): - Deployed the corrected app, allowed the launch projection to settle, then executed `sample Calternal 30 -file /tmp/vm/idle-sample-fixed.txt` on the VM. - Copied clean sample to `/tmp/idle-churn-evidence-fixed/idle-sample-settled.txt`; zero matches for `VaultWatcher.scan` and zero matches for `VaultSpotlightIndex.apply`. - Ran `open -n --env CALTERNAL_IDLE_DIAGNOSTIC=1 ~/Apps/Calternal-idle-churn.app`, idled 70 s, and read `log show --last 1m --predicate 'subsystem == "org.kayg.calternal"'`. `/tmp/vm/idle-diagnostic-fixed.log` contains only the table header: no apply/re-arm diagnostic messages. - UI artifacts: `/tmp/idle-churn-evidence-fixed/idle-launch-clean.png`, `idle-after-30s-settled.png`, and `idle-window-settled.mp4`. VM lease released and Calternal stopped.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal-macos#31
No description provided.