Repository navigation
perf(stats): stop retaining and rewriting the raw stats event log - #35852
Merged
Merged
Conversation
…5544) The collector kept up to 10K raw events (~203 B each since #14657 switched meta to pane keys and added worktree ids) and re-serialized the whole ~2 MB file every 5 s. No consumer reads events; persist aggregates only, keep the v1 file shape with an empty events array, and compact legacy files on load.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Medium impact] The PR appears safe to merge. SummaryThe collector stops retaining raw events and saves only running totals, while keeping
Reviews (1) · Last reviewed commit: "test(stats): use a small event burst for..." · Reviewed by Greptile |
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.
ELI5
Orca's usage stats file kept a log of up to 10,000 raw events and rewrote all of it, about 2 MB, every 5 seconds while agents were active. Nothing ever reads that log; only the running totals are used. The collector now keeps just the totals.
What Changed
src/main/stats/collector.ts:MAX_EVENTS = 10_000cap are gone;record()only updates aggregates.events: [], so the file keeps schema v1 and older builds parse it unchanged.src/main/stats/types.ts: comments updated.collector-async-save.test.ts: replaces the old "bounds retained events" test (fix(stats): bound retained events during stalled writes #20941). The new test checks that an old event-heavy file is compacted and that new activity keeps the file under 1 KB with correct totals.Why
Benchmark: 10K realistic events, 40 panes, 8 worktrees, 50 PRs.
JSON.stringifyper saveWhere this came from
Linked Issue
Fixes #35544
Visual Proof
N/A: no UI change. The stats summary shown in the app is computed from the same aggregates.
Testing
pnpm test src/main/stats src/main/quit-path-durable-write-blocking.test.ts: all pass.pnpm check:changed --maxWorkers=2: 21/21 checks pass.Adversarial reviews by Opus and Codex (gpt-6.1-sol, xhigh), both MERGE. Both searched the whole repo and found no reader of raw stats events in diagnostics, mobile, CLI, telemetry, star-nag or RPC. Both also verified that aggregates are preserved exactly from old files and that old/new builds can share the file without double counting.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Risk
Existing raw event history in users' stats files is dropped on first save. It was never surfaced anywhere. Aggregates (totals, counted PRs,
firstEventAt) are unchanged.🤖 Generated with Claude Code