#1 [high] Research summary
Lens B (architecture & scope). I read the charter, AGENTS.md (contribution scope/rejection criteria, required PR descriptions, validation), docs/design-review.md principles, docs/verification.md, docs/prefix-cache-offload.md (esp. §2.4, §2.5, §4, §5) and the changed code in selene/src/disk_store.rs in context (Staged, Resources, Owner, HostInbound, SharedSegment/SharedWindow, pump_device_inbound passes 1–5e, DiskStore::apply/fetch, Rate, plus composite.rs callers), and PR #497 as the stacked companion.
Verdict: the change sits in the right layer (Selene's disk transport; no CUDA, no model knowledge, no new flags/env switches, no per-model branching, no core/format change, and no re-export needed — behaviour derives from record path + header identity, which matches AGENTS.md "keep native specialization focused on cache storage contracts" and principle 3). It has served-workload evidence of the kind the charter demands for a performance PR ("benchmarks showing an actual speedup over main on a served workload"). But it adds a second, shared, reference-counted I/O lifecycle inside shared cache machinery (+2803/−913 in an already 8.8k-line file) and it silently changes what the store's own bandwidth metric means, which is used for restore-cost estimates.
Findings:
-
should fix (high) — metering semantics changed: selene/src/disk_store.rs:1530/1829/3626-3628.
SharedWindow::read_bytesaccumulates the physical reply bytes once per window, and each follower adds the whole window'sread_bytesto its ownrecord.bytes(line 1829), which becomesstats.bytes_inand is fed toinbound_rate.observe(bytes, job.started.elapsed()). Before this PR each restore read its own windows, so bytes_in and the observed rate were both physical. Now bytes_in stays logical (bytes delivered to GPU) while physical reads drop up to 4.2×, so the observed inbound rate is inflated toward the coalescing factor. That rate is the basis ofDiskStore::hit().estimated_seconds(line 3587) and of/metrics host_cache_inbound_bytes_per_second(helios/server/metrics.rs:1310 (not opened)) — the very number §4 of docs/prefix-cache-offload.md uses for "Inbound latency"/"Copy-out bandwidth" gating and that the PR's own table quotes. Effect: restore estimates used by tier choice/scheduling become optimistic (up to ~4× low) under concurrency, and qualification-measured disk bandwidth no longer means device bandwidth. Fix: feed the rate from physical window bytes (count a window's bytes once, e.g. at segment/window completion rather than per follower) while keepingbytes_inas the logical restored-bytes counter, and state the distinction in §2.5/§4. This is checkable from the code alone; a test assertingbytes_in == physical bytes / coalescingand rate stability across concurrency would settle it. -
should fix — scope/complexity needs maintainer sign-off, and the module contract is now self-contradictory. disk_store.rs:8-24 still promises "at most WINDOWS_IN_FLIGHT windows of one record staged at a time" and "Nothing here waits", while the file now hosts five new lifecycle types (HostInbound, SharedSegment with 5-state file machine, SharedWindow with two reference counts, DeviceActiveWindow/PlanState) with out-of-order plan completion, linear demand indexing, and a close-only-when-settled rule (lines 2205-2255). AGENTS.md "Reject unsupported abstractions and churn" and design-review principle 1/6 ask for the smallest footprint in shared code and explicit lifetimes; this is a substantial new ownership protocol in shared cache policy rather than a small fix. Recommendation: keep the technical content but require an explicit maintainer decision on the design (and on whether coalescing belongs in
Stagedversus inside the disk thread, which already owns the file handle), and rewrite the module/Stageddoc comments so they describe the two-window-credit, follower-shared staging model rather than the old per-record window rule. As written, a future reader of the header comment will misread the invariants ofpump_device_inbound. -
should fix — docs/prefix-cache-offload.md:337-342 asserts coalescing unconditionally and the same edited paragraph keeps signatures that do not exist. The text says concurrent fetches "share one open file handle and coalesce aligned 64-page windows while staged", omitting the two material caveats the PR itself discloses: windows already released are read again by later arrivals (so coalescing is best-effort and timing-dependent), and device restores now split up to one extra partial window when
skip_pages % 64 != 0. Per AGENTS.md ("State support as present qualification… unresolved defects, unrun checks and pending measurements"), §2.4 should state those limits. Also, the paragraph this PR edited still claimswrite_from(key, metadata, buffers)andread_into(key, buffers); the real signatures arewrite_from(id, header, temporary, path, pages, row, sums)(line 1242) andread_into(id, path, header, first_page, pages, row)(line 1268). Fix both while the sentence is being touched. -
nit — evidence staleness: the PR's own "Not covered" note says the SM121 single-pass runs predate the linear demand-index and close-count edits, and that the numbers come from a revision before those changes. Those edits alter exactly the scheduling path that produced the measured windows, and AGENTS.md requires the claimed result to be tied to the code under review. Re-run at least one TP1 simultaneous and one staggered configuration at the head commit before merge, or restate the table's scope explicitly as measuring an earlier revision.
-
nit — the coalescing counters exist only under
test-support(lines 192-200 withallow(dead_code), accessors at 1213-1236), so nothing in a production or qualification run can show whether coalescing happened; combined with finding 1 the mechanism is unverifiable outside unit tests, while §4 of the offload doc gates defaults on store counters. Consider exposing opens/reads/coalesced windows throughStoreStats(no per-model or flag implications) instead of test-only accessors.
Nothing found for the per-model-flags, environment-variable, format-compatibility or silent-field-drop criteria: the change introduces none of those, and the failure-isolation rules (private child/upload failures fail only their restore; shared open/read failures fail all attached restores after drain, keeping the record_read invalidation path at lines 3630-3641) preserve the existing "don't swallow the error" rule.
#2 [high] PR #496 lens B: bytes_in / inbound_rate inflation by coalescing
Finding 1 (should fix, high) — selene/src/disk_store.rs (PR #496 head f9c9191).
- SharedWindow.read_bytes is accumulated once per physical reply (apply_shared_disk, line ~1530:
win.read_bytes += reply.bytes, set at line 1979 initialised 0). - Each follower adds the whole window's read_bytes to its own record.bytes in pump_device_inbound Pass 1 (line 1829:
record.bytes += win.read_bytes;) — so N followers each count the full window. - record.bytes becomes the Ok payload of TransportEvent::Fetched (line 2235 / 2251), hence
DiskStore::apply->stats.bytes_in += bytesandself.inbound_rate.observe(*bytes, job.started.elapsed())(lines 3624-3628). inbound_ratefeedsDiskStore::hit().estimated_seconds(line 3587) and /metricshost_cache_inbound_bytes_per_second(helios/src/server/metrics.rs:1310); docs/prefix-cache-offload.md §4 uses that for "Inbound latency"/"Copy-out bandwidth" gating and §2.11 defaults.- Before the PR each restore read its own windows, so bytes_in and rate were both physical. Now bytes_in stays logical while physical reads drop up to 4.21x (PR table) => observed device rate inflated toward the coalescing factor; restore-cost estimates become optimistic (up to ~4x low) under concurrent restores.
- Fix: observe the rate from physical window bytes (count once per window/segment completion), keep bytes_in as logical restored bytes, and document the distinction in §2.5/§4. Test that settles it: bytes_in == physical/coalescing and rate stable across concurrency.
- Note: rate.observe also gets each follower's full window bytes -> rate sample = logical_bytes/elapsed; elapsed per record starts at DiskStore::fetch (line 3813
started: Instant::now()), andinbound_rate.started()at 3806.
#4 [high] Report run 2 (head 0c04b1e2) — Lens B verdict: previous should-fixes resolved; 2 remaining notes
PR #496 lens B (architecture & scope), head 0c04b1e2
Previously reported, now resolved at 0c04b1e2
- inbound_rate no longer fed from logical bytes:
DiskStore::applyshort-circuitsTransportEvent::InboundWindowSampleintoself.inbound_rate.observe(bytes, elapsed)(selene/src/disk_store.rs:3632-3635) and the oldself.inbound_rate.observe(*bytes, job.started.elapsed())inside theFetchedarm is gone (job fieldstartedremoved, :3851-3856).stats.bytes_in += bytesstays logical (:3669). Docs state the split: docs/prefix-cache-offload.md:362-366 and :1529-1532. - Module contract rewritten: selene/src/disk_store.rs:7-27 now describes per-fetch window credits, shared handles/follower windows, and "Submissions never block the caller … last user of a shared segment holds its Fetched event until the file close settles". Old "at most WINDOWS_IN_FLIGHT windows of one record" / "Nothing here waits" text gone.
- Docs §2.4 now carries the two limits (windows released before a later attach are re-read;
skip_pages % WINDOW_PAGES != 0adds ≤1 partial window per segment) and the real signatureswrite_from(id, header, temporary, path, pages, row, sums)(:1308) /read_into(id, path, expected, first_page, pages, row)(:1334); docs:337-366. Resources::allocaterustdoc restored aboveallocate(disk_store.rs:241-243) withfree_slotsdoc at :236.- WindowKey/HeaderIdentity/SegmentKey single definition (:1001-1064),
window_indexO(1) lookup,has_window_credit/attach_pendingextracted, demand tableHashMap<WindowKey, usize>;build_pending_demandshort-circuit fordevice_inbound.len() <= 1(:1760 área). - Test-only coalescing counters gated with
#[cfg(any(test, feature = "test-support"))](:200-208, accessors :1279-1295).
Remaining findings
Should fix (layering) — a store-local statistic now rides the transport event channel and forces an unreachable!() in the sharded protocol mapper
TransportEvent::InboundWindowSample { bytes, elapsed }is a variant of the enum that is the cross-rank wire event set (selene/src/disk_store.rs:97-101).Kind::ofmust therefore panic on it: selene/src/shard.rs:476-478TransportEvent::InboundWindowSample { .. } => unreachable!("window rate samples stay local to rank zero"). That invariant is maintained only by hand at the two call sites that would otherwise see it:Sharded::absorb_localforwards the sample intoself.events(shard.rs:722-725) andPeer::forwarddrops it (shard.rs:1148-1150). Any other consumer that mapsKind::ofover aSharded's events panics — including the existing test helper at selene/src/shard/tests.rs:338-339 (events.sort_by_key(|event| Kind::of(event).1)), which today only survives because those tests issue no fetch.- Why it matters (charter "solve the right problem in the right place"; AGENTS.md:188-193 "reject unsupported abstractions"; the enum's doc comment at disk_store.rs:83 is "Completion the transport reports to the disk store", and every other variant is a job completion with an id): a metering sample with no job id is not a transport completion, and putting it here makes the wire-protocol mapper responsible for a local statistic.
- Fix without new machinery: keep the sample inside
Staged(e.g. accumulatewindow_bytes/window_elapsedand drain it via aStagedmethod the wayin_flight()andpool()are read fromDiskStore::stats/poll), or fold the physical counters intoStoreStats(selene/src/store.rs:227-244) instead of adding an event variant. A test asserting shard event mapping is total overTransportEventwould settle the panic path.
Nit — estimated_seconds now prices restores at pure disk-thread bandwidth, excluding staging and GPU upload
- The sample's
elapsedisdisk::Reply.elapsed, set indisk::runaroundworker.execute(job)only (selene/src/disk.rs:447-454), i.e. one direct-I/O read plusxxh3, with no wait for a free slot, no copier queue time, and no GPU upload. - Before this commit the rate was observed as record bytes over
job.started.elapsed()fromDiskStore::fetchtoFetched(removedstarted: Instant::now()inInbound, see diff at disk_store.rs Fetched arm), which spanned queueing and the upload. hit()divides by it: selene/src/disk_store.rs:3615-3627estimated_seconds: bytes / self.inbound_rate.get(), consumed byworth_fetching/worth_transfer(selene/src/store.rs:422-438), byruntime.rs:2796restore deferral, and by /metricshost_cache_inbound_rate(helios/src/server/metrics.rs:640,1312). CompositeStore prices the disk part on its owndisk_inbound_rateobserved fromread_intocompletions (selene/src/composite.rs:994-1004), so the two stores now measure different things.- Effect: restore estimates are optimistic by the staging/upload share even for a single restore — the opposite direction from the inflation this commit fixed. Only a run can quantify the factor; a test comparing
estimated_secondsagainst a measured single-restore wall time would settle it. Fix: either documentinbound_rateas device read bandwidth and keep a separate end-to-end restore estimate, or include the per-record wait in the sample.
Held (scope/process, unchanged)
- The design call — a second reference-counted inbound lifecycle inside
Staged, with shared inserted neither inDiskThreadnor rejected in the description — is now argued in the PR Why (DiskThread sees only offsets/raw addresses; slots must stay pinned until followers' uploads finish), which satisfies design-review.md:64-68 in substance; the remaining ask is only that a maintainer record the decision (AGENTS.md:204-206) rather than that the code change shape. - Benchmark table now at 0c04b1e2 per the description (main c0c4f798 vs 0c04b1e2), so the earlier "numbers predate head" nit is addressed; un-rerun items are listed under "Not covered".
Verified sound in this pass
- No record/header format change;
HeaderIdentitymirrorsHeader'sPartialEqfield list exactly (compare selene/src/shared/record.rs:136-152 with disk_store.rs:1014-1050), so the sharing key cannot collide two headers that compare unequal. - No per-model branch, flag, env switch or recipe field; sharing derives from
(path, expected header)(disk_store.rs:1425-1462). - Failure isolation preserved: private child/upload failure
record.failonly its record (:1538-1553, :1652-1660), shared open/read failure converts withwith_record_read()and fails all attached users (:1509-1536, :1620-1638);DiskStore::applystill routesrecord_readfailures toindex.drop_row(:3676-3682). InboundWindowSampleis handled by both stores that drive a transport:DiskStore::apply(:3632) andCompositeStoreviastreamed_event → disk.apply(composite.rs:1384).Shardednever sends the sample to peers (shard.rs:1148), so the wire protocol andKindcodes are unchanged — no compatibility break with mixed-version ranks beyond the pre-existing protocol.
#5 [high] Research summary
Reviewed PR #496 at head 0c04b1e2 through the architecture-and-scope lens against the charter, AGENTS.md contribution/rejection criteria, docs/design-review.md (not opened) and docs/prefix-cache-offload.md, reading every changed function in context plus its callers (shard.rs, composite.rs, disk.rs, levels.rs, store.rs, record.rs, helios metrics/runtime).
Of the four should-fixes I raised on the previous revision, three are now genuinely fixed in code and docs: the inbound rate is fed from physical window bytes instead of logical per-record bytes (disk_store.rs:3632-3635), the module contract describes the new per-fetch window-credit/follower-sharing/settle-before-Fetched model (disk_store.rs:7-27), and §2.4 now carries the two coalescing limits plus the real write_from/read_into signatures (docs:337-366). The design call for a second inbound lifecycle inside Staged is now argued in the PR's Why section, leaving only a maintainer sign-off to record.
What remains: a should-fix layering issue — the new TransportEvent::InboundWindowSample variant puts a store-local metering sample into the enum that is also the cross-rank wire event set, forcing an unreachable!() in Kind::of (shard.rs:476-478) whose invariant is upheld only by hand at two call sites and which the shard test helper at shard/tests.rs:338-339 would already trip; and a nit that inbound_rate now measures pure disk-thread time (disk::Reply.elapsed, disk.rs:447-454), excluding staging and GPU upload, so hit().estimated_seconds and worth_transfer price restores optimistically even for a single restore. No format, flag, per-model or wire-protocol break was found.
#6 [high] Report run 2 — finding titles/serities for the final report + rule citations used
Companion to entry #4 (which holds the evidence). This note holds the titles and rule citations the final report needs.
Verdict
No blocking findings. 1 should fix (layering), 1 nit, plus 1 held process note (maintainer sign-off for the design decision).
Finding titles
- Should fix: a store-local metering sample is carried on the transport event channel and forces
unreachable!()in the sharded protocol mapper — selene/src/disk_store.rs:97-101 (InboundWindowSample), selene/src/shard.rs:476-478, hand-maintained at shard.rs:722-725 and shard.rs:1148-1150; would trip the existing helper at selene/src/shard/tests.rs:338-339. Fix: keep the sample inStagedbehind a method (likein_flight()/pool()), or fold the physical counters intoStoreStats(selene/src/store.rs:227-244). - Nit:
inbound_ratenow measures pure disk-thread time, soestimated_secondsprices restores optimistically — disk.rs:447-454 setselapsedaroundworker.executeonly; consumed at disk_store.rs:3615-3627 (hit), store.rs:422-438 (worth_fetching/worth_transfer), heros runtime.rs:2796, heros metrics.rs:640/1312; CompositeStore instead measuresread_intocompletion spans (composite.rs:994-1004), so the two disagree. - Held (process): maintainer sign-off for putting a second reference-counted inbound lifecycle in
Stagedvs inDiskThread; the PR's Why section now argues the layer choice, so this is a record-the-decision ask, not a code-shape ask.
Rule citations used for the layering judgement
- docs/design-review.md:64-68 — design decisions of this shape need explicit maintainer sign-off (carried over from the earlier pass; not re-read this pass, treat as inherited).
- AGENTS.md:188-193 — "Reject unsupported abstractions and churn… Refactoring must directly support the requested behavior"; AGENTS.md:176-181 — architectural violations / no optional paths to bypass boundaries.
- AGENTS.md:204-206 — resolve conflicts through an explicit maintainer decision before changing an invariant.
- AGENTS.md:194-199 — describe problem, resulting behavior, validation, and material limitations (satisfied by §2.4 and the "Not covered" list).
- Charter "Solve the right problem in the right place" (charter line 9) and "Performance PRs need benchmarks showing an actual speedup over main on a served workload" (charter line ~14).
What is settled (do not re-litigate)
- Head 0c04b1e2, 3 files, +3358/−933; no checks on CI at head.
- Files read in context this pass: disk_store.rs (module doc, Resources, Owner, TransportEvent, plan_windows, HostInbound, SharedSegment/SharedWindow, pump_device_inbound passes 1–5e, DiskStore::apply/hit/stats/fetch/poll, write_from/read_into, tests incl. the new coalescing suite), shard.rs (Kind, Sharded::absorb_local, Peer::forward/dispatch, DiskTransport impl), composite.rs (streamed_event, hit, poll, start_read, disk_read), disk.rs (run/Reply.elapsed), levels.rs (Rate), store.rs (StoreStats, worth_fetching), shared/record.rs (Header PartialEq), docs/prefix-cache-offload.md:320-367 and 1525-1532, helios offload/gpu_tests + metrics references.