PR #665 — helios: add scan-resistant dual-turnover prefix cache eviction
Case file across all nine angles. Facts are separated from author claims; every citation is to the head commit a7568c2 or to a named PR/issue.
Key findings
- It silently changes a documented invariant certified four days ago. #568 (merged 2026-11-28) states "Victim ordering remains strictly
(node.retention_rank(), node.id)" anddocs/core-design.md:1565still says captures "reclaim lower-rank victims strictly by demand-recency order". #665 makesis_protectedthe first sort key (helios/src/cache.rs:363-365, used at:732), so a reused lower-rank victim now outranks an unreused higher-rank one. The description never mentions #568 or that it revises that guarantee. (#568, #665 diff) - It partially reverses #298/#416 without saying so. #298 (2026-11-15) introduced the completion-recency refresh precisely so a long-running request is not evicted just before its client returns; #416 extended it to the host store. #665 keeps the completion
touch(helios/src/scheduler.rs:3107-3118) but routes it through plaintouch, so completion no longer confers protection, only MRU order within the unprotected tier (onlytouch_hitpromotes,cache.rs:384-389). Neither PR is referenced. - The design docs that specify this exact policy are not updated.
docs/core-design.md:1538-1583describes the touch policy and victim order as unchanged; search forretention_rankindocs/returns onlycore-design.md:1576. #298, #416, #567, #568, #582 and #655 all editeddocs/*— the local norm. #665 touches only 4 files, all underhelios/src. - Three mechanics the description does not spell out (all verified in code): the aging horizon is global, not per-node —
is_protectedcompares turnover againstself.tail_pagesandself.ready_checkpoints(cache.rs:353-360); onlyretire_leafforreadynodes increments the turnover counters (cache.rs:604-609), socompact_ancestor(cache.rs:626-657) never ages protection; andmark_reusedusesself.nodes.get_mut(&id).unwrap()(cache.rs:370), the only new uncheckedunwrapon a&mutpath. - The one path the description admits is unmeasured is also untested. Both A/B arms run
--prefix-cache-memory 0, so the host tier is off and the newtouch_hiton host restore (scheduler.rs:1884-1887) has no live evidence and, as far as I could find, no direct unit test — the 4 added tests are cache-level only. - Process gap against the repo's own written standard.
docs/design-review.md:226-228requirescheck.py --mutations/cargo-mutants "when adding or changing safety guards"; #665 adds one (is_protecteddemotion) and reports onlycheck.py --jobs 4. The existing mutation target atverification/helios-lifecycle/check.py:515-519sits on the veryprotected_eviction_tokensline #665's filter chain builds on. #568 and #582 both reported--mutations. Zero CI checks on the head commit, zero reviews, zero comments. - Guaranteed textual conflict with open #549 in the same
Checkpointstruct literal and the samekey()sort inhelios/src/cache/lifecycle_tests.rs.
The change
Size. 4 files, +271/−6, all under helios/src: cache.rs +64/−4, cache/tests.rs +192/−0, cache/lifecycle_tests.rs +6/−1, scheduler.rs +9/−1. Net production code ~68 lines; the rest is tests. Claimed and verified: no CLI flags, no floats, no unsafe, no model branches, no core/wire-format change (the added fields are in-memory Checkpoint fields only, cache.rs:84-86).
In plain terms. GPU prefix-checkpoint eviction used to rank victims purely by RetentionRank { use_epoch, role, consumed_tokens } plus id — essentially LRU-plus-role (cache.rs:90-96, :732). Because RequestScheduler::retire refreshes use_epoch on every completion, dead one-shot prefills land at the MRU end and reused multi-turn sessions get dropped first. The patch adds a one-bit per-checkpoint "reused" flag plus a turnover-based aging rule and puts protection ahead of rank:
- New
Checkpointfieldsreused,reused_at_evicted_pages,reused_at_evicted_nodes(cache.rs:84-86). - New
PrefixCheckpointCachecountersevicted_pages,evicted_checkpoints, incremented only fornode.readyleaves inretire_leaf(cache.rs:604-609). is_protected(cache.rs:346-361): false unlessreused; demotes only when both page turnover ≥tail_pages.max(1)and node turnover ≥ready_checkpoints.max(1)since the node's last hit.eviction_key→(is_protected, retention_rank, id)(cache.rs:363-365), used byeviction_candidate_within_budget'smin_by_key(cache.rs:732), after thebelow/immediate/protected_token_budgetfilters (cache.rs:712-731) which are untouched.eviction_candidates(),reclaimable_if_pinnedand retirement fences unchanged.touch_hit=touch+mark_reused(cache.rs:384-389), called on: duplicate publicationPublishResult::Existing(cache.rs:471); fresh admission hits viafresh_admission = accounting.is_none()(scheduler.rs:1727,:1734-1739); successful host restorePublishResult::Createdinfinish_inbound(scheduler.rs:1884-1887).- Inheritance (
cache.rs:478-481): a new checkpoint is born protected iff its parentis_protectedandparent_len * 2 >= tail_tokens(parent is ≥ one third of the new endpoint). - Completion
touchinretire(scheduler.rs:3107-3118) and preemption re-admissions stay plaintouch.
Description vs. diff. Everything the description claims is present, in the stated place. Three behaviours it does not state are in Key finding 4; the fresh_admission = accounting.is_none() gate is correct for preemption (re-admissions carry Some(accounting) from runtime.rs:1518/1534/1551/3174 while first-time admissions pass None at runtime.rs:1643/3866/4061), and retries inside admit_with_host_store pass the same carried accounting, so they do not re-mark reuse.
What the description says that the change does not do: nothing found — the stated limits are honest (--prefix-cache-memory 0, SM120 TP4, no effect when capacity fits or scans exceed capacity).
The why
- No linked issue, no user report, no "closes". Nothing in the tracker asks for scan-resistant or frequency-aware prefix eviction: searches for scan thrash, reuse-frequency protection, TinyLFU, LRU victim order, idle-session eviction return only #665 or unrelated items. The motivation rests entirely on the author's own measurement.
- Nearest real pain that motivated this area historically: #298 (voipmonitor; 200k–580k-token Kimi K3.1 agent sessions on 16 GPUs, "a request that ran for minutes finished ranked below everything admitted meanwhile ... its conversation was evicted first, just before the client continued"); #567 (avifenesh, final decode snapshot competing with cached inputs); #600 (multi-turn/tool-transcript misses). None is a scan/thrash report and #665 cites none.
- Sustained churn: five eviction-policy PRs in three weeks — #298 (11-15), #416 (11-23), #460 (11-23), #568 (11-28, after closing #567), #665 (12-01). That is maintainer-driven design on the same ~40 lines of
cache.rs, not a backlog item. - The design rationale in the body ("1-bit frequency caches fail in two regimes ... unbounded protection livelocks on phase shifts ... size-penalizing policies evict Turn 1 of 120K+ sessions") is asserted with no linked experiment.
Related work
- #298 (merged 2026-11-15, voipmonitor) — origin of the completion-recency refresh #665 blames; its third commit deliberately narrowed refresh to terminal + direct parent. #665 keeps the touch but removes its protective effect (see Key finding 2).
- #416 (merged 2026-11-23, jcartu) — extended completion recency to the host store (
retirequeues reused keys →take_reused()). Same relationship. - #567 (closed unmerged 2026-11-28, avifenesh) — "Preserve resident prefixes on ordinary completion", same eviction tradeoff; lukealonso closed it "in favor of #568". #665 is the third attempt in ~4 days.
- #568 (merged 2026-11-28, lukealonso, +1051/−44, 12 files) — direct predecessor. Added
protected_eviction_tokens(cache.rs:684-704) andeviction_candidate_within_budget(:706-734) with the explicit invariant "Victim ordering remains strictly(node.retention_rank(), node.id)". #665 replaces exactly that one line and leaves #568's budget arithmetic intact, so budgeted victims are still counted againstleaf_tokens/(1+age)but offered in a different order. #568 also shipped 5 end-to-end workload policy tests inhelios/src/scheduler/policy_tests.rs(not opened) (reverse-order revisits keeping ≥7/8 anchors; regime shift aging out 4/4 stale documents; a 256-token reasoning reply reclaiming an older 128-token anchor). #665 does not touch that file and does not single those tests out in its evidence. - #460 (merged) — source of the
ready_checkpoints/tail_pagescountersis_protectedreads. - #549 (open, WynnD, "Report KV pages held by active requests") — edits the same two test files and the same
Checkpointstruct literal (Fixture::fork,lifecycle_tests.rs:64-96vs:64-98) and the samekey()sort (:499-502): guaranteed textual conflict whichever merges second, no semantic conflict (pins vs victim order). - #655, #661, #663, #654, #548, #560, #621, #571 — all touch
helios/src/scheduler.rsbut none overlapsadmit_planned_with_checkpoint_accountingorfinish_inbound; #655 clearssnapshot_discoveryinretire, adjacent to but not overlapping #665's block. Judged not related: #619, #613, #612, #588, #664, #659, #662, #660 (export, offload, scheduling pricing, metrics — different layer).
Recent activity
- Base is
5d53040e(#628, yatesdr, 2026-12-01). No commit on the default branch since then touches #665's four files, so the PR is rebase-clean today. - The last 8 commits in
helios/src(≤60 days) are all 2026-11-30/12-01 and none is incache.rs:a3c80e19(#657),5d53040e(#628),e8a3a7c7(#656),cd1daa3e(#638),a4720050(#625),e85019b9(#645),bf7562ae(#646),f2ca2c41(#647). #665 lands in a comparatively quiet file whilescheduler.rschurns around it. cache.rshistory newest-first:a7568c2c(#665),5deacda9(#568),6d6fe0c6(#460),29192ef7(#298). So the three most recent substantive edits are precisely the ones #665 builds on (#460's counters, #568's filter chain) and revises (#298's protection-by-completion).
People
- Author: FujitsuPolycom, GitHub association CONTRIBUTOR, Discord "Dooner". Last 180 days: 15 merged, 11 closed, 3 open. Concentrated in helios scheduling/checkpoint policy and export: #582 (zero-budget checkpoint anchors, +2264/−20 — this is the PR that shaped the
CheckpointAccountingthat #665'sfresh_admissiongate keys on), #540, #497, #586/#587 (heliopause export), #649 (open), #660 and #661 (open, same day; #661 still draft). - Who else is here:
helios/srccommits in 180 days — Luke Alonso (235), Martin Vit (52), yatesdr (48).cache.rsitself has been authored by yatesdr (#460, #549), lukealonso (#568, TLA+ #595) and voipmonitor (#298). yatesdr and lukealonso are the de-facto reviewers of this file. - Expected iteration: #582 needed two review rounds (voipmonitor and lukealonso found duplicate-Anchor-capture blockers and a rebase conflict with #613). This author ships large scheduler changes but iterates under review.
- Engagement on #665: none — no reviewers, no comments, no reactions.
Community
- Zero comments, zero reviews, zero reactions (
pr_comments: "No comments"); opened and last updated 2026-12-01. - Not even automated intake: #549, #655, #567 and #568 each have a "A case file has been opened for N" comment plus flare-autobot reviews; #665 has neither.
- The only stated discussion venue is Discord ("Discord: Dooner"), i.e. any design discussion that shaped the policy is off-GitHub and not reviewable from the PR.
- Given the heavy maintainer attention the eviction question has had (#298/#416/#460/#567/#568 in three weeks), silence here is absence of engagement, not evidence of disinterest.
Project fit
Lines up:
- Charter "Bring real evidence. Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)" — satisfied in shape: served workload, A/B against a named main commit, settings line given.
- "Keep the runtime small and model-agnostic ... no per-model special cases or flags" — zero flags, no model branch, integer-only arithmetic, ~68 prod LOC.
- Four-part PR description (why / what / result / evidence) present and in order.
- Goal "Store prefix-cache checkpoints in host memory and share them via Selene" untouched — GPU-tier only, and the PR says so.
docs/design-review.md:50"eviction ... must not branch on model or hardware" — satisfied.
Does not line up:
docs/design-review.md:226-228mutation testing for changed safety guards, and:247-251"Leaving an applicable crate test, simulator sweep, TLA+ conformance run, or Kani proof unrun blocks commit and PR acceptance; noting it as a limitation does not make the omission acceptable". #665 reports TLA+ but no--mutationsand no Kani.docs/design-review.md:195-208asks scheduling/cost-policy changes to be checked againstscripts/scheduling_sim/. #568 and #655 both explicitly stated the simulator does not model checkpoint eviction; #665 says nothing either way.- The design doc specifying the changed behaviour is not updated (Key finding 3). The charter does not mandate it; every comparable merged PR did it.
Claims and evidence
Verified as claimed: the test/TLA+ command shapes are plausible and consistent with the workflows (.github/workflows/helios-lifecycle.yml (not opened) runs check.py + cargo kani --features runtime-core --lib; native-serving.yml (not opened) runs cargo test --features runtime-core,server); the LOC split matches pr_files; "no core-format changes" is true.
Author-reported only, no CI:
cache::137,scheduler::408 (4 ign),flare --lib238 (4 ign),flare-cli239 (3 ign), rustc 1.94.1, 0 warnings. No before/after test count; noserver::/runtime-core,serversuite listed (wherefinish_inbound's callers live); no selene suite (which #298/#416 reported).- TLA+
check.py --jobs 4: 10/10 models, 8/8 trace suites, 621,390 transitions, 12/12 checks. No--mutations, no Kani.verification/helios-lifecycle/contains noRetentionRankreference, which is consistent with the models not covering victim order — so "TLA+ passes" does not evidence the changed ordering either way. - The A/B table: scan-thrash 24x8K vs 8x214K — hit 19.76% → 37.31% mean (1.89x), evicted 168/215 → 132/217, saved tok/s 1,416.7 → 2,781.8 (+96.4%), TTFT p50 8,746.5/5,498.5 → 7,243.7/5,352.6 ms. Long-MT 4x127K 4-turn vs 12x8K — 28.62% → 49.71% (1.74x), evicted 17/24 → 12/24, TTFT p50 23,886.7/22,228.7 → 2,876.8/3,459.5 ms (−86.3%), saved tok/s 3,742.5 → 6,578.2 (+75.8%), Bg 727 → 752. Method: single boot, 4x RTX PRO 6000, DeepSeek-V4.1-Flash TP4, 2,606,848 KV tokens / 20,366 pages, 0 errors/preemptions, 2 cold-salted trials per arm. So n=2, single boot, no variance/CI reported, "cold-salted" undefined, no p99 or per-request distribution. The −86.3% TTFT on Long-MT is an order-of-magnitude jump that the 1.74x hit-rate change does not by itself explain.
- Serving sanity: HTTP 200, 37×41=1517, 204/204 finite logprobs, 0 failed requests on both boots — smoke test only.
- "Selene restore
touch_hitis verified by unit tests and TLA+" — but both arms run--prefix-cache-memory 0, the four added tests are cache-level (scan-vs-reused victim, inheritance threshold, dual-turnover demotion,reclaimable_if_pinnedparity), and I found no test drivingfinish_inbound'stouch_hit(scheduler.rs:1886) specifically. This claim is the weakest in the description.
Reach
- Blast radius: both pressure paths.
evict(cache.rs:759-775, called fromensure_resourcesscheduler.rs:1272andrefill_reservations:1356) and the budgeted optional-capture patheviction_candidate_within_budget(scheduler/cache_memory.rs:365inquote_snapshots) pick victims by the new key. So it changes which Anchors/Endpoints survive, not just which leaves are dropped. - Operators: zero knobs, zero defaults, zero metrics, zero logs.
CacheStats(cache.rs:880-905) has no protected/reused field, so a deployment that regresses cannot even see why. Contrast #549, which exposes gauges. - Compatibility: in-memory only; no wire/core-format change; existing exported cores still load.
- Docs: none updated —
docs/core-design.md:1538-1583,docs/scheduling-runtime-design.md(not opened),docs/prefix-cache-offload.md(not opened) all remain as-is; an operator reading the design doc after this lands is told victim order is "strictly demand-recency". - Host/Selene tier: GPU ordering does not apply there, but host restore now promotes GPU protection — a cross-tier side effect stated in the description and unmeasured.
Process
Open, marked ready for review, opened and last updated 2026-12-01 (same day as this case file). No CI checks on head a7568c2. No reviews, no comments. Self-contained (4 files, no docs, no verification/, no workflow edits), so no new approval path beyond normal review is needed — but per docs/design-review.md:226-251 the missing mutation/Kani run is a written blocking condition, not a nicety.
Open questions / could not verify
- Do #568's five end-to-end policy tests in
helios/src/scheduler/policy_tests.rs(not opened) still hold under the new first key? The PR reportsscheduler:: 408 (4 ign)passed but does not single them out, and I did not run them. - Is
finish_inbound'stouch_hit(scheduler.rs:1886) covered by any test? I found none; the description's claim points at unit tests that are cache-level. - The A/B numbers are author-reported, n=2 trials per arm on one boot; I have no access to the hardware and did not reproduce them. The Long-MT p50 TTFT −86.3% is unexplained by the reported hit-rate delta.
- Does the compaction path (
compact_ancestor,cache.rs:626-657, which never touches the turnover counters) leave protection effectively permanent under single-child-ancestor pressure? Verified in code, not exercised by any test I found. - Older (pre-30-day) user-facing scan/thrash reports were not exhaustively searched; the no-issue finding holds for open items and items closed in the last 30 days.
- How #298's motivating workload (Kimi K3.1, 16 GPUs, 200k–580k-token sessions) behaves under the new ordering is not measured anywhere — #665's evidence is DeepSeek-V4.1-Flash TP4 at 128-token pages.