Repository navigation
perf(engine): idle-zero, no background git while nobody is here - #69
Merged
Merged
Conversation
Every RPC call used to mark the app active, so an open but unattended window (the PR list refresh every 120 s, the usage gauge, held Watch* streams) kept the PR watch polling at full speed forever; it never slowed after 30 minutes or paused after 2 hours. - user_activity::is_user_activity: an allowlist of calls a person makes (send, steer, answer input, open a chat, focus the window, PR and git actions, terminal input). Background polls do not count. - A live agent run counts as activity, so an agent waiting on CI keeps the watch at full speed; the idle clock starts when the run ends. - The loop sleeps until the next poll is due (15 s to 15 min) instead of waking every 15 s, and rechecks every 5 min while paused.
Every checkout was re-captured (about six git runs each) every 120 s, whether or not anyone was using the app. - Repairs run when someone comes back (window focus, or the first action after 5 quiet minutes; at most every 2 min), for a chat's checkout at turn end, and on watcher overflow (unchanged: the hub's rescan kicks). - The periodic safety repair runs every 15 min, only while a person acted in that window or a run is live, and skips live-watched checkouts untouched for 6 h. Unattended and idle it spawns no git. - A noise filter drops watch events from root target/, any node_modules/ and .git objects/logs/worktrees, so builds and installs no longer end in a capture. Source edits, refs, HEAD and index still kick.
The slot pool's leak check woke every 30 s and re-ran `make --version` every 10 minutes for the life of the engine. Checks now run only while a run is live or a terminal is open, plus two minutes of grace so a leak at the end still gets its two quiet ticks; then the task parks with no timer until a run starts or a terminal opens, and checks at once on waking. The re-probe runs at most every 10 minutes, only while checks run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First batch of the idle-zero work: when nothing is happening, the engine should spawn nothing and wake as little as possible.
Changes (one commit each)
Watch*streams) kept the watch polling at full speed forever.user_activity::is_user_activityis an allowlist of calls a person makes (send, steer, answer input, open a chat, focus the window, PR and git actions, terminal input). A live agent run also counts, so an agent waiting on CI keeps it at full speed. The loop sleeps until the next poll is due instead of waking every 15 s, and rechecks every 5 min while paused.target/, anynode_modules/and.gitobjects//logs//worktrees/; source edits, refs, HEAD and index still kick.make --versionre-probe run only while a run is live or a terminal is open (plus 2 min of grace), then the task parks with no timer until a run starts or a terminal opens.Before / after (headless engine, same method)
godspeed headlesson a fresh temp data dir, a git repo with 10 linked worktrees and one chat in each, 2 PR watches on public upstream PRs, and a connected client behaving like an open but unattended window (WatchChats, WatchSpaces, WatchSessions, WatchCheckoutDiffs, WatchWorkspaceGitStatus held; ListPullRequestWatches every 120 s; nothing user-initiated after setup). 180 s settle, then 10 minutes measured. git/gh spawns are counted exactly by PATH wrappers; wakeups and CPU come fromproc_pid_rusage(top's IDLEW samples miss most wakeups). Debug builds oforigin/mainand this branch, forced full rebuilds.git -Ccaptures, 75rev-parse, 50branch)rev-parse, spaces upkeep)Tests
cargo test -p zeron-engine --lib -- pr_watch:: user_activity:: diff_sync build_slots::: 60 passed, including the new ones:user_activity::people_count_and_background_polls_do_notpr_watch::background_calls_let_the_watch_idle_and_live_runs_keep_it_awakepr_watch::the_loop_sleeps_until_the_next_poll_is_duediff_sync::repair_schedule_tests::*(repair scope, stale skip, rate-limited return repair, noise paths and events, and a real watcher: writes intotarget/,node_modules/and.git/objectsdo not kick, a source edit does)build_slots::checks_park_after_a_grace_once_nothing_is_live,a_parked_loop_has_no_timer_and_wakes_on_note_live