Repository navigation
perf: less daemon and window memory, fewer requests - #1065
Merged
Merged
Conversation
On a stand at the owner's scale (1.18M events, 2.8 GB, four tabs, agents working) the daemon settled at 518 MB, 366 MB of it SQLite's allocator, which keeps what start-up filled. At 4 MiB: 276 MB, 100 MB SQLite, every timed endpoint as fast, CPU 10.2% -> 10.7% of a core.
…freshes HandoffEffect looked for every handed session's first edit and counted the calls before it once a minute: about 1 GB of disk reads an hour on the owner's Mac. A first edit once found is kept, and a session with none yet is read again only after its newest event moved.
The 0.188.0 ETag reached clients that keep tags; the Ops module's scheduled scripts start as new processes without one, and module lists were still ~7,100 an hour and 37% of the daemon's disk reads on the owner's Mac. Each page is kept with the tag it was read at (32 MiB at most) and answered from memory while the collection is unchanged. Who asks is logged at debug level, once per client and collection per 10 minutes.
The inspector's read of a session's calls carried every result's body and threw it away on arrival (cockpit slimToolResult): 531-703 KB per session on the owner's live sessions. With slim=1 the daemon drops it before the wire, keeping an error's head and interrupted: 38% smaller on a hook-driven session on the stand, 70% on a long one.
… 304 The workspace asks the full list once a minute (424 KB on the owner's Mac) and the live one on every tick. The daemon tags each answer with a hash of its body; the dashboard sends the last tag itself, gets the kept array back on a 304 and does not merge it into the sidebar again.
…'s events The board's per-session cache held the newest 70 events whole, written files and command output included, for up to 256 sessions: 30.5 MB of payloads on the stand's database. It now keeps a payload's source and trigger for the turn reading and the tool inputs without file bodies for the narration (2.4 MB), with every state read the same, and drops a session the last read did not list.
The workspace asked for the live list on every live tick, a second apart while anything worked: 47.8 asks and 669 KB a minute beside four agents. It now asks when a frame names a session it does not hold (at most once a second) and every 15 s, hidden too for the tray and the Dock badge; the session frames keep the held ones current. Session frames are applied once a second instead of every 300 ms. On the Chromium stand: requests 996 -> 383 KB a minute, React commits 984 -> 593 a minute.
The popover's web view was made hidden as soon as a daemon answered and kept for the life of the app: a second WebKit content process of 25 MB on the bench whether the popover was ever opened or not. It is now made on the first click or peek, with a loading mark on its page until it draws. With the popover never opened the app's processes went 188.9 -> 143.3 MB at start and 380.3 -> 332.5 MB with eight tabs (bench snapshot build). Closing it again five minutes after it hid was built and dropped: the panel's destroy aborted the app in -[NSView removeFromSuperview], WebKit's window visibility observer failing to remove a KVO observer after the panel's class swap.
Every start read all of history again to rebuild the 7d, 30d and all-time parts. They are now written to parts_kept (migration 0093) with the events mark they were read at, after each whole read and at most every 10 minutes after; a start reads only the sessions that moved since that mark, as between two asks in one run. A row is used only by the build that wrote it and while younger than the 6-hour rebuild. On a copy of a 2.4 GB database the parts' start-up reads, about 255 MB, are gone. TestKeptPartsEqualAFreshRead holds the kept range to a fresh count.
The session list ETag (ed7f1e8) skipped the merge when an answer came back as the same array. The held list can have moved since from frames and the window's own actions, and eight AppShell tests caught a session shown twice. The merge already gives back the held list when nothing differs, so it now runs on every answer; the 304 still saves the bytes.
…rkspace's A 304 handed every reader the kept array itself, so a reader that changed its rows changed the next answer too: e2e phone.spec lost the chat's controls. getTagged now returns a structuredClone. The counted lists (sessionsWithTotal: phone Home, browser Home, Now) go back to plain fetches the browser revalidates by the same ETag. golden.spec's route that rewrites the list fetches without the page's If-None-Match.
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.
Performance pass of 2026-11-24: less memory and fewer requests, behaviour unchanged.
Measured on an isolated stand (temp HOME, spare port, fake claude), before → after:
slim=1events for the inspector: −38% bytes on hook-driven sessions, up to −70%.parts_kept, documented in.ai/03-contracts.md): start-up reads ~255 MB → 0 for those figures; equality with a fresh rebuild tested.Checked on a read-only copy of a real database. Full go test, lint, tsc, vitest, cargo and docs checks pass locally; the two phone e2e failures also fail on master.