Repository navigation
perf(sqlite): keep a short fingerprint of saved rows instead of full copies in memory - #48207
Conversation
4278063 to
e3498ac
Compare
|
Perf scan (head Findings: none.
|
|
Review status — head
Benchmark: name=fleet-memory-win-high head=e3498acd7331c364c85b739cb0e011a2cc59e21c gate=PASS (no memory regression against |
e3498ac to
3c1d18d
Compare
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Perf scan (head |
|
Review status — head
Benchmark: name=fleet-memory-win-high head=3c1d18d0f96623b18aa088e046eb0160f3d889a5 gate=PASS (no memory regression against |
ELI5
Several of Orca's small databases kept a full copy of every saved row in memory, just to tell later whether a row changed. Now they keep a short fingerprint of each row instead, which is enough to spot a change.
What Changed
KeyedJsonRowCachekeeps a SHA-256 digest (44 bytes) of each stored row's JSON, plus its sequence number, in place of the full JSON string.keyed-json-row-plan.ts(re-exported from the cache module) to avoid an import cycle.Why
The baseline exists only to skip writing rows that didn't change. Holding every row's JSON to do that kept the whole GitHub cache, last-status and catalog contents in RAM twice. A digest answers the same question at a fixed size. An accidental SHA-256 collision is not a practical risk.
Linked Issue
N/A (maintainer PR; part of a five-PR memory series measured on a 1,266-worktree profile)
Visual Proof
N/A: memory-only change; nothing on screen changes.
Testing
No new tests: the existing row-cache tests already cover skip-unchanged, reinsert, restart and legacy import through the public API, and they pass. Memory before/after on a seeded ~1,900-workspace Windows profile is in the review comment.
Performance
Lowers memory: −9.2 MiB of main heap on a 1,266-worktree profile. CPU: each compared row is hashed. Patch writes, including the per-status agent updates, hash only the changed rows. Full writes hash bytes the caller has just serialized; about +1 ms per MB written (4,096 rows / ~1 MB: 1.67 ms against 0.64 ms). There are no new writes, timers or queries.
Risk
Level: Low. If the digest planning were wrong, a row could be rewritten needlessly or, in theory, skipped. Equal content still produces equal digests, and the on-disk format is unchanged, so older and newer builds read the same files. Revert is a plain revert.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)