Repository navigation
engine: held leases stop re-reading the floor; one group commit for closing chats; clock leaves with its window (r7) - #2517
Merged
Conversation
…oup commit saves every closing chat; the clock leaves with its window (r7) Idle (r7 finding 2): each held job's runner renews its lease every 2 s, which rewrote leases.json, woke every open pull and, with a hold present, made all 15 slots list and deep-copy all 86 jobs once a second. - the root watch compares lease.RenewalShape; a renewal, a runner's folders and events.jsonl wake no pull - Desk.floorQueue: one reading of a change shared by every slot; unchanged jobs are reused, only changed files are read, sorted only on change; OverLimit reads it too - a job already held at its budget with a reply pending is no longer saved unchanged on every look (a write loop) - runner requests settle the floor every 5 s, not every 1 s - CODEAF_DIAGNOSTIC_PROFILE_DELAY opens the profile window later Quit (finding 7): cellstore's one flush slot synced only its own chat's records while every other closing chat queued; whoever holds it now syncs every chat's owed records once. Clock (finding 9): codeaf clock leaves once the window that started it is gone and nothing is in hand.
…changed manager journal is parsed once (r7) The 5 s settle window delayed Auto's publish after its proof (worker TestAutoPipelinePassesPlanGateAndPublishesWithoutUserApproval and TestRecoveryAutoPipelineRepairsTransientFailureAndUpdatesTheSamePR timed out). Only lease heartbeats and presence now wait five seconds; pulls and reports settle within a second as before. thread.Read hands back the last answer for a journal whose file and folder are unchanged.
…nce per change of them (r7) Every open job chat's budget watch globbed workers/*/*/<job>.json every few seconds; on macOS with 43 chats that was a fifth of the idle engine.
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.
Engine findings from WorkAF live e2e round 7: idle CPU with held leases, slow quit, and a
codeaf clockthat outlived its engine.Idle CPU
Idle engine CPU over 120 s. Setup: 86 jobs (84 of r7's final documents plus 2 native jobs whose step holds its lease), about 43 open job chats, 15 runner slots and a stub model. Measurement starts 200 s after the engine starts. Rig:
r7rig.py(scratch).1436ad765)ef7953101)macOS is still above the 5% bar. What remains in its steady profile is mostly file-status calls:
settleJobs' hydrated list every 5 s: 11%With 43 chats that each ran 15 tool calls, the same build reads 7.6%.
What changed:
leases.jsonevery 2 s, which woke all 15 open pulls to re-list the floor. The root watch now compareslease.RenewalShape, the document without its heartbeat and expiry fields. Runner folders andevents.jsonlno longer wake pulls either.Desk.floorQueuekeeps the sorted queue and re-reads only job files that changed. This replaces 15ListSaveddeep copies per change.thread.Readreturns its last answer for a manager journal that is unchanged.liveMirrorslists the mirror folders once per change of them instead of globbing for every job chat's budget watch.CODEAF_DIAGNOSTIC_PROFILE_DELAY(1..3600 s) opens the developer profile window later, so a steady idle can be captured.Quit
Not reproduced. The rig quits in 1.4–1.8 s, exit 0, before and after, on both hosts. That includes 42 chats with 15 tool calls each in separate checkouts. The cause of r7's 28–30 s is still unproven.
One real serialization is fixed: cellstore's group commit synced only the flushing chat's records while every other closing chat waited behind its single slot. Whoever holds the slot now syncs every chat's owed records, each path once per pass. A chat whose snapshot failed keeps its records owed and is told. Test:
TestOneGroupCommitSavesEveryChatClosingAtOnce(48 chats).Clock
Reproduced and fixed. Before,
codeaf clockstayed alive while any window was open, including after its engine exited. It now leaves once the window that started it is gone and no run is in hand; any open window starts the next within half a minute. Test:TestAClockLeavesWithTheWindowThatStartedIt. On both hosts, no clock was left after the engine quit.Tests
Deterministic tests cover each change:
TestARenewalWakesNoPullAndARealChangeWakesThemAllTestSlotsWokenByOneChangeShareOneReadingOfItTestALookLeavesAJobAtItsBudgetAsItIsOnDiskTestARunnersRequestsSettleTheFloorAtMostOnceASettleWindowTestAnUnchangedJournalIsParsedOnceAndAnAppendedLineIsReadTestAJobChatsHoldersListTheMirrorFoldersOncePerChangeOfThemThe full
internal/factory/workerpackage also passes.make pr-ready BASE=origin/factory/general-intakepassed onef7953101. The last commit only changes PERF.md. Change entry:docs/changes/unreleased/2517-r7-idle-holds-quit-clock.md.🤖 Generated with Claude Code