-
Notifications
You must be signed in to change notification settings - Fork 77
_sidebar-daemon consumes ~100% CPU and leaks memory immediately on start #109
Description
Description:
After toggling the sidebar on with workmux sidebar, the _sidebar-daemon process immediately spikes to ~97% CPU and grows in memory continuously (750MB within a minute, 1.1GB within two minutes). The _sidebar-run client processes are unaffected (~0% CPU, ~10MB each).
Killing the daemon and restarting via workmux sidebar toggle reproduces the issue consistently.
Environment:
- workmux 0.1.166
- tmux 3.5a
- Linux (amd64)
- ~5 active worktree windows, each running a Claude session with MCP servers
Expected behavior: Daemon should be near-idle between 2-second polling intervals.
Likely cause (AI-analyzed from source, not manually verified):
The git worker thread spawned in daemon.rs (~line 440) appears to have no sleep in its main loop. next_worker_timeout() can return as low as 1ms when debounce-ready worktrees exist, causing fs_rx.recv_timeout() to return almost immediately and the loop to spin. The main daemon loop has a 10ms sleep, but the git worker runs in a separate thread with no sleep floor. This would explain the immediate CPU spike, especially with multiple active worktrees generating filesystem events.
The growing memory footprint suggests snapshot or state accumulation in the daemon as well.
Possible fix: Add a minimum sleep floor (e.g. 50ms) in the git worker loop, or clamp next_worker_timeout() to a minimum of ~50ms to prevent busy-waiting.