Repository navigation
perf(usage): lazy-load source cache ledgers - #16219
sanshengai wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe usage provider now stores source data in a separate cache file. Cache loading validates schema version, worktree fingerprint, source key, and source-array shape. Legacy inline source data migrates asynchronously to the partitioned cache. Hot-state snapshots exclude source data. Scans load prior sources through resident, legacy, or partitioned state and persist scan results separately. Tests cover lazy loading, migration, two-file persistence, and empty Merge Risk: ⚪ Minimal · up to The change lazy-loads cold usage ledgers while preserving cache migration and persistence behavior; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 Warning |
|
Closing as stale. main has moved on substantially since this branch was opened on Aug 24, and I am no longer following it. Happy to reopen a rebased, single-change PR if maintainers still want the fix. |
Summary
Why
The usage stores are constructed unconditionally during app startup. Their previous synchronous
JSON.parse(readFileSync(...))loaded every processed-file ownership key even when the usage UI was never opened. On a real active Orca profile:The first upgraded launch still performs a one-time legacy parse so it can migrate safely. Subsequent launches read only the small hot cache unless a scan runs.
Related performance umbrella: #16211
Durability and compatibility
schemaVersionandworktreeFingerprintprocessedFiles/processedDatabasesstays an empty array in the hot file)Validation
pnpm exec vitest run --config config/vitest.config.ts src/main/usage src/main/codex-usage src/main/claude-usage src/main/opencode-usage— 21 files, 108 tests passedpnpm exec oxlint src/main/usage/usage-provider-source-cache.ts src/main/usage/usage-provider-store-lifecycle.ts src/main/usage/usage-provider-store-lifecycle.test.tspnpm run typecheck:nodepnpm run check:max-lines-ratchetgit diff --checkpnpm testitself cannot load the optionalwindows-native-registrynative module under the local Node 24.19.0 environment, so the same repository Vitest config was invoked directly.AI assistance
This contribution was developed with AI assistance and manually reviewed for migration ordering, schema/fingerprint invalidation, generation races, failure fallback, and quit flushing.