Verdict: worth merging (with one small follow-up: document the JSON story)
The change is still small, in the right layer, backed by real evidence, and closes a reported observability gap (#537). The latest push (9cca87ac, "Keep page gauges out of the copy-out retry key") fixed the one real blocker I had and two of my prose requests, and it moved the retirement unpin ahead of request.take() as asked. What remains is one documentation/API-completeness item, not a design problem.
Fit against the charter
- Right problem, right place. #537 is a reproducible, version-cited defect ("KV cache usage cannot be computed with vLLM semantics", v0.3.2
c0c4f79) showing the existing gauges only bound the value (≈16 % upper, ≈0 % lower, vs ≈9 % on vLLM). That is squarely "a reproducible bug / bad docs" per the charter's merge list. The fix lives where the quantity lives —helios/src/cache.rs(cache-side pins),helios/src/scheduler.rs(slot state),helios/src/server/metrics.rs(gauge) — with no new flag, no env switch, no per-model branch, no backend abstraction. Nothing here approaches a non-goal. - Respects an existing invariant instead of working around it.
PrefixCheckpointCachealready maintainsready_checkpoints/unready_checkpoints/tail_pagesprecisely sostatsnever scansnodes(cache.rs:219-224, 816-837); the newrequest_pinned_pagesfollows that established pattern, incremented/decremented along the samechain(id)walkpin/unpinalready perform (cache.rs:551-580). The alternative — scanning checkpoints per scrape — is what the existing comment forbids, so this is the smallest-footprint correct design the charter asks for: ~120 lines of runtime code plus tests and prose. - No duplication, no simpler route. #537's own alternative (split
cached_kv_pagesinto pinned/idle) costs identical bookkeeping and yields a less directly usable number; a ready-made ratio gauge is simpler for an operator but hides the reserved term and freezes the arithmetic. Two composing counters is the right grain, and no existing gauge can produce the value — that is the entire complaint. - Benefit and who gets it. Operators migrating vLLM/Grafana dashboards, and specifically the open monitoring example #541, whose KV panel can otherwise only show bounds.
scripts/qualify_worker_failure.py:143(not opened) already readsflare_free_kv_pagesfrom this endpoint.reserved_kv_pagesadds attribution previously invisible: those pages leavefree_pagesat admission (scheduler.rs:1721-1724) and appear in no other gauge. The measured reserved term is 2-3 pages under streaming load, so the request gauge is the valuable half; the reserved gauge is cheap and should not be oversold. - Cost: negligible and bounded. Two
u64perCheckpoint, twousizeon the cache struct (a type alreadyCloned for snapshot quotes, so the words ride along), one add/sub per pin on a chain already walked for aVec, and a per-statsloop over at most slot-count live requests (scheduler.rs:1216-1228). No GPU work, no allocation, no scheduling decision.
What the new push changed, and what I verified
- Copy-out retry key (was a blocker) — fixed.
CopyoutResourcesembedsSchedulerStatswhole and derivesPartialEq, Eq(runtime.rs:1053-1059, compared at 2455), so live page counts would have re-offered deferred host copy-outs whenever decode crossed a page boundary. The push zeroesrequest_pages/reserved_pageswhen building the key (runtime.rs:2446-2450), with a comment saying why. That restores "no scheduling decision changes". It is a slightly awkward shape (a stats struct partially nulled for a cache-resource comparison), but it is three lines, documented, and the honest minimal fix; a dedicated cache-resource key struct would be nicer and is not worth demanding here. - Retirement ordering — fixed.
retirenow releases the request pin beforerequest.take()(scheduler.rs:3149-3157), so a future mispaired release leaves the request inspectable instead of leaking a pin behind a half-destroyed slot. This was my main hardening ask and it is the cheap form of it. - Pin-flavour duplication — reduced. The three
if inbound.is_none()branches at admission collapse intopin_prefix/unpin_prefixbehind a singlerequest_pinbinding (scheduler.rs:1643-1645, 2025-2040). The ticket-parent pin still precedesensure_resources, as it must. - Docs — mostly accurate now. docs/api.md:298-312 now states that the worker publishes on each scheduler pass rather than the scrape reading scheduler state, that request-pinned checkpoint pages also appear in
flare_cached_kv_pages, that reserved pages are outside the request gauge sorequest + reservedis the cross-runtime figure, and that retiring pages and an in-flight restore ticket are excluded. That answers three of my four requests and the honest double-count disclosure is exactly what #537 needed. - Counter correctness — re-checked. Creation starts both counts at 0 (cache.rs:458-462);
count/uncountnever touch request pins, so entry/exit fromnodesis neutral; compaction asserts ancestor and heir agree (debug_assert_eq!(node.request_pins, child.request_pins), cache.rs:626-627) and the mergedtail_pagesstay in the counted heir, so the union length is preserved; a node withrequest_pins > 0impliespins > 0, so eviction cannot strand counted pages (cache.rs:658-663). The strengthened test-only drift assertion (cache.rs:819-837) compares the maintained count against a full scan on everystats()read across the whole cache/scheduler suite — proportionate for a gauge-only counter, and the same pattern its neighbours use. The parent/two-children test asserting 3 rather than 4 (cache/tests.rs:320-342) pins the "shared page counted once" property, and the scheduler test asserts shared + both private sets and the reserved sum, then zero on retirement with cached pages remaining (scheduler/tests.rs:970-1034).
Evidence
Meets the charter's bar: why / what / claimed result / evidence, a Discord: line, and an explicit statement of what was not run (Windows build, full helios suite → CI). The live scrape is the right shape — idle 0/0 with 2019 cached of 21504; two concurrent streams 399/402 request pages, 3/2 reserved, 2037/2043 cached; the ratio 0.0186/0.0187; the sanity inequality holding — and it correctly disclaims comparison with another runtime and discloses that the agent's own traffic is included. No performance claim is made, which is correct for a visibility-only change, so the "benchmark against main" rule does not apply.
The one thing still outstanding
The JSON surface diverges silently. Snapshot (metrics.rs:68-129) is the documented format=json body and docs/api.md:332-362 is the JSON↔Prometheus table; these two gauges are Prometheus-only and the prose does not say so. Either add request_pages/reserved_pages to Snapshot (two fields, one line each in Metrics::snapshot, one row each in the table — and the terminal dashboard could then plot them) or add one sentence to docs/api.md saying these two are Prometheus-only and why. Two Prometheus-only gauges among dozens of snapshot fields is fine; leaving it unstated is the drift the repo's own docs rules push against. This is the only item I would actually block on, and it is under ten lines either way.
Two things worth knowing but not worth blocking: the parallel pin flavour still lives only in comments plus the drift assertion (a Debug-only cross-check that every live request with prefix: Some(_) carries a request pin would make a future mispair fail loudly — the release-ordering fix above already removes the silent-leak failure mode), and pages of self.retired and of an in-flight restore ticket remain outside both gauges, which docs/api.md now states.
Bottom line
Worth merging. This is a focused, well-evidenced, correctly-layered observability addition to a gap a user reported with reproduction detail, at a complexity cost the cache was explicitly designed to absorb, and the last push removed the one behavioural regression it had introduced. Ask for the JSON-gauge documentation (or the two fields), then land; the Windows build and the full helios suite should go green in CI first, as the description itself flags. #549 and #548 touch disjoint regions of metrics.rs, so merge order does not matter.