Add per-file result cache for Codex provider#185
Merged
Conversation
Fixes #183. Users with large Codex session directories (45 GB, 10K+ files) experienced CPU pegging because every 30-second refresh re-parsed all session files from scratch. Three optimizations: 1. readFirstLine now reads 16 KB via fs.open() instead of loading the entire file through readSessionFile. Cuts discovery I/O from ~45 GB to ~160 MB for 10K files. 2. Per-file result cache (codex-results.json) with mtime+size fingerprinting. Parsed results are cached on first run; subsequent runs return cached data instantly for unchanged files. 3. Cache-accelerated discovery skips header validation for cached files, pulling the project name directly from the cache manifest. Cache safety: fingerprint captured before read (no TOCTOU), atomic write via temp+fsync+rename, 0o600 permissions, Object.hasOwn for prototype pollution defense, eviction of deleted files on flush, try/finally ensures flush even on parse errors.
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
readFirstLinenow reads 16 KB viafs.open()instead of loading entire files (discovery I/O: 45 GB -> 160 MB)codex-results.json) with mtime+size fingerprinting, cached files skip re-parse entirelyCache safety (validated by 6 review agents across 2 rounds):
Test plan
codeburn reportworks correctly~/.cache/codeburn/codex-results.jsonwith 0o600 permissions