Repository navigation
Prompt cache: TF_CACHE_EVICT=decayed_resume, up to 34% fewer rebuilt rows on agent traces (opt-in) - #3258
Merged
Conversation
This was referenced Nov 13, 2026
1 task done
ashhart
force-pushed
the
lead/cache-evict-decayed-resume
branch
from
November 14, 2026 20:08
9e36684 to
b6280d0
Compare
ashhart
added a commit
that referenced
this pull request
Nov 16, 2026
This was referenced Nov 16, 2026
Six growing agent conversations on a shared 8,192-token system prefix with one-offs between turns, two cohorts of interleaved chats, and unique one-off prompts, replayed through Store.begin/keep/lookup/restore/remove at 4, 8 and 16 GiB. Shared cuts reach the store, so a common system prompt restores as a prefix. A frequency/probation selector runs beside main's for comparison; production eviction is unchanged. zig build cache-agent-replay prints the records. Refs #3241
…in eviction (opt-in) A resumed snapshot gets eight store ticks of recency credit, at most two resumes' worth, so a conversation that keeps coming back outlives one-off prompts without outliving its use; redundant copies, the active rewind, borrowed entries and reservations keep main's protections. Off by default: unset, eviction is main's order exactly (host controls replay main's choices on every trace). Measured through the real store on frozen traces: at 16 GiB agent loops rebuild 28-34% fewer prompt rows and agent cohorts 24-30% fewer, at 4 GiB 4-18% fewer across agents and chats, no cell worse on seeds 7, 11 and 23. The replay gains an agent-cohort trace and confirmation runs per seed. Refs #3241
ashhart
force-pushed
the
lead/cache-evict-decayed-resume
branch
from
November 16, 2026 09:56
b6280d0 to
e0123b0
Compare
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.
Refs #3241. Stacked on #3247 (the replay harness); it lands after it.
TF_CACHE_EVICT=decayed_resume(off by default) gives a resumed prompt-cache snapshot eight store ticks of recency credit, at most two resumes' worth (16 ticks). A conversation that keeps coming back outlives one-off prompts, but not for ever: an entry more than 16 ticks newer still outranks it, however often it was resumed. Main's protections stay as they are: redundant copies go first, then the active rewind, borrowed entries and reservations. Unset, eviction is main's order exactly; host controls replay main's choices on every trace and compare them choice for choice.The gate was fixed before any run: in every trace and budget, no more rebuilt prompt rows than main, and strictly fewer in at least one agent cell. Rebuilt rows are the prefill a user waits for. Results through the real store, at 4, 8 and 16 GiB:
At 8 GiB every cell ties. No cell is worse on any seed. On the fresh seeds 11 and 23, hits never fall below main's. On seed 7, the first measured, two 16 GiB cells lost one hit each (286 to 285 of 864) while rebuilding a third fewer rows. That is why the gate measures rows, and why it was re-run on new seeds before this change.
Replies are unchanged by construction: eviction decides only which snapshots are kept, and every restore is checked equal to its cold run. Opt-in for now. Making it the default comes after a served A/B on agent follow-ups.
Checks on today's main (macOS):
zig build -Dfixed-cpu compile-cache-replay-host test-cache-replay-host test-cache-agent-host test-cache-store-host test-cache-confirm-host test-cache-decay-host test-prompt-cache-host cache-confirm-nativepasses and prints the same records. fmt clean, lean 341 (same as main).