#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.