Repository navigation
Index events to stop 300-900% CPU - #100
Open
SuperLogicAI wants to merge 3 commits into
Open
SuperLogicAI wants to merge 3 commits into
SuperLogicAI wants to merge 3 commits into
Conversation
listAttentionEvidence runs after every hook, and with no index on events.type each run scanned the whole table: 12-33 s on an 18 GB database. Runs already in flight are not cancelled, so they stacked until all 10 pool workers were busy, showing as 300-900% CPU in the Rust process. Migration 15 adds events(type, ts). On a clone of that database the query drops from 12.7 s to 112 ms with identical output, and listToolEvents from 1.4 s to 4 ms. Nothing is deleted. A new test pins that the query uses the index and was confirmed to fail without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows checks repo.ts out with CRLF, so matching a literal newline failed the new test there. The migration itself was unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With two agents running, CPU still reached 30-300% after migration 15. Spike samples showed pread under getOverflowPage with JSON parsing near zero: eventsSince filters on ts alone on every side-panel refresh, and ts is stored after payload_json, so each run walked every row's overflow pages. Migration 16 adds events(ts). On a clone, a 1-hour window drops from 919 ms to 8 ms with identical output. The index test now covers both reads and was confirmed to fail with the new index removed. Co-Authored-By: Claude Opus 5.5 <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
Two reads kept SQLite busy enough to show as 300-900% CPU in the Rust process.
listAttentionEvidenceruns after every hook. With no index onevents.type, each run scanned the whole table: 12-33 s on an 18 GB database. Runs in flight aren't cancelled, so they stacked until all 10 pool workers were busy.eventsSinceruns on every side-panel refresh and filters ontsalone.tsis stored afterpayload_json, so each run walked every row's overflow pages to reach it.Migration 15 adds
events(type, ts)and migration 16 addsevents(ts). Nothing is deleted, and no query changes.listAttentionEvidencelistToolEventslastLefteventsSince, 1 houreventsSince, 7 daysMeasured on APFS clones of the real database, warm cache, through
node:sqlite. Output hashes matched, and the indexes built in 1.6 s and 1.0 s.Verification
sampleduring spikes pointed at each query in turn. Migration 15 alone took the installed app from 500-900% to 1-3% at idle and 30-300% with two agents, and applied in 1.29 s on the real database.npm run check,npx tsc --noEmit,git diff --checkcargo test --lib(194 passed, 1 ignored),cargo clippy --all-targets -- -D warningshot_event_reads_use_their_indexesruns the real SQL fromrepo.ts. It failed with either index removed and passes with both.Not verified
npm run reinstall; steps are indocs/TESTING.md..logic-loop/board.mdand the Phase 68 work stay out of this PR.🤖 Generated with Claude Code