Repository navigation
perf(store): cap hydrated transcripts by bytes as well as count (#1475) - #1488
Conversation
Opening the 10 largest real threads held 8 parsed transcripts (~32.8 MB of heap). A 16 MiB shard-size budget on the same LRU keeps 5 of them (+19.2 MB, -41%). Sizes come from the parsed JSON and refresh on flush; the most recent read is never evicted so one huge thread isn't re-parsed per read. Eligibility rules (working, dirty, in-flight, legacy) unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5255a693ff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (Object.prototype.hasOwnProperty.call(this._messagesHydrated, id)) { | ||
| json = JSON.stringify(this._messagesHydrated[id] || []); | ||
| // Refresh the LRU size estimate in place (Map.set keeps the order). | ||
| if (this._hydratedReads.has(id)) this._hydratedReads.set(id, json.length); |
There was a problem hiding this comment.
Evict newly clean transcripts after flushing
When several hydrated transcripts are created or enlarged through setMessages, they are correctly pinned while dirty, and this line updates their size estimates during the flush. However, neither the synchronous nor asynchronous flush invokes _evictHydrated after the writes become clean; eviction only runs on a later cache miss in _hydrateMessages. If subsequent accesses are all cache hits, the hydrated cache can therefore remain arbitrarily above the new 16 MiB budget indefinitely, defeating the cap for actively created or grown threads.
Useful? React with 👍 / 👎.
Part of #1475, round 3, from PM3's 'didn't move' list: the hydrated-transcript LRU from #1481 capped by count only.
What changed
MAX_HYDRATED_BYTES(16 MiB of shard JSON) next to the 8-thread count cap.Measured (worker, clone of the real store, forced GC, 3 runs): opening the 10 largest threads adds +19.2 MB of heap instead of +32.8 MB (−41%). Store load is unchanged (55 vs 56 ms).
Verified independently
store-hydrated-budget.test.jsfails on main: 3 of 4 tests.Not done, deliberately: lazy side-file reads at boot. Measured at ~19 ms of an ~85 ms Store load.
🤖 Generated with Claude Code