Recommendation: Ready To Merge
Head 831c47c7 (rebased onto main c513e46a, including #665) cleanly resolves all three helios/ correctness blockers and the hot-path scheduler eviction defect from Round 4 and @lukealonso's review — fixing observe_prefill_rate, page_pressure_victim_priority (preserving #665 reuse protection, recency, and unpinned-overlap progress), RowRestoreLatency::observe's lower median, and zero-allocation freeable_prefix_scratch / Checkpoint::only_child tracking, each with targeted regression tests. Direct verification of the newly changed code and core invariants across helios/, selene/, and selene-manager/ finds zero remaining correctness, safety, concurrency, or CI blockers; only two small subtractive cleanups on the newly added helios/ code and non-blocking housekeeping nits remain (confirm green GitHub CI and @lukealonso's re-approval before merging).
Merge Risk
Level: Medium
- Large cross-crate cache-core surface (
+11,418 / -1,237across 42 files): Touches GPU VMM snapshot-alias planning (helios/src/runtime_core/cache_memory.rs), scheduler pressure eviction and prefill-delta pricing (helios/src/scheduler/), host offload/sharding/direct I/O (selene/), and manager arena retention and waiter scheduling (selene-manager/src/store.rs,arena.rs). Core invariants (only_child,clean_slots, prefix-sum cache invalidation, disk accounting,WindowReleaseSignalwakeups) are covered by debug assertions, unit/integration suites, and 8/8 TLA+ models with mutation checks (verification/helios-lifecycle/check.py:515-528). - Operator-visible wire, startup, and metric changes (all disclosed): Adds internal multi-host TP rank-relay event
Kind::StoreInvalidated = 4(requiring matching rank builds), fails startup cleanly on sub-page memory-only budgets (selene/src/offload.rs:706-712), separates committed vs reserved disk gauges (docs/api.md:390-394), dropsflare_host_cache_intake_slotsto0without local disk, and updates publicflare-seleneAPIs in lockstep with workspace callers. - Downstream & concurrent PR coupling: PR
#694is already stacked directly on831c47c7consuming this PR's public surface, while open PRs#655and#659touch overlappinghelios/files (checkpoints.rs,runtime_core/cache_memory.rs) and will need coordinated merge sequencing.
Walkthrough
- Resident-aware lookup, diskless intake sizing & telemetry (
helios/src/server/runtime.rs:3161-3246, 3312-3459,helios/src/server/metrics.rs:538-564, 914-950,selene/src/offload.rs:175-254, 675-712,docs/api.md:387-398): Forwards GPU-resident token offsets on pool lookups, refreshes queued full-GPU-hit plans if evicted before dispatch (runtime.rs:3185-3208), falls back to local copies at the same endpoint when a pooled row-only candidate is rejected (runtime.rs:3383-3413), sizes local intake slots to0when local disk is disabled, splits ready disk inventory from uncommitted reservations, and exports per-level pool restore rates. - L1 DRAM clean retention & non-blocking drain (
selene/src/memory.rs:3517-3527,selene/src/pool/store.rs:289-321,selene/src/pool/local.rs:83-90): Retains cleanpersisted_in_poolrecords in L1 DRAM with invariant-checkedclean_slotsaccounting and narrows shutdown drain topending_pool_drain(). - GPU snapshot-alias packing, pressure eviction & restore pricing (
helios/src/runtime_core/cache_memory.rs:655-830, 1633-1686,helios/src/scheduler/cache_memory.rs:205-269, 397-553, 662-668, 713-820,helios/src/scheduler.rs:744, 1282-1293, 1375-1386, 2136-2241,helios/src/cache.rs:80, 306-319, 554-560, 662-677, 699-720, 848-850, 1040-1054,helios/src/scheduler/checkpoints.rs:280-314, 403-409, 453-502,helios/src/server/runtime.rs:262-335, 3054-3077,docs/runtime-core-design.md:846-888): Packs exact half-width alias planes with midpoint ordering and non-power-of-two/per-rank handle-budget fallback; replaces per-victim eviction clones/maps/scans withfreeable_prefix_scratchprefix sums andCheckpoint::only_childwhile preserving#665reuse protection and recency; prices restores via read-onlyestimate_prefill_delta_ns(including intermediate conditioned-window terminal chunks), lower-medianRowRestoreLatency, and a fixedstep.token_capacityfallbackobserve_prefill_rateEMA. - Direct compressed I/O, event-driven waiters, clean arena retention & offer coalescing (
selene/src/disk.rs:848-875, 1272-1425,selene/src/disk_store.rs:346-415,selene-manager/src/arena.rs:163-200,selene-manager/src/store.rs:1406-1738, 2237-2272, 5049-5072, 5758-5762): Writes whole compressed v4 records via alignedO_DIRECTI/O with exactset_lentruncation andStoreInvalidatedpropagation, replaces timer-polled put waits with losslessWindowReleaseSignalwakeups and rotating epoch-tracked scans, retains clean manager RAM extents via buddycoalescing_block, and resolves covered waiting offers directly toPresent.
Pre-merge Checks
- [PASS] Security / malicious screen: No credential leaks, external exfiltration, unsafe memory bypasses, or prompt-injection vectors in PR code (
unsaferaw_sliceuses inselene/src/disk.rs:1277, 1321, 1404are bounded by caller-pinned buffer/slab lifetimes; the external "Full Review" links in earlier comments are standard Autobot review-template footers, not PR code). - [WARN] Charter & value fit: Strongly aligned with the prefix-caching charter goal, model-agnostic, resolves
#451, and discloses all wire/startup/API/baseline caveats; however, headline SM120 A/B Tables A–C remain measured on pre-refactor7d7dcdcbvs5d53040e(predating#665,#663, and#660), transparently noted in the PR description (charter#210). - [WARN] Related / duplicate / conflict check: Open issue
#451still lacks a closing comment summarizing the midpoint half-width conflict-span design (docs/runtime-core-design.md:846-858);#694is stacked on831c47c7, and#655/#659touch overlappinghelios/files. - [PASS] Tests & verification evidence: Regression tests in
helios/src/server/runtime/phase_tests.rs:9073-9350,helios/src/runtime_core/cache_memory.rs:1633-1686,helios/src/scheduler/cache_memory.rs, andhelios/src/cache.rs:1040-1054cover all Round 4 /@lukealonsofixes with clean isolation and production paths; author reports clean-D warningscheck,1,838helios release lib,585selene,205 + 128selene-manager,254flare tests, andverification/helios-lifecycle/check.py --mutations(8/8 TLA+ models + Rust mutations) passing on831c47c7(confirm green GitHub CI on831c47c7before merge).
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Delete the dead
backing_pressureparameter and#[cfg(test)]-onlyevict_for_pressurewrapper (helios/src/scheduler/cache_memory.rs:713-740,helios/src/scheduler.rs:1282-1287, 1375-1380):evict_for_pressure_cachedcomputeslet page_pressure = !self.snapshot_pages.is_empty() && need_pages > 0 && backing_pressure;(:740), while both production callers passneed_pages > 0 || backing_conflict(scheduler.rs:1285) ortrue(scheduler.rs:1378). Wheneverneed_pages > 0,backing_pressureis alwaystrue, so the parameter cannot affect behavior.- Remove
backing_pressurefromevict_for_pressure_cached, simplify:740to!self.snapshot_pages.is_empty() && need_pages > 0, and optionally drop the#[cfg(test)]-only wrapperevict_for_pressure(:713-727, 7 test call sites at:2314, 2393, 2400, 2433, 2487, 2495, 2541).
- Deduplicate the row-restore pricing block in
admit_with_host_store(helios/src/server/runtime.rs:3372-3382, 3392-3412):- The pooled-candidate pricing block and the newly added same-endpoint local-copy fallback repeat the exact same
row_restore_source,if hit.pages == 0 { ... } else { ... },metrics.host_lookup_cost(...), andflare_selene::worth_restore(...)sequence. Extracting a small local helper (e.g.,price_restore) removes ~12 duplicated lines and prevents pooled vs local row-restore pricing from drifting.
- The pooled-candidate pricing block and the newly added same-endpoint local-copy fallback repeat the exact same
Nits
- Update the stale "Scope Summary" diffstat in the PR description: The PR body still quotes
+10,106 / -1,158across 42 files while the Verification section cites831c47c7; the actual diffstat at831c47c7is+11,418 / -1,237across 42 files. - Post wrap-up on
#451: Add a short comment on open issue#451recording the midpoint-ordered half-width alias packing resolution (docs/runtime-core-design.md:846-858). - Optional follow-up on
selene-managerwaiter scans (selene-manager/src/store.rs:1561-1566, 1610-1666):scan_writeback_waiters_stepcachesclean_arena_victims()inspanswithin each 32-waiter step, which is fast for typical RAM record counts and only runs whencan_allocatefails; if large multi-thousand-record namespaces ever hit sustained waiter storms, hoisting/caching the clean-victim span vector across a singlewriteback_wake_epochwould avoid repeating the tree walk across multi-step sweeps. - Optional A/B refresh post-
#665: Re-running Tables A–C againstc513e46a(which includes#665on the same DeepSeek-V4.1-Flash TP4 rig) would close the remaining evidence delta under charter#210if hardware time is available.
Dropped on verification
- Correctness M1 (claimed severe head-of-line blocking from
clean_arena_victims()under--memory 256M) — Overstated & downgraded to Nit: Verified inselene-manager/src/store.rs:1531-1666thatspansis already cached across all 32 waiters in a step and skipped wheneverself.memory.can_allocate(bytes)succeeds; under tight--memory 256M, only a handful of clean records reside in RAM (and Table F ran 62/62 HTTP 200 at 806.6 MB/s under 16-way storm). Also rejected the proposed "reserve coalescible block beforequeue_put" fix as speculative and risky under cancellation/requeue paths. - Correctness M2 (
Metrics::host_lookup_costdouble-counting on local fallback athelios/src/server/runtime.rs:3379, 3400) — Misread metric contract:host_lookup_cost(helios/src/server/metrics.rs:538-564) has always recorded one paired 3-tuple(missing_tokens, transfer_ns, prefill_ns)perworth_restorecandidate evaluation (already called once perbeforeloop iteration, distinct from per-requestscheduler.record_host_lookup()at:3420, :3446, :3451). Evaluating a local copy after rejecting a slow pooled row-only source tests a distincttransfer_seconds; omitting either call would hide the rejected transfer estimate or desynchronize_countacross the three paired histograms. - Correctness M3 (
WritePackedstaging throughself.scratch+write_record_bufferedfor unaligned partial windows atselene/src/disk.rs:848-868, 1311-1425) — Misread design / overstated: Compressed packed v4 records combine variable-length metadata and non-block-aligned packet slices that must be repacked forO_DIRECTregardless; staging through the pre-allocated 1 MiBself.scratch(disk.rs:168, 398) avoids 200+ MiB transient bounce-buffer allocations while sustaining 1.0–2.4 GB/s NVMe throughput.write_record_bufferedapplies only to partial unalignedWriteRecordstreaming windows (disk.rs:864-868), matching the PR body's "aligned whole-recordO_DIRECTI/O (WriteRecord,WritePacked)" statement. - Correctness m1 (
write_direct_slicesassumes offset 0 atselene/src/disk.rs:1335) — Low-signal / already documented: Documented explicitly atdisk.rs:1327-1330, and both callers guarantee offset 0 (write_record_directreturns early forspan.aligned()at:1273-1275, so:1306is reachable only whenwhole_recordholds withspan.offset == 0;write_packedalways writes a fresh file at:1415). - Correctness m2 (
transfer_in_uselinear scan of waiter deques atselene-manager/src/store.rs:1363-1368) — Low-signal untouched code: Queues are capped at 1024 (store.rs:39-40), scanning contiguousu64pairs is sub-microsecond, and this code is unchanged from Round 3. - Correctness m3 (
TierStore::pending_pool_draintrait default atselene/src/store.rs:401-404) — Misread dispatch & wrong citation: Upstream mis-citedselene/src/memory.rs:2776(held_slots) instead ofpending_pool_drainat:3517-3527.PooledStore::drain_memory(selene/src/pool/store.rs:294) only reachespending_pool_drainwhenbegin_pool_drain()returnsSome(...), and everyTierStoreimplementingbegin_pool_drain(MemoryStore,Tiers,FakeLocal) also overridespending_pool_drain. - Subtraction Finding 3 (
target_intake_slots/sized_concurrencyinselene/src/offload.rs:244-254, 675-680) & Finding 4 (expire_waitersoninflight_waitersinselene-manager/src/store.rs:1670-1700) — Low-signal untouched code / worse abstraction:offload.rsis untouched since Round 3 andtarget_intake_slotscleanly documents integrated-memory sizing for bothheadroom_inner(:183) andprepare(:677).expire_waiterspartitionsinflight_waitersinto four outcomes (dropped closed sessions, expired, wake, remaining), so forcing it through a two-wayfilter_inflight_waitershelper would duplicate predicates and introduce the same polarity trap noted onfilter_writeback_waiters. - Discovery A5 residuals (
evictable_snapshotsdouble pass atcache_memory.rs:751, 777;simulate_snapshot_quoteonce-per-quote clones at:411-412; debug-onlysingle_childscan atcache.rs:306-318) — Low-signal: Bounded to one prefix rebuild / pre-existing quote simulation / debug-onlydebug_assert_eq!.