Repository navigation
perf: cut redundant work from the steady cross-session rebuild - #90
Merged
Merged
Conversation
While an agent writes its transcript, discovery runs every 10 s and the cross-session snapshot rebuilds every 15 s. Remove work that produced the same results: - Claude local-agent discovery expanded the shared sibling directory once per agent (38 x 119 entries); expand it once per scan and test the literal trace name, as glob does. Names with glob magic keep the per-agent glob. - Parse Claude Desktop metadata once per file signature. - Stop copying owned ID sets in model coverage and usage provenance. - Return the matched-pace windows cache without a deepcopy; snapshots are read-only. - Compute each distinct agent-usage scope selection once per aggregation. Aggregates are not folded incrementally because float sums are order dependent. A parity golden generated from main pins the outputs. Co-Authored-By: Claude Code <noreply@anthropic.com>
- Keep only the indexed fields of Claude Desktop metadata in the cache; the rest of a file can carry MCP configuration and permission state. - List the shared sibling directory uncached so it is never staler than the per-agent globs it replaced. - Key agent scope bodies by record identity alone. - Store parity digests per float sum() behavior: Python 3.12 made sum() compensated, so CI's 3.12 produces different (equally reference) digests. - Test path-cache freshness, rooted scans, eviction, and field trimming. Co-Authored-By: Claude Code <noreply@anthropic.com>
7 of 8 tasks
Member
Author
|
Status at 1532799: one minor fix needed, then ready after an update from main.
— Pratik's agent |
The metadata cache stored a failed read under the file's unchanged mtime and size, so a locked or briefly unreadable file (a Windows sharing violation or an antivirus scan) hid that Desktop session until the file changed or the server restarted. Read errors are no longer cached; parse errors still are, since they repeat until the file changes. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
bhavsarpratik
added a commit
that referenced
this pull request
Oct 26, 2026
Brings in the Splunk by Cisco branding (#93), the trace-path privacy fix (#89), and the cross-session perf work (#88, #90). - All Sessions rows now key on the server-sent trace key, since #89 removed the path the branch used to hash. - Regenerate the agent_usage parity digests for the new model_runtimes and model_days fields; every pre-existing field still matches main's golden on Python 3.9 and 3.14. Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
Summary
When an agent is writing its transcript, the server runs source discovery every 10 s and a forced cross-session rebuild every 15 s. This PR removes work that produced the same results on every cycle. Dashboard, menu bar and MCP output do not change.
The PR builds on
mainand does not depend on #88. #88 removes the cost of re-encoding the snapshot on each poll; this PR reduces the cost of building it.token_meter/runtimes/claude.py)<id>.jsonlname is checked withlexistsin each folder.globdoes for a literal final component. I checked this against the CPython 3.9, 3.11 and 3.14 sources.cwdand activity caches.domain/aggregates.py,domain/usage.py): these no longer copy ID sets they already own or only read.app.py): the cached windows object is returned without adeepcopy(2 MB, 35 ms). Snapshots are read-only. That rule is now documented, and I traced every consumer.domain/agents.py): each distinct scope selection is computed once per aggregation. There were 736_usage_bodycalls but only 75 distinct selections. The top-level body is still built on its own, because it is changed afterwards.Why the aggregates are not updated incrementally: they fold sessions in order using float sums. Subtracting a session and adding it back changes the float association, so the totals would no longer match exactly.
Measurements
Setup: Python 3.9, 2,259 sources. Inputs are frozen as APFS clones of the local traces (no credential files, and no Cursor
state.vscdb). Base is agit archiveofmain, run with the same driver.In-process, warm, mean of two runs each
all_session_sources()cross_session()capability_inventoryaggregate_model_statsIsolated server CPU, ABAB order
software_update_watchernot started./state1 s,/session2 s) + menu bar (/menubar2 s)Notes on these numbers:
main, the polled number is dominated by re-encoding the snapshot on every/statepoll, which is what perf: stop re-encoding the cross-session snapshot on every poll #88 fixes.aggregate_model_statsis the ordered float fold itself.Equivalence evidence
tests/domain/test_aggregate_parity.py):main(fd08706).sum()compensated, so the golden stores one digest set persum()behavior. 3.9 and 3.11 share one set; 3.12, 3.13 and 3.14 share the other.all_session_sources()andcross_session()were compared betweenmainand this branch, once in the same process and once in back-to-back processes. Only two kinds of field differed:request_revisionstrings, which embed a SQLite-shmmtime that changes whenever the database is opened/state(8 MB) and/menubarwere byte-identical apart fromtokenandgenerated_at.main. It can find a new sibling trace sooner thanmainwould.Gates
bash -nandgit diff --checkall pass.Test plan
python3 -m unittest discover -s testsmain./scripts/installand installed-runtime parity. The installed runtime on the measuring machine belongs to another branch.🤖 Generated with Claude Code