Repository navigation
fix(selene): fix local storage tier, input cache, sharding, and codec edge cases - #610
Merged
Merged
Conversation
yatesdr
force-pushed
the
fix/selene-local-tiers-and-sharding
branch
2 times, most recently
from
November 29, 2026 17:26
7081343 to
999094e
Compare
Local storage tiers, prepared-input caching, sharded disk ranks, direct
I/O loops, and KV-codec helpers had several correctness, durability, and
accounting bugs:
- Track `HashingState { in_flight, notice, rehash }` in `Announce::hashing`
so interleaved `Ready`/`Gone`/`Ready` transitions neither leak DRAM
pins nor announce stale hashes, and fast-path `allocate_slots(0, false)`
(`selene/src/memory.rs`).
- Refuse direct-to-disk writes under unwritten DRAM-parked ancestors in
`CompositeStore::store`, fix `Inbound::used_disk` NVMe attribution,
and remove the `waiting_spills` head-of-line cap
(`selene/src/composite.rs`).
- Require `!receive_profiles.is_empty()` for v4 packed files in
`DiskStore::new`, prevent self-eviction loops in `make_room_inner`,
fix `Reclaim::unlinked` `used` accounting after `Truncate`-then-`Unlink`,
and reject v4 empty `ranks` and replication flags in `Header::decode`
(`selene/src/disk_store.rs`, `selene/src/shared/record.rs`).
- Use an unbounded invalidation queue, generation epochs, `WaiterGuard`,
pre-eviction `retain()` checks, and accurate `len()` vs `capacity()`
in `InputStore` (`selene/src/input.rs`).
- Return `(drained, result)` from `Peer::shutdown`, return
`with_record_read()` on v4 mismatch and refuse rank-0 truncate fallback
on corrupt v4 files, prune page-only leaves in `shard::agree`, close
peers concurrently in `Sharded::close`, filter unreadable v4 files when
`KvCompression::Off`, propagate the global minimum disk limit across
3+ ranks, and canonicalize peer IPs (`selene/src/shard.rs`,
`selene/src/shard/tests.rs`, `selene/src/offload/sharded.rs`).
- Retry `EINTR` in `fallocate` and `io_uring`, retry block-aligned short
transfers, and make `Worker::publish` directory sync Windows-safe
(`selene/src/disk.rs`).
- Reject duplicate in-flight keys in `PooledStore::fetch`, start rate
tracking only after accepted paged fetches, prefer faster equal-length
local hits when a remote tier is degraded, guard `worth_transfer`
against NaN, use `RefCell::take` across Rayon in `GpuPlan::decode_checked_cpu`,
use checked arithmetic in `geometry.rs`, and reject unknown buffer
names in `codec_layout.rs` (`selene/src/pool/store.rs`,
`selene/src/levels.rs`, `selene/src/store.rs`,
`selene/src/shared/gpu_codec.rs`, `selene/src/geometry.rs`,
`selene/src/shared/codec_layout.rs`).
Local tiers, sharded disk ranks, prepared-input caches, and codec paths
no longer leak pins or disk accounting, desync disk limits across 3+
ranks, or panic on corrupt v4 headers.
Validated on Linux (rebased onto post-NVIDIA#607 main `5df8edd3c`), GB10, and
SM120 hardware across `selene`, `selene-manager`, and `helios offload::`.
Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
yatesdr
force-pushed
the
fix/selene-local-tiers-and-sharding
branch
from
November 29, 2026 17:27
999094e to
c4788c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this change is needed
An audit of Selene's local storage tiers, prepared-input cache, multi-host sharded disk transport, direct I/O worker, and KV-codec helpers surfaced several correctness, durability, and accounting defects (beyond the items already landed in
#607):DiskStore::newtreated v4 packed files as readable even whenreceive_profileswas empty (e.g., restarting with--lossless-kv-compression offover a compressed disk directory), andHeader::decodecould panic on corrupt v4 headers with emptyranksand replication flags set.Announce::hashingleaked DRAM pins or announced stale hashes across interleavedReady/Gone/Readytransitions;CompositeStore::storeallowed direct-to-disk writes under unwritten DRAM-parked ancestors;Inbound::used_diskmisattributed NVMe bytes;Reclaim::unlinkedleakedusedaccounting afterTruncate-then-Unlink; andDiskStore::make_room_innercould self-evict in a loop.InputStorecould drop invalidations when the worker queue was saturated, conflate waiter generations, leave waiters blocked if the worker exited, or evict before checkingretain().Shardedrank-0 disk limit negotiation only propagated two-rank limits instead of the global minimum across 3+ ranks,shard::agreeretained page-only leaves after row intersection,Peer::shutdownleaked unconditionally even when drained,Peer::dispatchfell back to rank-0 truncation on corrupt v4 headers, andSharded::closeclosed peers serially and marked itself closed on partial failure.disk.rsdid not retryEINTRinfallocateorio_uring, did not retry block-aligned short transfers, and called directorysync_allon Windows.PooledStore::fetchdid not reject duplicate in-flight keys and started rate tracking before accepted fetches;GpuPlan::decode_checked_cpuheld aRefCellborrow across Rayon work;geometry.rsandcodec_layout.rslacked checked arithmetic / unknown-buffer checks.Each fix resolves the defect locally inside its owning module without changing Selene's storage architecture or wire compatibility.
What changed
selene/src/memory.rs,selene/src/composite.rs,selene/src/store.rs,selene/src/levels.rs,selene/src/pool/store.rs): TrackHashingState { in_flight, notice, rehash }inAnnounce::hashing; fast-pathallocate_slots(0, false); refuse direct-to-disk writes under unwritten DRAM-parked ancestors (triggering ancestor spill andRetry(Inflight)); fixInbound::used_diskNVMe attribution; removewaiting_spillsHOL cap; guardworth_transferagainst NaN; fixReclaim::unlinkedaccounting; reject duplicate in-flight keys inPooledStore::fetch, startRateonly after accepted paged fetches, and prefer faster equal-length local hits when a remote level is degraded.selene/src/disk_store.rs,selene/src/disk.rs,selene/src/shared/record.rs): Require!receive_profiles.is_empty()for v4 packed files inDiskStore::new; stop self-eviction loops inDiskStore::make_room_inner; reject v4 emptyranksand replication flags beforederive()inHeader::decode; retryEINTRinfallocate/io_uringand retry block-aligned short transfers; handle Windows-safeWorker::publishand Unix post-rename directory-sync cleanup; updateopen_reads_header_and_checksums_in_one_transfertruncated-file chunk count (3 -> 4) to reflect EOF confirmation on block-aligned short reads.selene/src/input.rs): Use an unbounded invalidation channel, isolate waiters by generation epoch, release waiters viaWaiterGuardon worker exit, pre-checkretain()before eviction, and fixlen()vscapacity().selene/src/shard.rs,selene/src/shard/tests.rs,selene/src/offload/sharded.rs): Return(drained, result)fromPeer::shutdownsoserve()only leaks when!drained; returnwith_record_read()on v4 mismatch and refuse rank-0 truncate fallback on corrupt v4 files; prune page-only leaves inshard::agree; poll all peers concurrently inSharded::closeand only setclosed = trueon success; filter unreadable v4 files across all ranks whenKvCompression::Off; propagate the global minimum disk limit across 3+ ranks; canonicalize peer IPs.selene/src/shared/gpu_codec.rs,selene/src/geometry.rs,selene/src/shared/codec_layout.rs): UseRefCell::takeinstead of holding a borrow across Rayon inGpuPlan::decode_checked_cpu; use checked arithmetic ingeometry.rs; reject unknown buffer names incodec_layout.rs.decode_rejects_v4_empty_ranks_and_replication_flags_without_panicking,invalidate_succeeds_even_when_job_queue_is_saturated,agree_prunes_page_only_leaves_after_row_intersection, and NaNworth_transfertests.Expected benefit and measured result
Local tiers, prepared-input caches, multi-host sharded ranks, direct I/O loops, and CPU/GPU codec paths no longer leak pins or disk accounting, desync disk limits across 3+ ranks, or panic on malformed v4 headers. Empirically verified on a 4-node GB10 TP4 cluster with heterogeneous per-rank disk limits (
512M / 384M / 256M / 512M): baseline desynced to0.2 / 0.4 / 0.2 / 0.5 GiBwhile patched converged all 4 ranks to the exact0.2 GiBglobal minimum.Supporting evidence
#607main(5df8edd3c):RUSTFLAGS="-D warnings" cargo check --locked --manifest-path selene/Cargo.toml --all-targets --features codec,rdmaandselene-manager --lib --bins: passed with 0 warnings.cargo test --locked --release --manifest-path selene/Cargo.toml --features codec --lib: 542/542 passed.FLARE_RUN_CUDA_TESTS=1SM120 4× RTX PRO 6000 (cn5, withkv_codec_gpu-sm_120a): 28/28helios::offload::CUDA tests passed.flare run+selene-managerqualification acrossDeepSeek-V4.1-Flash-1017TP4,GLM-5.3-FlashTP2 & TP4 (off,cpu+cpu -> offrestart,gpu),Qwen3.8-Flash-NextTP1 & TP2 on SM120 (cn5), and 4-node GB10 TP4 (--roce-ring) oncn6–cn9: 0 panics, 0 quarantined bytes, bit-exactpos0parity, and verified 4-rank global min disk limit convergence.Worker::publishpath was checked structurally but not run on Windows; live hardware qualification ran against the combined 4-PR stack before rebasing onto#496/#497/#607, and CPU tests were re-run after rebasing onto5df8edd3c.Discord: D-Rock