Repository navigation
Conversation
|
A case file has been opened for 705. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe state machine is sound — every
Walkthrough
Merge Risk: Medium · up to
|
eec5e95 to
63206a0
Compare
|
@flare-autobot Pushed
Ready for re-review! Discord: jcartu |
63206a0 to
abd39ba
Compare
|
@flare-autobot Rebased onto Preserved from #674: the Validated on Note: the SM120 TP4 Discord: jcartu |
…) CPU storm Refs NVIDIA#703. When CompositeStore runs out of DRAM retention slabs while disk spills are saturated at MAX_SPILLS or failing with ENOSPC, repeated StoreOutcome::Retry(Slabs) deferrals previously caused a tight CPU spin loop and O(N) spill-recheck amplification across Worker::service_store and CompositeStore: - Worker::service_store unconditionally set progress = true on every loop iteration, preventing the worker from parking even when every deferred store returned the identical Retry(reason). - CompositeStore::poll incremented stats.progress on ENOSPC write failures, re-triggering all deferred stores even though zero slots became durable. - CompositeStore::store invoked spill_parked() on every Retry(Slabs) while MAX_SPILLS writes were already in flight, repeatedly sorting parked keys and inflating held[0] per rejected publication. This change stops the storm while preserving wakeup liveness: - helios/src/server/runtime.rs: reconcile take_publications(), deferred_stores, and deferred_copyouts by CheckpointId via a single Pending claim helper so each ID runs at most once with accurate fresh and prior_retry tracking. Mark worker progress only on explicit real state transitions (Queued, Present, Oversize, Err, or a changed StoreReason), and gate non-fresh StoreReason::Slabs retries on store.can_retry_slabs(&publication). - selene/src/store.rs, pool/store.rs, pool/local.rs: add default-true HostStore::can_retry_slabs and forward it through PooledStore and Tiers. - selene/src/disk_store.rs: add zero-clone plan_record_slice and plan_record_meta helpers; delegate plan_record to plan_record_slice. - selene/src/composite.rs: return false from disk_stored() on ENOSPC backoff so ENOSPC completions do not bump stats.progress, while returning true if a DiskJob::Write slot is freed even without a matching outbound entry (removing any orphaned parked entry to prevent self.outbound[&key] panics in spill()). Edge-trigger stats.progress += 1 once when retry_after expires in poll() so idle waiters wake up cleanly (bounded to one probe per 50 ms backoff, ~20 Hz, observed via Worker::run idle_wait() which waits 50 us for inbound transfers, 100 us for pool lookups, or 2 ms fallback when executor.outstanding() == 0). Replace spillable_slots() with early-exit has_spillable_slots(), add O(jobs) writing_spills() with the O(parked) 1:1 DiskJob::Write <-> parked.writing debug_assert_eq in poll() maintenance, guard spill() against double-writing an already-writing parked record (updating the pre-existing test assertion at store.spill(child.key) to check !parked.writing first), skip spill_parked() in store() when writing == MAX_SPILLS, share validate_tail/covered_endpoint and zero-clone planning between store() and can_retry_slabs(), and implement CompositeStore::can_retry_slabs. - docs/prefix-cache-offload.md: document HostStore::can_retry_slabs, the per-ID StoreReason retry contract and Slabs gate, and the updated held_total and store_skipped_total cadence under MAX_SPILLS/ENOSPC and the Slabs gate. Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
abd39ba to
55fd8ac
Compare
|
@flare-autobot re-review on Discord: jcartu |
Refs #703
Summary
Stops the CPU spin loop and retry amplification in
Worker::service_storeandCompositeStorewhen DRAM retention slabs are saturated and disk spills are either full atMAX_SPILLSor hitting filesystemENOSPC.Background and Trigger
Issue #703 observed this storm on
v0.5.1under a disk-fullENOSPCtrigger where parked DRAM copies could not commit to disk, causing every spill failure to re-trigger the full deferred queue. The same underlying retry amplification also affects healthy disks wheneverMAX_SPILLS(8) concurrent writes are already in flight and incoming/deferred publications exceed remaining DRAM headroom:Worker::service_storepreviously setprogress = trueunconditionally on every publication attempt, preventing the worker loop from parking even when every deferred store returned the exact sameStoreOutcome::Retry(reason).CompositeStore::pollpreviously incrementedstats.progressonENOSPCwrite failures, immediately re-waking all deferred publications even though zero slots became durable.CompositeStore::storepreviously calledspill_parked()on everyRetry(StoreReason::Slabs)rejection even whileMAX_SPILLSwrites were already running, repeatedly sortingparkedkeys and inflatingheld[0]per rejected publication.Worker::service_storelacked a single per-CheckpointIdreconciliation pass acrosstake_publications(),deferred_stores, anddeferred_copyouts, using O(N) scans and risking duplicate/zombie waiter state on same-ID fresh plus deferred collisions.Changes
helios/src/server/runtime.rs:take_publications(),deferred_stores, anddeferred_copyoutsbyCheckpointIdinto a singleVec<PendingStore>indexed byHashMap<CheckpointId, usize>viaPending::claimbefore iterating. Each uniqueCheckpointIdis processed at most once, preservingfreshandprior_retryaccurately under bothretry == falseandretry == true(no zombie waiters on fresh success, accuratehost_retry_successaccounting, and clean updates whenStoreReasonchanges).progress = trueonly on genuine state transitions (StoreOutcome::Queued | StoreOutcome::Present | StoreOutcome::Oversize,Err, or a changedStoreReason), allowing the worker to park when retries make no state change.StoreReason::Slabsretries onstore.can_retry_slabs(&publication)beforeexport_fits()andstore.store(), preventing unready large publications from thrashing while letting smaller publications that fit proceed without starvation.selene/src/store.rs,selene/src/pool/store.rs,selene/src/pool/local.rs:HostStore::can_retry_slabs(&self, _checkpoint: &PublishedCheckpoint) -> boolwith a defaulttrueimplementation, forwarded throughPooledStoreandTiers.selene/src/disk_store.rs:plan_record_slice(borrowing&[PagePayload]) andplan_record_meta(metadata-only, zero page-vector clone) forCompositeStore::store()andCompositeStore::can_retry_slabs(), keepingplan_recordfor its two existing callers (disk_store.rs:2619,disk_store.rs:3419) and unit tests.selene/src/composite.rs:disk_stored()to return whether waiters should reconsider: returnsfalseonENOSPCbackoff (soENOSPCcompletions do not bumpstats.progress) and returnstruewhenever aDiskJob::Writeslot is freed, including ifoutboundwas already removed (removing any orphanedparkedentry so subsequentspill()calls cannot panic onself.outbound[&key]).retry_aftertimer expiry inCompositeStore::poll(), unconditionally clearself.retry_after = Noneand edge-triggerself.stats.progress += 1once. Under sustainedENOSPC, retry cadence is bounded to one probe per 50 ms backoff (~20 Hz), never a tight spin loop, andWorker::run(helios/src/server/runtime.rs:1248-1292) enforces a 50 us / 100 us / 2 ms idle poll cap whenexecutor.outstanding() == 0so theretry_afterexpiry edge fires reliably even with zero new publications.spillable_slots()with early-exithas_spillable_slots(need), addvalidate_tail()andcovered_endpoint()helpers, and enforce the 1:1DiskJob::Writetoparked.writinginvariant inpoll()maintenance viadebug_assert_eq!.spill()withif parked.writing { return None; }so an already-writing parked record cannot start a duplicate concurrent disk write.spill_parked()inCompositeStore::store()whenwriting == MAX_SPILLS(maintenance inpoll()still accounts forheld[0]once per tick).CompositeStore::can_retry_slabs()and add a#[cfg(test)]injectable backoff clock (poll_at) for deterministic testing.docs/prefix-cache-offload.md:HostStore::can_retry_slabs, the 50 msENOSPCretry_afterbackoff and progress edge-trigger, and theheld[0]maintenance-tick accounting semantics.Served-Workload A/B Benchmark (SM120 TP4,
ENOSPCWorst-Case Regime)Measured back-to-back on identical hardware and configuration: 4x RTX PRO 6000 Blackwell (SM120),
DeepSeek-V4.1-FlashTP4,--prefix-cache-memory 2Gbacked by a 64 MiBext4loopbackO_DIRECTvolume pre-filled to triggerENOSPC, warmed with an identical 416-request saturation sequence (3,443/6,547host-cache slots in use,314parked records). Note that this single-runENOSPCregime is the worst case for baseline; healthy-diskMAX_SPILLSsaturation deltas will be smaller.3d1614cc)63206a09)flare-modelCPU %slabsretriesstore_skipped: 9,991 vs 0; gated retries no longer reachstore()held_total{tier="dram"}c=4wall / throughput17.47 / 3.663; 4.78x from rounded req/s)c=4latency p50 / p95 / maxc=4countedslabsretriesstore()rejections; gated retries no longer reachstore()so they never incrementstore_skipped_total/store_reasons_total(1 fresh attempt per new request)c=4CPUproc158.5%)proc381.1%)Narrow Metric and API Shifts
ENOSPCdisk-write failures no longer incrementStoreStats::progresson completion; instead,progressedge-triggers once when the 50 msretry_afterbackoff expires.StoreStats::held[0]is now accounted on progress-gatedpoll()maintenance ticks rather than per rejectedRetry(Slabs)call inCompositeStore::store(), and deferredSlabspublications skipped bycan_retry_slabs()do not callstore.store()or incrementhost_store_outcome.HostStore::can_retry_slabsis a new default-truetrait method onHostStore, forwarded throughPooledStoreandTiers.Out of Scope
ENOSPCretention and eviction policy documented indocs/prefix-cache-offload.mddisk_bytesmetric definition and accountingexport_fits()internal cloning behaviorVerification
All checks ran on Linux x86_64 with
prlimit --memlock=unlimited:--locked --release):cargo test --locked --release --manifest-path selene/Cargo.toml: 558 passed, 0 failed, 0 ignored (541#[test]+ 17#[tokio::test])cargo test --locked --release --manifest-path selene/Cargo.toml --features test-support: 558 passed, 0 failed, 0 ignored (test-support = ["codec"]inselene/Cargo.tomlgates library code rather than test items, so identical count is expected)FLARE_TEST_TEMPLATE_DIR=... cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server: 1,906 passed, 0 failed, 84 ignored (includes 2FLARE_MUSE_SPARK_SNAPSHOT-gated Muse-Spark tests and 82 GPU/checkpoint-snapshot/release-benchmark tests)debug_assert!invariant checks):cargo test --locked --manifest-path selene/Cargo.toml composite::tests -- --nocapture: 65 passed, 0 failed (verified 0test_directorydirect-I/O skips)cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server phase_tests: 132 passed, 0 failedselene/src/composite.rsand 4 inhelios/src/server/runtime/phase_tests.rscargo clippy --locked --manifest-path selene/Cargo.toml --all-targetsandcargo clippy --locked --manifest-path helios/Cargo.toml --features runtime-core,server --all-targets: 0 warnings and 0 errors on all touched lines.rustfmt --edition 2024 --check: 0 formatting diffs on all touched lines.Discord: jcartu