TL;DR
kv_entry_eviction_score is (hits+1) * tokens / size regardless of reason. A freshly written cold or evict checkpoint loses the eviction race to a competing workload's fresh continued snapshots on density alone. In production a 1.3 GiB live-state save died within ~5 min while a second conversation prefilled.
How it fails today
When conversation B writes a continued, A will have a cold, an evict, & a continued on disk.
The score function gives all three the same weight, so the victim depends on incidental density differences and not on intent. If cold & evict were boosted, the continued would be the consistent target.
Then if conversation A resumes right where it left off the evict would cache hit and a significant amount of prefill time would be avoided.
In a production case the live-state evict was 1.3 GiB and got unlinked after 5m 19s while B prefilled.
Proposed fix
Bump the base from 1.0 to 4.0 for KV_REASON_COLD | EVICT | SHUTDOWN in kv_entry_eviction_score. Continued and unknown stay at 1.0. A continued must serve three real hits before outranking a fresh same-shape checkpoint. Existing hit decay still applies.
TL;DR
kv_entry_eviction_scoreis(hits+1) * tokens / sizeregardless ofreason. A freshly written cold or evict checkpoint loses the eviction race to a competing workload's fresh continued snapshots on density alone. In production a 1.3 GiB live-state save died within ~5 min while a second conversation prefilled.How it fails today
When conversation B writes a continued, A will have a cold, an evict, & a continued on disk.
The score function gives all three the same weight, so the victim depends on incidental density differences and not on intent. If cold & evict were boosted, the continued would be the consistent target.
Then if conversation A resumes right where it left off the evict would cache hit and a significant amount of prefill time would be avoided.
In a production case the live-state evict was 1.3 GiB and got unlinked after 5m 19s while B prefilled.
Proposed fix
Bump the base from
1.0to4.0forKV_REASON_COLD | EVICT | SHUTDOWNinkv_entry_eviction_score. Continued and unknown stay at1.0. A continued must serve three real hits before outranking a fresh same-shape checkpoint. Existing hit decay still applies.