Explore report · NVIDIA/hyperflare-inference #734

Raw Markdown for agents: https://autobot.eidonix.com/p/0d3a038a-4492-441c-96d6-b7daaabea33d.md

Case file: PR #734 — selene: parallelize startup disk scan and coalesce small header reads

https://github.com/NVIDIA/hyperflare-inference/pull/734 · draft · base main @ 22d2ac9 · head 015076e · opened & last updated 2026-12-04 · labels area:selene, performance

Key findings

  1. The motivation has no issue, bug report or maintainer request behind it. The tracker contains no report about slow startup scanning; searches for "startup disk scan / recovery / record directory scan" return only #734 itself. The scale argument in the description (MAX_DISK_RECORDS = 4096 caps the input store at selene/src/input.rs:26; .ckpt directories are bounded only by --prefix-cache-disk-limit) is checkable and plausible, but the problem statement is the PR's own.
  2. It is the third PR in a series by the same author applying one pattern to Selene I/O — #497 (bounded std::thread::scope hashing in the restore path, merged 2026-11-29) and #496 (read coalescing in the fetch path, merged 2026-11-29). #734 moves the same two ideas into the startup scan path. Nothing is reversed or superseded; #496/#497 are complementary, not overlapping.
  3. selene-manager is only half covered, contrary to how the description reads. record::scan is delegated to (selene-manager/src/disk.rs:101), but the pre-pass that opens every .ckpt to find identity/fingerprint (selene-manager/src/disk.rs:71-98, Header::read_metadata(File::open(...)) at :77) is still a sequential QD=1 loop; par_map is pub(crate) (selene/src/shared/record.rs:1148) so selene-manager cannot reuse it.
  4. The coalesced read only helps .ckpt headers. .input records are inspected by inspect at selene/src/input.rs:1008-1030 with a plain read_exact(&mut h[..88]); they never go through Header::read_metadata, so the .input win is parallelism only. Correspondingly, the only declared regression is on the .input warm path.
  5. The author declares one real regression: warm InputStore::start_bounded on x86_64, 1,000 files: 2.09 → 2.53 ms (0.83x, +0.44 ms), attributed to thread-scope setup plus entries.sort() and explicitly "not separately isolated by ablation". This is a served path (container restart with warm page cache) getting measurably slower, in exchange for 8.36x cold.
  6. Evidence does not meet the repo's served-workload rule. AGENTS.md/charter require performance PRs to show a speedup on a served workload (#210); the description itself says these are "isolated component microbenchmarks, not end-to-end flare run startup timings". Also, the ~200-line harness lives in an uncommitted selene/examples/scan_bench.rs (not opened) (only rank_node is declared in selene/Cargo.toml:57-59), so the numbers cannot be reproduced from the branch, only by pasting the description.
  7. Undeclared behavioural changes beyond performance: .tmp/invalid/.input.pending deletion is now deferred to a second pass, so a mid-scan Unreadable error leaves garbage on disk that the old code would have removed before failing; and .input admission order is now lexicographic (selene/src/input.rs:552), which changes which records survive a tight DiskBudget/MAX_DISK_RECORDS.
  8. Process: draft, no CI on the head commit, no comments, reviews or reactions. The repo's native-serving.yml does run selene tests on windows-2022 (.github/workflows/native-serving.yml:48-55 (not opened)), which would partly cover the one admitted gap (no native Windows execution).
  9. No compatibility surface changes: no on-disk v3/v4 .ckpt/.input format change, no protobuf/wire change, no new dependency, no unsafe in production code, no flag or metric rename. read_metadata's new read-ahead is cursor-unsafe for a pub fn, but all five callers either drop the handle or use positional reads (verified).
  10. The win lands in an operator-visible, already-timed phase: record::scan and InputStore::start_bounded both run inside Prepare host prefix cache, which emits on_step("scanning disk records") and records timings.disk_scan (selene/src/offload.rs:750-765, :767-779), a timing added by merged PR #625 and documented at docs/prefix-cache-offload.md:1070-1076. #734 adds no metric of its own.

The change

Size: +554/−30 in 2 files (pr_files), matching the description's arithmetic (+135/−30 production, +419 test LOC; 554 − 419 = 135).

1. Coalesced metadata read — Header::read_metadata (selene/src/shared/record.rs:357-397). Baseline on main is vec![0; HEADER_BYTES] + read_exact, then a second read_exact for the v4 directory tail (selene/src/shared/record.rs:354-370 at ref main). The new version fills a stack buffer of HEADER_BYTES + 4096 in a read() loop that tolerates short reads and retries ErrorKind::Interrupted, so v3 headers and v4 directories ≤ 4 KiB cost one syscall; larger v4 directories (up to packed::MAX_DIRECTORY, selene/src/shared/packed.rs:17 (not opened)) fall back to one read_exact tail. The doc comment now states "May read ahead past the end of the metadata … callers must not rely on the reader cursor position after this returns" (:359-360). Note the read-ahead can pull up to 4 KiB of the first page segment into the buffer and discard it; harmless for every current caller (below).

2. Bounded parallel map — par_map (selene/src/shared/record.rs:1142-1192), pub(crate): threshold 64 items, chunk 8, at most 16 workers from available_parallelism().map_or(4, ..); std::thread::scope + Builder::name("flare-scan").spawn_scoped(..).ok() (a failed spawn silently degrades capacity), calling thread participates, results re-sorted by index so order is preserved; below threshold or with one worker it degrades to a serial iter().map.

