Repository navigation
Conversation
SGLang refreshes every radix node that a match or insert walks, including a child whose edge is only partially matched and then split, so the retained suffix and the new prefix node are both most recently used (legacy `_match_prefix_helper` and `_insert_helper` in python/sglang/srt/mem_cache/radix_cache.py L731-L739 and L794-L813 at v0.5.20; the default unified tree core touches the walked child and refreshes it again in `_split_node`, unified_cache/unified_tree_core.py L1196-L1200 and L1396). Re-inserting a sequence whose pages are all cached walks and refreshes the same path. The simulator split a partially matched child without refreshing it, so its suffix kept the old timestamp, and an insert with no new pages returned before refreshing the path. Refresh the child before splitting it on the match and insert paths, and refresh the start path even when the inserted suffix is empty. Read-only admission matching and Belady's page-wise eviction are unchanged. Signed-off-by: Rudy Pei <yanrpei@gmail.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Superseded by #583, which now contains this change together with the related SGLang cache lifecycle, eviction, reporting, and KV-event corrections. The consolidated branch has passed local core and public-API validation. |
Why and what changed
A partial radix match or insert splits a cached edge without refreshing its retained suffix. Finishing a request whose entire sequence is already cached can also return before refreshing the path. Both leave recently accessed KV older than an unrelated prompt and change the next eviction victim.
Refresh a matched child before splitting it, and refresh the start path even when an insertion has no new pages. Apply this to token and page-hash entrypoints.
Review map
crates/core/src/engine/cache/radix_cache.rs.Evidence
cargo test -p aisimulate-core— 2,446 passed, zero failures, 1 ignored. This full suite ran before the final comment/legal-only changes; final-head focused results follow.cargo test -p aisimulate-core --lib -- engine::cache::radix_cache::tests— 40 passed, zero failures. Nightly formatting and packaged legal-file checks passed.Modeling or data provenance
The behavior follows SGLang v0.5.20 (radix matching and insertion). Tests use synthetic token sequences and a controlled clock; no measured performance claim.
Tracking
None.
This pull request and its description were written by Isaac.