Recommendation: Changes Requested
The core write-side profitability gate, top-down pool coverage, O(1) clean_slots accounting, dram_only warm L1 retention/reclamation, compaction-lineage canonicalization, and cascade anchor retention are technically sound — no core correctness, safety, or concurrency blockers were found after direct verification at head d74e810. Changes are requested before merge because (1) this PR is stacked on unmerged #674 and its headline A/B numbers were measured on an earlier combined dev commit (09400ad8) where two of three models had zero gated spills (conflating #674's byte reduction with this gate) and without reporting the mandatory verification/helios-lifecycle/check.py gate, and (2) the new user-visible Prometheus metrics, StoreOutcome::Unprofitable contract, and prefill_saved_ns == 0 fail-open / cold-restart recovery semantics are missing from docs/api.md and docs/prefix-cache-offload.md.
Merge Risk
Level: Medium
- Modifies core prefix-cache spill, eviction, cascade, and publication paths across
selene(store.rs,composite.rs,disk_store.rs,memory.rs,shared/index.rs,pool/{cascade,local,store}.rs) andhelios(scheduler.rs,scheduler/sharing.rs,server/runtime.rs,server/metrics.rs), with high test coverage and debug invariant checks (assert_clean_slots_invariant, batch-removal atomicity, end-to-end composite/cascade unit tests). - Zero Protobuf, Ignition, model-core, CUDA graph contract, or on-disk v4 format changes;
prefill_saved_ns == 0fails open to unconditional spilling, bounding blast radius for unpriced paths and disk-recovered caches. - Stacked on #674 (the combined diff against
maincarries ~2.9k lines ofselene-manager/srcand sharedheliosedits from #674), so rebasing ontomainafter #674 lands and re-running verification at the final commit is required before merge.
Walkthrough
- Pricing & trait surface (
selene/src/store.rs:261-293, 396-399, 454-467, 496-550): AddsPublishedCheckpoint::prefill_saved_ns,StoreOutcome::Unprofitable,StoreStats::spill_skipped_unprofitable[_bytes]: [u64; 2],PoolSpillPolicywith 5% hysteresis (materially_differs_from),HostStore::compacted,TierStore::{set_pool_spill_policy, spill_eligible_pool, persisted_in_pool, record_is_packed}, and pure predicatesstandalone_spill_profitable(reusingworth_restore, fail-open whenprefill_saved_ns == 0) andfork_dedup_profitable. - Local NVMe gate, warm L1 retention & fork promotion (
selene/src/composite.rs:447-907, 984-1036, 1856-1966, 2115-2144, 2299-2313,selene/src/disk_store.rs:2186-2264, 2612-2669, 3482-3664,selene/src/shared/index.rs:521-575): Unprofitable checkpoints stay in L1 DRAM (dram_only) with uncharged disk-index metadata entries, are excluded from disk parent selection so durable children never depend on them, reclaim blocking shadows in batch viaIndex::remove_nodesunder disk pressure, and promote to durable NVMe oncefork_dedup_profitabletriggers across distinct canonicalized descendant branches. - Pool coverage,
O(1)clean_slots& cascade safety (selene/src/memory.rs:341-444, 769-856, 961-1056, 1137-1194, 1243-1528, 1612-1710, 1754-1878, 3694-3705,selene/src/pool/cascade.rs:131-200, 286-381, 434-558,selene/src/pool/local.rs:35-39, 131-150,selene/src/pool/store.rs:199-258, 603-610): Maintains cached top-downPoolCoverage { eligible, covered_pages, has_row_ancestor }andreclaimable_clean_slotsinMemoryStore(with matching top-down evaluation inDiskStore), forwardsTierStorepolicy/status hooks throughTiers, skips unprofitable interior checkpoints on homogeneous cascades, and preserves chain-starting ancestors for profitable rowless records and raw/packed representation boundaries. - Helios prefill pricing, compaction lineage & metrics (
helios/src/server/runtime.rs:2917-2975,helios/src/scheduler.rs:683, 1996,helios/src/scheduler/sharing.rs:12, 46-156,helios/src/server/metrics.rs:529-539, 632-637, 872-885, 922-933): Publishesprefill_saved_nsfromestimate_prefill_delta_ns(c, 0, c, ...)with cold EMA fallback, forwards boundedcompacted_ancestorsviaHostStore::compacted, handlesStoreOutcome::Unprofitableby unpinning without deferral, and exportsflare_host_cache_spill_skipped_unprofitable[_bytes]_total{tier="nvme"|"pool"}plusreason="unprofitable"onflare_host_cache_store_reasons_total.
Pre-merge Checks
- [PASS] Security / malicious screen: No suspicious patterns, secret exposure, or prompt-injection directives found in code or PR text.
- [WARN] Charter & value fit: Model-agnostic, flag-free, and squarely aligned with the Selene host-cache goal, but the A/B evidence is from an older combined commit (
09400ad8) where 2 of 3 models show 0 gated spills and new metric/outcome docs are missing. - [WARN] Related / duplicate / conflict check: Additive with no competing proposal, but stacked on unmerged #674 (must rebase onto
mainafter #674 lands; shareshelios/src/cache.rs,runtime_core/cache_memory.rs(not opened), anddocs/prefix-cache-offload.mdwith #674's merge-order dependencies). - [WARN] Tests & verification evidence: Strong unit-test coverage with real
MemoryStore/DiskStore/CompositeStore/Cascadefixtures and debug invariant checks, butpython3 verification/helios-lifecycle/check.py(mandatory underdocs/design-review.md:209-251for changes tohelios/src/scheduler.rs,scheduler/sharing.rs, andserver/runtime.rs) and head-commit A/B numbers are not reported.
Blockers
None.
Should Fix
-
Rebase after #674 and refresh head-commit verification and A/B evidence (
PR description,docs/design-review.md:106-115, 209-251):- The served SM120 A/B table was measured on combined dev commit
09400ad8rather than headd74e810, and two of the three rows (GLM-5.3-FlashTP2 andDeepSeek-V4.1-FlashTP4) report0skipped spills while showing NVMe byte reductions (5.10 → 3.79 GBon GLM-5.3) attributable to #674 rather than this gate. Once rebased ontomainafter #674, rerun the A/B against post-#674mainat head (explicitly distinguishing any row where the gate does not fire from the gate's own savings) and label the production fleet table as an offline header replay directly alongside its headline figures. - Because the top commit modifies
helios/src/scheduler.rs,helios/src/scheduler/sharing.rs(eviction/compaction tracking), andhelios/src/server/runtime.rs(publication/pin lifecycle), runpython3 verification/helios-lifecycle/check.pyon head and include the result in the PR's Verification section perdocs/design-review.md:211-215, 234-251.
- The served SM120 A/B table was measured on combined dev commit
-
Document the new Prometheus metrics,
StoreOutcome::Unprofitable, and fail-open recovery semantics (docs/api.md:340-398,docs/prefix-cache-offload.md:685-696, 1454-1465):helios/src/server/metrics.rs:872-885, 922-933addsflare_host_cache_spill_skipped_unprofitable_total{tier},flare_host_cache_spill_skipped_unprofitable_bytes_total{tier}, andflare_host_cache_store_reasons_total{reason="unprofitable"}, none of which appear indocs/api.md:340-398(which documents every otherflare_host_cache_*family). Add them todocs/api.md, clarifying that..._bytes_totalcounts skipped write bytes (packed stored bytes when compressed in L1 DRAM perselene/src/composite.rs:1023-1029, otherwise uncompressed tail+row bytes perdisk_store.rs:3621-3622andmemory.rs:848-850).docs/prefix-cache-offload.md:1462-1465lists onlyPresent,Oversize, andRetryunder Publication outcomes; addUnprofitable(selene/src/store.rs:275) with its terminal unpin-without-deferral semantics (helios/src/server/runtime.rs:2940-2966).- Explicitly document in
docs/prefix-cache-offload.md:685-696(and the PR description) thatprefill_saved_ns == 0intentionally fails open (selene/src/store.rs:528-534) — including for on-disk records recovered after restart (selene/src/disk_store.rs:2306-2320, 2199-2201, preserved due to zero v4 header changes) until Helios republishes the key and backfillsprefill_saved_ns(selene/src/composite.rs:810-825, 7992-8038).
Subtract / Simplify
- Stop forwarding
set_pool_spill_policyintoCompositeStore's flatMemoryStore(selene/src/composite.rs:2473-2476,selene/src/memory.rs:1243-1265, 1299-1305):- In
CompositeStore,self.memoryis flat (flat = true) and never spills to the pool (CompositeStore::set_spillonly callsself.disk.set_spill(enabled)atcomposite.rs:2470-2472, andCompositeStore::spill_eligible_poolonly queriesself.disk.spill_eligible_pool(key)atcomposite.rs:2477-2479). Callingself.memory.set_pool_spill_policy(policy)atcomposite.rs:2475allocates and maintains a fullHashMap<PrefixKey, PoolCoverage>across every L1 DRAM record and runs anO(n)recompute_clean_slots()scan on every>= 5%pool rate update for zero behavioral effect. Delete line 2475 (or guardpool_coverageinMemoryStoreon!self.flat).
- In
- Simplify
CompositeStore::record_is_packedto queryself.diskdirectly (selene/src/composite.rs:2483-2493):CompositeStore'sTierStoreimplementation retires exclusively fromPoolTier::Nvme(self.disk.take_retiring(),self.disk.retirement_predecessor(),self.disk.pin_export_files()), so checkingself.memory.record(&key)beforeself.diskis backwards and unnecessary. Replacing lines 2483-2493 withself.disk.record_is_packed(key)matches the actual NVMe export source and removes 9 lines.
- Deduplicate
estimated_prefill_saved_*inhelios/src/server/runtime.rs:2917-2921vs3276-3297:- Both sites run
scheduler.estimate_prefill_delta_ns(...)with the identicalgained as f64 / prefill_rate.max(1.0)cold fallback. Extract a sharedestimated_prefill_saved_ns(...) -> u64helper (or haveestimated_prefill_saved_secondswrap it) to eliminate the second fallback formula.
- Both sites run
- Deduplicate pool standalone profitability and chain-byte helpers (
selene/src/memory.rs:424-444,selene/src/disk_store.rs:2186-2206,selene/src/composite.rs:572-577):memory_pool_standalone_profitableanddisk_pool_standalone_profitableare identical apart fromMemoryRecord/DiskRecord, and both repeat thesaved_ns == 0 => truecheck already performed bystandalone_spill_profitable(selene/src/store.rs:529-534). Movingstandalone_profitable(&self, bytes: u64, prefill_saved_ns: u64) -> boolontoPoolSpillPolicyremoves both helpers and the redundant zero-checks.CompositeStore::standalone_nvme_bytes(selene/src/composite.rs:572-577) returns(raw_bytes, raw_bytes)(the sameu64twice); returning a singleu64simplifies both the helper and its caller atcomposite.rs:587-592.
- Collapse duplicated
PoolSpillPolicyconstruction (selene/src/pool/store.rs:202-214vs242-258):PooledStore::newandPooledStore::pool_spill_policyrepeat the identicalremote_manager()→Level→rates[2]/rates[3]match. Extracting one free helperpool_spill_policy(remote_manager: bool, rates: &Ranking) -> PoolSpillPolicyremoves the duplicate block.
Nits
docs/prefix-cache-offload.md:698still refers to parked records as "DRAM-only records" right after the new paragraph (lines 692-696) defines records that fail the NVMe gate as RAM-only/DRAM-only records that are not written on shutdown drain (selene/src/composite.rs:2356drainsself.outbound/self.parked, excludingself.dram_only). Clarifying line 698 to "parked DRAM records" avoids conflating the two.- In the PR description, note that
selene-manager/tests/client.rs(not opened) (fixtureprefill_saved_ns: 0updates) anddocs/files are modified in the top commit, and keep the "zeroselene-managerserver changes" claim scoped explicitly to the top commit (since the stacked diff againstmainincludes #674'sselene-manager/srcchanges).
Dropped on verification
- Correctness lens A2 ("NVMe gate drops DRAM→GPU upload charge under DRAM pressure via
memory.fits(chain_slots)"): Verified false.MemoryStore::fits(selene/src/memory.rs:1737-1739) checks static total DRAM capacity (slots + intake_slots <= slot_count), not transient free slots. When!memory.fits(chain_slots),retains_chain(selene/src/composite.rs:285-326) is alwaysfalse, soCompositeStore::lookup(composite.rs:1798-1806) usesself.disk.hit(chain)(disk_store.rs:3793-3806, disk-read-only rate, streamed viaself.disk.fetch). Under transient DRAM pin pressure whenmemory.fits(chain_slots)istrue,composite_ratesISSome((disk_rate, memory_rate)), matching coldCompositeStore::hit— directly pinned bystreamed_composite_write_under_dram_pin_pressure_matches_cold_admission_price(selene/src/composite.rs:8870-8920). - Subtraction lens S1 ("Delete compaction-lineage +
dram_only_descendants~250 lines and replace withNode::children() >= 2"): Verified false / would break the feature. InCompositeStore,self.memoryis flat (flat = true,memory.rs:369, every node haschildren() == 0) andplan_record_excluding(..., Some(&self.dram_only))(composite.rs:1911-1913) deliberately excludesdram_onlyrecords as parents inself.disk.index()so durable disk records never depend on unpersisteddram_onlyancestors. Thusnode.children()is always0for everydram_onlynode in both indexes; replacingdram_only_descendantswithnode.children() >= 2would completely disable fork-dedup promotion, and droppingcompacted_parent/HostStore::compacted/suppressed_fork_voteswould regress linear GPU compactions into false fork promotions (composite.rs:7578-7642, 8211-8265, 8774-8867). - Correctness lens B2 ("
reap_evicted_dram_onlyswallowsremove_uncharged_batcherror and strandsdram_only"): Verified false in practice.remove_uncharged_batch(selene/src/disk_store.rs:3505-3546) pre-validates every precondition ofIndex::remove_nodesand unpinspins() == 1before calling it;dram_onlynodes cannot havechildren() > 0(plan_record_excludingexcludes them) orpins() > 1(CompositeStore::fetchatcomposite.rs:2074-2082only disk-pinsNodeState::Waitingnodes, which requirenode.ready == true). - Correctness lens B1 ("O(n·retries) full-index rescan per blocked capture retry in
reclaimable_uncharged_subtree"): Dropped as low-signal. Each loop iteration inreserve_disk_capture/store_excluding_reclaiming_dram_only(composite.rs:506-566) only continues whenevict_blocking_dram_only_for_diskremoves alldram_onlyshadows blocking a durable disk root (immediately unlocking it for eviction), andreclaimable_uncharged_subtree(disk_store.rs:2612-2669) short-circuits on the first durable child and returns on the first eligible root. - Subtraction lens S6 ("Double counting between
host_store_reasons[6](unprofitable) andspill_skipped_unprofitable[0]"): Verified false.flare_host_cache_store_reasons_total{reason}(helios/src/server/metrics.rs:529-539, 922-933) exhaustively partitions non-QueuedsynchronousStoreOutcomereturns (mirroring howoversizeis counted in bothhost_store_reasonsandhost_dropped), whereasflare_host_cache_spill_skipped_unprofitable_total{tier}counts all skipped spills across tiers, includingCompositeStore's warm L1 DRAM-retained skips that returnQueued/Storedrather thanUnprofitable. - Subtraction lens S5 (dropping
PoolSpillPolicy.level): Dropped the field-deletion part (leveldocuments the priced tier and guarantees a rescan onHostNvme↔RemoteNvmeswitch even if rates are within 5%); kept only deduplicating the identicalPoolSpillPolicyconstruction block inselene/src/pool/store.rs. - Correctness lens A1 (demoted from Major correctness bug to Should Fix documentation): Verified that scan-recovered records start with
prefill_saved_ns == 0and fail open until republished (disk_store.rs:2199-2201, 2306-2320,composite.rs:7992-8038), but changing.ckptheaders would violate the zero v4 format-change constraint andDiskStorehas no scheduler prefill model. Reclassified as a documentation/disclosure requirement under Should Fix #2.