Repository navigation
fix: reduce CPU overhead for small history and usage reads - #147205
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 1:33 PM ET / 17:33 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR makes small history and usage reads stop sizing transcript rows at their byte budget, extends regression coverage, and awaits asynchronous Workboard test cleanup. Merge readiness✅ Ready for maintainer review The optimization remains useful: current main and the latest release still materialize candidate metadata before enforcing small byte budgets. No actionable correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway reads stored session transcripts to serve chat history and calculate recent usage. These SQLite readers select the appropriate transcript tail before loading message payloads. flowchart TD
A[History or usage request] --> B[Transcript snapshot]
B --> C[Visible messages and reset boundaries]
C --> D[Newest-first byte sizing]
D --> E{Budget reached}
E -->|No| D
E -->|Yes| F[Load selected tail]
F --> G[History or usage result]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +31, Tests +29. Total +60 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep bounded tail selection in the existing transcript reader, preserving snapshot consistency, logical ordering, byte accounting, and iterator cleanup. Do we have a high-confidence way to reproduce the issue? Yes, from source: a small byte budget with a large candidate window still materializes all metadata on main. The PR reports a failing-before regression; this review did not execute tests. Is this the best way to solve the issue? Yes. Descending iteration extends the existing range reader and preserves the separate complete-metadata path required by hard-cap integrity checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against adb6e518a442. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
427939e to
649c5db
Compare
|
Merged via squash.
|
* commit '201f11afefdb19a9c75e9d3542bf7425c80df7a7': (141 commits) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) refactor: share streaming media tail boundary update (#146989) refactor(tui): classify resume candidates once (#146983) improve: skip unused toast dismissal work (#147196) fix(linux): recover saved remote connections without replacing active sessions (#146047) fix: doctor stays silent when Windows state dir is under OneDrive (#123720) feat: announce successful Daybreak retries (#147146) feat(code-mode): reuse results across code cells (#147154) refactor(test): reuse CLI plugin fixture writer (#147186) test: skip unused compiler setup in routing fixtures (#147194) test: reuse LINE webhook runtime fixture (#146710) fix(code-mode): check automation and process result types (#147143) ...
* commit '2d87daf04b78992382299d552f15ac84a86a23ed': (1815 commits) fix(ui): distinguish tool activity with semantic icons (#147207) fix(linux): recover completed Quick Chat replies without resending (#146048) feat(desktop): unify Tauri title bar and window controls (#147097) refactor(test): share plugin fixture server shims (#147225) perf(gateway): defer worker workspace execution imports (#143496) fix(gateway): post-ack webhook work fails with "Async work scope is closed" (#144801) refactor(scripts): centralize upgrade survivor version floors (#146975) fix(ci): check publication registries before FRV fanout (#147184) fix(qa): align system-agent delegation with channel contracts (#145905) improve: reduce repeated chat message identity work (#147210) fix(channels): remove stale pre-tool previews from Slack and Telegram (#147106) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) ...
…147205) * perf(sessions): stop recent transcript sizing at the byte budget * test(workboard): await concurrent store cleanup
What Problem This Solves
Fixes extra Gateway CPU work when chat-history or live-usage reads request a small transcript byte budget.
User Impact
Small reads size only the tail needed to enforce their budget. Returned history, token usage, cost, and oversized-newest behavior stay the same; no configuration or migration is required.
Why This Change Was Made
Recent reads previously materialized the entire candidate metadata window before walking backward to the byte boundary. The existing reset-window reader now supports descending iteration, so usage and history stop after the first excluded predecessor. History still merges reset/compaction boundary bytes, and hard-cap siblings retain their complete metadata reads and integrity checks.
Evidence
The regression failed before with 3,000 metadata rows across three reads and now passes with at most six, including repeated reads and a subsequent write on the same SQLite connection. All 66 focused tests pass, covering sparse reset chunks above 500 positions, boundary-only tails, oversized events, hard-cap siblings, concurrent writers, and history cursor fences.
Synthetic calls through the real rich-row reader reduced metadata rows from 1,000 to 74–96 per read while returning the same payload bytes, token totals, and cost. This measures reader work, not its share of live Gateway CPU. Local core and core-test typechecks, scoped lint, and the selected repository guards pass. Fresh independent review found no actionable issues. Exact-head CI run 34771572345 passed before native prepare and merge.
The initial CI run hit a baseline Workboard cleanup lint failure. The branch carried its one-line awaited-cleanup repair, with the exact concurrency test and scoped extension lint passing. #147203 landed that repair independently on main before this merge, so the final merge contains only the four transcript reader/regression files.