#1 [high] Should fix: pin_request/unpin_request duplicate pin's chain walk and skip its refcount-overflow guard
PR 549, helios/src/cache.rs.
Precedent: Cache::pin (cache.rs:519-534) and unpin (cache.rs:536-546) compute self.chain(id)? once, check self.nodes[&id].direct_pins == u64::MAX || chain.iter().any(|id| self.nodes[id].pins == u64::MAX) and return Err("checkpoint reference count exhausted") before mutating.
New pin_request (cache.rs:551-563) does self.pin(id)? (which walks the chain) and then let chain = self.chain(id)?; again — two Vec allocations and two root-walks per pin, and the exact pattern is repeated in unpin_request (cache.rs:565-580, self.unpin(id)? then self.chain(id)?). Departure from the one-walk-per-operation shape of the siblings it wraps.
Second departure: the new counters direct_request_pins/request_pins are incremented with += 1 and decremented with -= 1 with no u64::MAX guard, whereas the existing cumulative pins/direct_pins are guarded by an explicit checked check in pin. The subtraction side relies only on the direct_request_pins == 0 early-out plus debug_assert_eq! in compact_ancestor (cache.rs:627) and the test-only scan in stats (cache.rs:819-837), so a mismatched release in a release build silently underflows request_pinned_pages (usize) instead of erroring the way unpin does.
Fix: fold the request accounting into pin/unpin behind a parameter (or a private pin_with(id, request: bool)), computing chain once and running the overflow guard over both pin sets; keep the tests' error messages by branching only in the error text. If the two-walk shape is kept, at minimum add the same u64::MAX check for request_pins.
Verified by reading cache.rs:519-580 and cache.rs:613-646.
#2 [high] Should fix: three copies of the pin/pin_request branch in admit_planned break the single-binding pattern
PR 549, helios/src/scheduler.rs:1643-1649, 1657-1669, 1683-1692.
Before the change the admission path took one let pinned = ... (scheduler.rs:1638-1642) and paired it with a single self.cache.pin(id) / self.cache.unpin(id) shape at each rollback site. Now the same two-branch conditional
if inbound.is_none() { self.cache.pin_request(id)? } else { self.cache.pin(id)? }
appears at 1643-1649 and the mirrored unpin_request/unpin rollback appears twice more (1657-1669, 1683-1692). Three copies of the pairing must stay in sync: a single missed mirror pin/unpins the wrong counter, which then trips only the test-only drift assert in Cache::stats (cache.rs:819-837) and nothing in a release build. The file's established convention is to encode such pairs once (cf. pinned/pin above, and pin_checkpoint/unpin_checkpoint wrappers at scheduler.rs:2038-2044 which exist precisely so callers cannot mismatch).
Fix: carry the pin kind in the existing binding, e.g. enum PinKind { Request, Admission } chosen next to let pinned = ..., and use one self.cache.pin_as(kind, id) / unpin_as(kind, id) at all three sites.
Also worth confirming with the author (documentation convention, docs/api.md:298-305): an Inbound request contributes neither to request_pages (its prefix is None until finish_inbound) nor to reserved_pages, while its ticket's ticket.pages are held out of free_pages — so those pages are in no gauge, although SchedulerStats::inbound_waiting (scheduler.rs:137-138) documents Inbound requests as active. docs/api.md says the gauges count "the distinct KV pages that active requests reference". Either count ticket pages in reserved_pages-like accounting or state the exclusion in docs/api.md.
#5 [high] Should fix: scheduler now has two parallel named-kind wrapper pairs (pin_prefix/unpin_prefix vs pin_checkpoint/unpin_checkpoint), and half the call sites bypass them
Supersedes the earlier "three copies" note for the admission path.
Commit 9cca87ac added:
- helios/src/scheduler.rs:2025-2040
pin_prefix(&mut self, id, request: bool)/unpin_prefix(&mut self, id, request: bool)— dispatch on a bare bool. - helios/src/scheduler.rs:1643
let request_pin = inbound.is_none();then calls at 1645 (pin), 1656 and 1678 (unpin). The three copies are gone; the remaining shape issue is the mechanism.
Why it's a conventions departure:
- The repository already has exactly this convention with a named pair:
pin_checkpoint/unpin_checkpoint(helios/src/scheduler.rs:2042-2050), each documented as "Pins a GPU-ready checkpoint for the worker's copy-out", each a one-line forwarder tocache.pin/cache.unpin. Addingpin_prefix/pin_checkpointas two bool-vs-name variants of the same two forwards means the scheduler now expresses "which counter" two different ways for the same underlying call, and a reader cannot tell from the name alone which sites are request pins. - The bool parameters are boolean-blind at the call site:
self.pin_prefix(id, request_pin)at 1645 reads as arbitrary without re-reading 1643. ThePinKind-style named choice, or aCache::pin_requestvsCache::pinpair selected once in thepinnedbinding, keeps the pairing visible aspin_checkpointdoes. - Half the request pins do not go through the new wrapper at all: helios/src/scheduler.rs:1889 (ticket waiter restore), 2977 and 2997 (boundary publication), 3155 (retirement) call
self.cache.pin_request/self.cache.unpin_requestdirectly. So there are now three ways to take a request pin (cache method directly,pin_prefix(.., true)), and the wrapper is used only on the admission path.pin_checkpointis used at every copy-out site (runtime.rs:2480/2496, 2705/2710, 2360/2364/2396) with no directcache.pinbypass in non-test code — that is the precedent the new wrapper should match: either every request-pin site goes through one named helper, or the helper goes away and the choice is folded into Cache::pin/unpin as the earlier finding asks.
Fix: pick one mechanism. Preferred: fold the accounting into the cache (pin_with/unpin_with, earlier finding), leaving pin/pin_request as named wrappers, and delete pin_prefix/unpin_prefix; the admission site then binds the method choice once in the pinned tuple. Alternative: keep the scheduler wrapper, give it a two-variant enum instead of a bool, and route 1889/2977/2997/3155 through it too.
Verified in code: helios/src/scheduler.rs:1643-1646, 1654-1657, 1676-1679, 1889, 2025-2050, 2974-2999, 3149-3156; helios/src/server/runtime.rs:2480, 2496, 2705, 2710.
#7 [high] Report: PR 549 review at 9cca87ac — should-fix conventions findings only
Verdict: should fix (conventions/duplication), no blocking issues
Evaluated at head 9cca87ac ("Keep page gauges out of the copy-out retry key"), 8 files, +246/-16, docs/api.md + helios/src.
Should fix
Cache::pin_request/unpin_request(helios/src/cache.rs:551-563, 565-580) callself.pin(id)/self.unpin(id)and then walkself.chain(id)?a second time, so one logical operation (the request-pin subset invariant) lives in two functions that must agree, at the cost of a second root-to-leaf walk +Vecallocation on admission, ticket hand-off, boundary publication and retirement. Precedent:pin(cache.rs:519-534) andunpin(cache.rs:536-546) each own their whole invariant in one walk with the refcount guards;count/uncount(cache.rs:258-275) are likewise the single site for the derived counters. Fix: privatepin_with(id, request: bool)computingchain(id)once, withpin/pin_request/unpin/unpin_requestas thin wrappers (see note #1).- The scheduler now carries two parallel wrapper pairs for the same forward:
pin_prefix/unpin_prefix(scheduler.rs:2025-2040, bool-dispatched, used only on the admission path at 1645/1656/1678) alongside the pre-existingpin_checkpoint/unpin_checkpoint(scheduler.rs:2042-2050, name-dispatched, used at every copy-out site in runtime.rs). Request pins at 1889/2977/2997/3155 bypass both wrappers and callcache.pin_requestdirectly, so the repository has three ways to take a request pin. Fix: one mechanism — fold accounting into the cache and deletepin_prefix/unpin_prefix, or keep the wrapper with a two-variant enum and route all four remaining sites through it (see note #5).
Nit
- docs/api.md:311-312 documents the
#[cfg(test)]drift assertion inCache::stats, and docs/api.md:302-303 says "every scheduler pass" though the worker publishes only when a pass makes progress (runtime.rs:1143-1153). AGENTS.md:52-60 on document purpose; the HELP strings already carry the contract (see note #6).
Checked and dropped
- New
AtomicU64fields (metrics.rs:265-266) and their bulk store (metrics.rs:514-521) plus the test fixture/expected exposition rows (metrics.rs:1789-1791, 1834-1835) follow the existingcached_pages/snapshot_backing_pagespattern exactly. No new mechanism. SchedulerStats::stats(scheduler.rs:1216-1228) iteratesslotsexactly as neighboursactive_requests(1203-1207),retiring_slots(1209) andcheckpoint_anchor_guards(1212) already do; no per-slot duplication and no existing helper computes these sums.PinKind-free bool concern is captured in finding 2, not separately.- The PR's two gauges are correctly absent from the docs/api.md JSON field table (332-355): that table maps JSON fields, and the gauges are deliberately not in the snapshot.
- Budgeting the drift assertion into
stats(cache.rs:816-837) reuses the existing#[cfg(test)]assertion rather than adding new machinery — the right precedent. - No pre-existing helper computes "pages held by live requests"; maintaining the counter incrementally matches
ready_checkpoints/unready_checkpoints/tail_pages(cache.rs:250-253, 258-275). - Local prose: docs/api.md 298-310's remaining claims (shared tail pages counted once; request-pinned pages also in
flare_cached_kv_pages) match cache.rs:553-561 and therequest_pins == 1transition, and cache.rs:830-834's drift predicate.
Not settled
- Whether the double chain walk is measurable — needs a micro-benchmark; the finding stands on structure alone.
- The runtime-core-design.md nit from the previous report (docs/runtime-core-design.md:873 documents
flare_snapshot_backing_pages) stands unchanged; it is not repeated as a finding here to avoid duplicating the earlier report.
#8 [high] Research summary
Reviewed PR #549 at head 9cca87ac through the conventions/duplication lens: all eight changed files read in context (cache.rs, scheduler.rs, scheduler/tests.rs, cache/tests.rs, cache/lifecycle_tests.rs, server/metrics.rs, server/runtime.rs, docs/api.md), judged against AGENTS.md, docs/design-review.md and the charter.
No blocking issues. Two should-fix items:
-
Cache::pin_request/unpin_request(cache.rs:551-580) wrappin/unpinand then walkchain(id)a second time, so one invariant (request pins as a subset of pins, withrequest_pinned_pagesmoving on the 0↔1 transitions) lives split across two functions that must agree, and every admission, ticket hand-off, boundary publication and retirement pays a second walk andVecallocation.pin/unpin(cache.rs:519-546) each own their entire invariant in one walk; the fix is a privatepin_with(id, request: bool)with thin wrappers. -
Commit 9cca87ac did remove the three inline branches, but replaced them with
pin_prefix/unpin_prefix(scheduler.rs:2025-2040), a bool-dispatched variant of the same forward that the file already expresses as a named pair,pin_checkpoint/unpin_checkpoint(scheduler.rs:2042-2050). The new wrapper is used only on the admission path (1645/1656/1678) while four request-pin sites still callcache.pin_request/unpin_requestdirectly (1889/1889, 2977-2979, 2997-2998, 3155), so the scheduler now has three ways to take a request pin whereas copy-out pins all go through one helper. Fix: one mechanism — fold accounting into the cache and delete the bool wrapper, or keep it with a two-variant enum and route all sites through it.
One nit: docs/api.md:311-312 now documents a #[cfg(test)] assertion to API readers, and docs/api.md:302-303 says "every scheduler pass" though the worker publishes only on passes that make progress (runtime.rs:1143-1153); AGENTS.md:52-60 governs where such notes belong.
Explicitly dropped after checking: the new AtomicU64 fields and their store/test rows follow the existing cached_pages pattern exactly; SchedulerStats::stats iterates slots the same way its neighbours do, with no existing helper duplicating it; the gauges' absence from the JSON field table is correct; and the drift assertion reuses the existing #[cfg(test)] mechanism. The earlier runtime-core-design.md documentation nit still stands but is not restated here.
#9 [high] Supersession map: which earlier notes still hold at head 9cca87ac
Read #7 first: it is the consolidated, current report for head 9cca87ac (8 files, +246/-16) and it lists exactly three findings plus the dropped candidates. Use #5 and #6 for the detail of findings 2 and 3.
Status of the older notes:
- #1 (Should fix:
pin_request/unpin_requestduplicatepin's chain walk) — STILL CURRENT, unchanged by 9cca87ac. Cite helios/src/cache.rs:551-563 and 565-580 against helios/src/cache.rs:519-534, 536-546, 258-275. Do not report the missingu64::MAXguard as a separate bug: it cannot fire whilerequest_pinsis a subset ofpins, so it is only the reason to merge the loops. - #2 (Should fix: three copies of the pin/pin_request branch) — STALE. Commit 9cca87ac removed the three inline branches (see its diff of helios/src/scheduler.rs:1640-1682). The live replacement finding is #5:
pin_prefix/unpin_prefixas a second, bool-dispatched wrapper pair besidepin_checkpoint/unpin_checkpoint, plus four sites that bypass it. Report finding #5, not #2, or the report will describe code that no longer exists. - #3 (Nit: no docs/runtime-core-design.md entry for the new gauges) — still technically true (docs/runtime-core-design.md:873 documents
flare_snapshot_backing_pages), but it was already reported in #4 and is deliberately not restated in #7. Mention only if the report wants a complete nit list; flag it as carried over. - #4 — the previous run's report (against 5ed7af8). Its findings 1 and 3 correspond to current #1 and #3; its finding 2 is superseded by #5; its api.md prose review points are superseded by #6 and by the rewritten docs/api.md:298-312.
Also current, from #7's "checked and dropped" list — worth keeping negative results visible: the new AtomicU64 fields follow the existing cached_pages pattern; SchedulerStats::stats slot iteration matches its neighbours; the gauges' absence from the docs/api.md JSON field table is correct; the #[cfg(test)] drift assertion reuses the existing mechanism rather than adding one.
#3 [low] Nit: new gauges get no runtime-core-design.md entry (api.md table row correctly omitted)
PR 549, docs/api.md:298-305 and helios/src/server/metrics.rs:1310-1318. Severity: nit.
Precedents for how a new scheduler page gauge is documented:
- docs/api.md:325-355 is the field table mapping every JSON field to its Prometheus name (cached_pages -> flare_cached_kv_pages at 345, free_pages at 346, total_pages at 347). The two new gauges deliberately have no JSON field (stated in the PR description), so absent table rows are consistent with the existing "beyond the JSON fields" sentence at docs/api.md:292-296 — not a finding.
- flare_snapshot_backing_pages has a design-document description at docs/runtime-core-design.md:873. The two new gauges have only the new api.md paragraph and the HELP strings at metrics.rs:1310-1318, so they have no runtime-core-design.md home.
Recommendation: add one sentence to docs/runtime-core-design.md near the snapshot_backing_pages text so the metric keeps the design-doc home the existing gauge has. Only worth doing if the semantics need a durable specification beyond the exposition help.
Prose facts verified against code: SchedulerStats::request_pages = live slots' private_pages.len() + cache.request_pinned_pages (scheduler.rs:1216-1222); request_pinned_pages adds a checkpoint's own tail_pages once when its request_pins rises from zero (cache.rs:551-563) and is checked against a full scan in stats (cache.rs:819-837). So "each page counted once even when several requests reference it" matches the implementation, and the api.md wording "idle cached prefixes ... are outside that share" is accurate — pinned shared pages are counted in both flare_request_kv_pages and flare_cached_kv_pages, which the text does not claim otherwise.
#6 [low] Nit: docs/api.md now cites a test-only assertion and calls the publish cadence "every scheduler pass"
Commit 9cca87ac rewrote docs/api.md:298-312.
Two departures in the added prose, both verifiable from the code:
- docs/api.md:311-312 "the test-only assertion in
Cache::statscompares the maintained request-pinned count with a full scan of every checkpoint on each read" — a user-facing API document now documents a#[cfg(test)]assertion (helios/src/cache.rs:816-837). AGENTS.md:52-60 says a repository document either specifies architecture or instructs agents, and that unrun checks and pending measurements belong in docs/TODO.txt rather than design documents; the drift assertion is none of these for an API reader, and the exposition HELP text (helios/src/server/metrics.rs:1310-1317) already carries the user-facing contract. Precedent: no other /metrics paragraph in docs/api.md names a test hook. - docs/api.md:302-303 "The worker publishes both on every scheduler pass" — the worker calls
self.metrics.scheduler(...)only whenprogressis true (helios/src/server/runtime.rs:1143-1153), so a pass without progress leaves the values stale. "The metrics are the last values published by the scheduler loop" states the actual guarantee.
Fix: drop the parenthetical about the test assertion (or move it to the PR description / docs/TODO.txt), and say "on each scheduler pass that makes progress".