Repository navigation
Limit the timeline cache by bytes instead of row count - #7063
Merged
Merged
Conversation
The response cache skipped every window over 200 rows. On real data that was half of recently used threads, so switching back to a busy thread always rebuilt it, although those windows were only modestly larger (up to about 0.7 MiB). Windows are now cacheable up to 2 MiB each, measured with the row digests the tag already computed, and the cache holds at most 64 MiB in total. With bytes bounding memory, the entry limit rises from 128 to 512 so a rotation of more than 128 threads no longer evicts every window just before it is reopened. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
The timeline response cache skipped every window over 200 rows. Row count is a poor proxy for size: on a live database, the latest window of 72 of the 150 most recently updated threads was over 200 rows (Claude Code's finished turns stay flat, so one busy turn gives 140 command rows), while those windows were only modestly larger, median 318 KiB and at most 732 KiB, against 130 KiB for the cached ones. Switching back to any busy thread therefore always rebuilt its window. Follows #7034.
What changed
apps/server/src/services/threads/timeline-cache.ts:timelineWindowJsonLength, the same measure the served-windows cache uses. It reads the row digeststimelineWindowTagalready computed, so measuring adds no serialization.How you verified
VACUUM INTOcopy of a live database (8.4 GB):createThreadTimelineWindows().readfor the latest window (deferContent, as the app requests) of the N most recently updated threads, once cold, then three reopen passes.pnpm exec turbo run typecheck lint --filter=@bb/server, and the servertest/services/threadsandtest/public/public-thread-timeline*suites (38 files, 343 tests) pass.🤖 Generated with Claude Code