3. record::scan restructured — selene/src/shared/record.rs:1209-1278: collect candidate names/symlink flags from fs::read_dir, par_map over fs::symlink_metadata (never follows symlinks; !metadata.is_file() → Absent) and inspect, then a serial reduction that returns the first Inspection::Unreadable(error) before any deletion, then a removal pass for .tmp/invalid paths, then unchanged remove_orphans (:1280+) with its deterministic (consumed_tokens, digest) ordering.

4. Worker::scan restructured — selene/src/input.rs:514-587: collect .input and .input.pending paths without deleting anything inside read_dir, entries.sort() (:552), par_map(inspect), return the first non-InvalidData error (:554-562) before unlinking temporaries or mutating self.disk/self.budget, then delete temporaries and apply the unchanged serial budget/MAX_DISK_RECORDS admission loop (:568-585).

Tests added (inside the same two files): single-read/EINTR/short-read/truncation coverage for read_metadata (:2474+), parallel_scan_handles_large_mixed_v3_v4_directory_deterministically (also pins that dangling and live symlinks, subdirectories and foreign files survive), parallel_scan_preserves_directory_on_unreadable_entry and an input-side variant that asserts corrupt/over-budget/.pending/blocked files all survive an unreadable-entry failure and the budget is untouched (selene/src/input.rs:1643-1750).

What the description does not say (verified in the diff)

Description claims that check out


The why

The description's argument: recovery inspects every cached .ckpt and .input file sequentially at QD=1, with two blocking read() calls per v4 header, so local NVMe queue depth is unused and startup stalls; caches hold "hundreds to tens of thousands of records".



Recent activity

selene/src in the last 60 days is dominated by yatesdr (38 commits), then Luke Alonso (7), Martin Vit (2). Recent, directly relevant: #694 (write-side NVMe / pool spill profitability gate, 2026-12-04), #674 (prefix-cache hit rate, L1 retention, NVMe throughput, GPU snapshot packing), #625 (offload startup timings — the hook #734's improvement shows up in), #612/#611/#610 (selene-manager and selene hardening/fixes). #734 builds on this work and conflicts with none of it: no shared hunks, no format changes, no reversal of the hardening PRs.


People


Community

Zero comments, zero reviews, zero reactions at the time of this case file. The description is unusually complete (four-part why/what/result/evidence structure, two architectures, interleaved A-B-B-A method, explicit limitations), which is consistent with the author's history of answering review rounds on #496/#497. Interest is currently nil; the PR is a same-day draft.


Project fit


Claims and evidence

Claim Evidence Verdict
Cold scan speedups, 9–11x at 10,000 .ckpt on both arches Author's bare-metal benchmark, medians + p10–p90, interleaved A-B-B-A, control 22d2ac9 vs candidate 015076e Self-reported, not independently reproduced; methodologically described in unusual detail, but harness uncommitted
Warm scan speedups 1.38x/1.85x/2.28x (x86_64) and 2.39x/3.14x/2.99x (aarch64) same Self-reported; much weaker than cold, as expected for page-cache-warm metadata
Cold InputStore::start_bounded 8.36x / 9.02x same Self-reported; consistent with parallelism over 1,000 files
Warm InputStore::start_bounded 0.83x on x86_64 (2.09 → 2.53 ms, +0.44 ms) declared by the author, attributed to thread-scope setup + entries.sort(), "not separately isolated by ablation" Honest disclosure of a real regression on a common path; cause unproven
aarch64 warm distributions bimodal, arms overlap on InputStore author says so Declared; cold cells do not overlap (max(cand) ≪ min(ctrl))
591 selene tests (590 lib + 1 integration) with test-support, 566 with --no-default-features, on bare-metal GB10 and x86_64 container, non-root author-reported counts, three rustc versions Plausible and far above the 522/475 quoted in #496/#497 after ~10 days of main growth; not verifiable without CI
Full-suite counts: helios 1,976; flare 247; flare-cli 224; selene-manager 205 + 98; pytest 4 author-reported Not verifiable without CI
read-ahead is cursor-safe verified in code (five call sites) Confirmed
0 unsafe, 0 new deps, formats unchanged verified in diff Confirmed
selene-manager benefits partially — only the scan call, not its identity pre-pass Overstated in effect
Windows correctness statically audited only, never executed Admitted gap; windows-2022 CI in native-serving.yml:48-55 would exercise the non-#[cfg(unix)] new test once run
Impact on end-to-end flare run startup not measured Missing; also missing: RSS/CPU cost of up to 16 extra threads at startup, and any measurement with a cold page cache smaller than the cache directory
Attribution between the two mechanisms (coalesced read vs parallelism) no ablation Missing — #497's review asked for exactly this kind of separation

Reach


Process


Open questions / what could not be found

  1. Where did the problem come from? No issue, no user report, no maintainer request. Would a maintainer confirm the scan is a real startup bottleneck in a served deployment (and at what record counts)?
  2. End-to-end effect on flare run's Prepare host prefix cache phase (the timing exists via #625) — nothing measured.
  3. Split of the win between read coalescing and parallelism; especially whether the 0.83x warm .input regression would disappear without entries.sort() or with the existing rayon pool.
  4. Why raw scoped threads instead of the existing rayon cpu_pool (selene/src/shared/codec.rs:37-60)? A deliberate choice (nice/policy isolation) or a convenience?
  5. Intended permanence of the deferred-deletion/fail-closed semantics — this looks like a deliberate hardening addition riding along with a performance PR, and is not called out as such.
  6. Will the benchmark harness be committed? AGENTS.md asks for reproducible inputs; the only harness is ~200 lines pasted in the description.
  7. Windows: nothing executed; CI would cover it once checks run.
  8. Not found: any reaction from yatesdr/other selene/src owners; any prior discussion of the .input scan ordering guarantee that the new sort() establishes.