Skip to content

perf(list): skip fsmonitor daemon starts when the daemon is running - #4284

Merged
max-sixty merged 1 commit into
mainfrom
fsmonitor-socket-probe
Sep 26, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fsmonitor-socket-probe

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

On macOS with the builtin fsmonitor enabled (core.fsmonitor=true), wt list and the wt switch picker fork git fsmonitor--daemon start for every worktree inside the post-skeleton rayon::scope, and the per-row task pool can't start until all of them return. In the steady state nearly every start exits 128 "already running"; in a 128-worktree repo those forks cost 100–300ms before the pool opens.

Repository::start_fsmonitor_daemon_at now first connects to <git-dir>/fsmonitor--daemon.ipc and returns without forking if a daemon answers. That's the check git's own start makes before refusing (ipc_get_active_state connects and closes). Any failure — no daemon, stale socket, unresolvable git dir, or a socket path longer than sun_path — falls through to the existing fork. The git dir is already primed from the worktree list on this path, so the probe runs no git command.

The socket basename is now shared as git::fsmonitor::IPC_SOCKET_NAME with the wt remove stop path.

The new unit test binds a UnixListener at the repo's socket path and checks, via captured trace records, that no git fsmonitor--daemon start runs while it answers and that the start does run for a path with no git dir. It fails with the early return removed.

🤖 Generated with Claude Code

This was written by Claude Code on behalf of max-sixty

On macOS with the builtin fsmonitor enabled, `wt list` and the `wt switch`
picker fork `git fsmonitor--daemon start` for every worktree before the
per-row tasks can start, and in the steady state each of those forks exits
"already running". `start_fsmonitor_daemon_at` now first connects to the
worktree's `<git-dir>/fsmonitor--daemon.ipc` socket, the same check git's
`start` makes before refusing, and forks only when nothing answers. Any
connect failure falls through to the fork.

The socket basename is now shared from `git::fsmonitor::IPC_SOCKET_NAME`
with the `wt remove` stop path.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit a6930b7 into main Sep 26, 2026
38 checks passed
@max-sixty
max-sixty deleted the fsmonitor-socket-probe branch September 26, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants