Explore scratchpad · NVIDIA/hyperflare-inference #734

Raw Markdown for agents: https://autobot.eidonix.com/p/6b1a6c7d-7d70-4633-8017-0b6debdd0093.md

#1 [high] Change: what PR #734 does and its size

PR #734 (open, DRAFT, author FujitsuPolycom, labelled area:selene + performance, Discord "Dooner", base main 22d2ac9, head 015076e, opened & last updated 2026-12-04, no CI checks, no reviews, no comments).

Files (pr_files): selene/src/input.rs (+130/−7), selene/src/shared/record.rs (+424/−23). Total +554/−30; description says +105 net non-test production LOC (+135/−30) with +419 test LOC.

Three production changes:

  1. Header::read_metadata (selene/src/shared/record.rs:355-397): reads into a stack buffer [0u8; HEADER_BYTES + 4096] in a single read() loop (handles short reads + EINTR), so v3 headers and v4 directories <= 4096 B are covered by one syscall; larger v4 falls back to Vec + read_exact for the tail. Doc comment now says "May read ahead past the end of the metadata... callers must not rely on the reader cursor position after this returns" (record.rs:357-359). HEADER_BYTES = BLOCK_BYTES = 4096 (record.rs:92); packed::MAX_DIRECTORY = 2 MiB (selene/src/shared/packed.rs:17).
  2. New par_map helper (record.rs:1142-1189): PARALLEL_SCAN_THRESHOLD=64, PARALLEL_SCAN_CHUNK=8, MAX_SCAN_WORKERS=16; workers = available_parallelism().map_or(4,..).clamp(1,16), falls back to serial map below threshold or if <=1 worker; uses std::thread::scope + Builder::name("flare-scan").spawn_scoped(...).ok() (spawn failure silently degrades to fewer threads) with the calling thread participating; results re-sorted by index for order.
  3. record::scan (record.rs:1206-1280) split into collect-candidates → par_map symlink_metadata + inspect → serial reduction that deletes .tmp/invalid files only after no Unreadable error; then remove_orphans.
  4. Worker::scan (selene/src/input.rs:518-585): collects .input entries, sorts paths, par_map(inspect), returns the first non-InvalidData error before unlinking .input.pending or mutating self.disk/self.budget, then applies the serial budget/recovery loop.

Tests added (record.rs:2429-2740 and input.rs:1643-1750): read_metadata single-read/EINTR/short-read/truncation tests, parallel_scan_handles_large_mixed_v3_v4_directory_deterministically (also checks dangling + live symlinks, subdirs, foreign file survive), parallel_scan_preserves_directory_on_unreadable_entry, two input-side tests (deterministic recovery under tight DiskBudget; unreadable entry preserves dir+budget).

#2 [high] Change: behaviour changes the description does not spell out

Things the description understates or omits (verified in the diff, pr_diff of both files):

  1. Deletion is now deferred and best-effort-ordered: previously record::scan deleted .tmp/invalid files inline as it walked; now removals happen in a second pass after reduction (record.rs:1266-1280). Same net effect on success, but on a mid-scan Unreadable error the whole removal pass is skipped, so garbage that a previous run would have deleted survives until the next successful scan. Same intentional fail-closed change in Worker::scan for .input.pending files (input.rs:548-568) — .pending files used to be deleted as encountered inside read_dir, now only after all inspects succeed.
  2. Worker::scan now sorts .input paths lexicographically before inspecting (input.rs:552 entries.sort()). This is a new deterministic admission order under MAX_DISK_RECORDS/DiskBudget; before, order followed fs::read_dir order. The description mentions it, but it is a behaviour change in which records survive a tight budget, not just a perf change. Test parallel_scan_recovers_large_directory_deterministically_under_tight_budget (input.rs:1645+) pins the new order.
  3. Worker::scan error selection changed: it reports the first non-InvalidData error by sorted path order, and uses swap_remove on the result vec. Description mentions reject-before-unlink; what it does not say is that all inspections still complete before the error is returned (no early abort), so a directory of thousands of files pays full inspection before failing.
  4. par_map is pub(crate) and lives in shared::record (record.rs:1148). selene-manager cannot use it; selene-manager/src/disk.rs::recover (disk.rs:60-108) still does its own sequential per-directory Header::read_metadata loop over the first entries to find identity/fingerprint before delegating the actual scan to record::scan (disk.rs:101). So selene-manager's own discovery loop is still QD=1 — the description says "delegates full directory scans to record::scan", which is true for the scan but not for its pre-pass.
  5. Symlink handling unchanged: inspect still uses fs::symlink_metadata and requires is_file(), so symlinks (live or dangling) are neither followed nor deleted — same as before the change; the new test locks that in. Note a live symlink to a regular file is not treated as a record, it is skipped (record.rs:1256-1262 if !metadata.is_file() { return Inspection::Absent }).
  6. Read-ahead can consume up to 4096 bytes of the first record segment into the buffer: for a v3 record whose file is only HEADER_BYTES long (metadata-only), read() returns fewer bytes, fine; but for any record whose segment begins with page data, up to 4096 page bytes are read and discarded. No correctness effect since every caller either drops the handle or uses positional reads (verified: selene/src/disk.rs:1478 caller later uses read_exact_at at disk.rs:1464, io_uring submits explicit offsets at disk.rs:2126-2165; selene/src/shard.rs:1200-1273 opens and drops per use; selene-manager/src/disk.rs:77 drops the File each iteration).

#4 [high] Project fit: scan runs in the timed 'Prepare host prefix cache' phase (PR #625)

#5 [high] Related work: author's #497/#496 series — same pattern, adjacent paths

This is the third PR in a series by the same author (FujitsuPolycom, Discord "Dooner"; CONTRIBUTOR; 20 merged, 12 closed, 0 open in the last 180 days) doing the same kind of change in Selene:

#6 [high] Project fit: matches charter goals; deviates from the served-workload evidence rule

AGENTS.md (repo root) requirements vs. what this PR supplies:

#7 [high] Process & community: draft, zero engagement, no CI, no review yet

#8 [high] Claims and evidence: what is backed, what is self-reported, what is missing

Headline claims in the description and how each is (or is not) backed:

  1. "9.93x cold / 2.28x warm speedup for record::scan of 10,000 .ckpt on x86_64; 10.84x/2.99x on aarch64 GB10." Backed by the author's own bare-metal microbenchmark, medians with p10–p90, interleaved A-B-B-A, control 22d2ac9 vs candidate 015076e, dataset generator in the uncommitted harness. Not independently reproduced; not end-to-end; the harness itself is not in the diff, so a reviewer must paste ~200 lines from the description to re-run it.
  2. Cold cells are the strong result (all cold cells have non-overlapping ranges). Warm cells are much weaker: record::scan warm 1.38x (500), 1.85x (2000), 2.28x (10000) on x86_64.
  3. One measured regression is declared honestly: warm InputStore::start_bounded on x86_64 goes 2.09 → 2.53 ms (0.83x, +0.44 ms) for 1,000 files; the author attributes it to thread-scope setup + entries.sort() but says it was "not separately isolated by ablation". This is the one place the change makes a real-served path slower, and the affected path (warm restart of the input store) is common in practice (a container restart with a warm page cache).
  4. aarch64 warm distributions are bimodal and overlap between arms on InputStore; the author says so. Cold ratios on GB10 are ~9–10x.
  5. Test evidence is strong and specific: 591 selene tests (lib+integration) with test-support, 566 with --no-default-features, on both aarch64 bare metal and x86_64 container, non-root uid 1000/1001 with rustc 1.94.1/1.99.1/1.100.0; plus full-suite counts for helios (1,976), flare (247), flare-cli (224), selene-manager (205 + 98), and 4 Python tests. Counts are far above the 522/475 figures quoted in #496/#497, consistent with ~10 days of main-branch growth — plausible but not verifiable without CI.
  6. Claim "all five callers in selene and selene-manager either drop the file handle or use positional read_exact_at" — verified correct (see scratchpad entry on callers): record.rs:1334, disk.rs:1478 (positional reads at disk.rs:1464 and io_uring span.offset), shard.rs:1200, shard.rs:1251, selene-manager/src/disk.rs:77.
  7. Claim "0 production unsafe, 0 new dependencies" — verified: diff adds no unsafe; Cargo.toml untouched (std::thread::scope/spawn_scoped only). The only unsafe in the added code is libc::geteuid() inside a #[cfg(unix)] test (record.rs test parallel_scan_preserves_directory_on_unreadable_entry).
  8. Claim "+105 net non-test production LOC (+135/−30)": not independently recounted; pr_files reports +554/−30 across two files, which includes the +419 test LOC the description also states (554 − 419 = 135 added, −30 removed → +105 net; arithmetically consistent).
  9. NOT claimed and not measured: any end-to-end flare run startup A/B; any RSS/CPU-cost measurement of the new threads at startup; any measurement on a machine with a page cache smaller than the cache directory; any behaviour of the changed deletion ordering under a real unreadable-file incident.
  10. No ablation of the two changes against each other (read coalescing vs parallel scan), so a reader cannot tell how much of the cold win comes from each. #497's reviewer asked for exactly this kind of isolation ("attribute the hash pool separately"); the same ask applies here.

#9 [high] Reach: who is affected, compat, deployment, and what is not reversed

Who and what this touches (verified):

#10 [high] Why: the motivation is self-declared, not issue-backed

#12 [high] Amendment 2026-12-05 (head b7bd3fa9): scope shrank, coalescing reverted, served-workload A/B added

Head moved 015076e -> b7bd3fa9 (014076e... incremental 015076ec..b7bd3fa9; PR now based on main be4092d7). Size now +498/-112 in 3 files (pr_files): selene/src/shared/record.rs +352/-103, selene/src/input.rs +140/-7, docs/prefix-cache-offload.md +6/-2. Title changed to "selene: parallelize startup disk scan" (coalescing dropped from title). Labels now area:selene, performance, triage:validation (triage label added); item reads as open, not draft.

SUPERSEDED from my 2026-12-04 report:

WHAT THE CODE LOOKS LIKE NOW:

#13 [high] Amendment: served-workload + ablation evidence now present, with 4 caveats

PR #734 body (updated 2026-12-05) now carries end-to-end flare run startup A/B, closing the docs/design-review.md:106-115 / #210 served-workload rule I flagged:

  1. Cross-round control inconsistency: my 2026-12-04 report recorded warm .input control 2.09 ms -> 2.53 ms on x86_64; this round's x86_64 control is 4.40 -> 2.60 ms for the same 1,000-file workload. The control more than doubled, so the "regression is gone" conclusion rests on a different environment (WSL2 ext4), not on a like-for-like rerun. The candidate absolute barely moved (2.53 -> 2.60 ms). Ask which environment is representative before treating warm as won.
  2. .ckpt bodies are sparse seeded files (set_len), so cold drop_caches cost is inode/header reads without real data extents; scan only touches headers, so this is close to representative, but the cold 8.60x should not be read as "650 GiB cache".
  3. Single host, TP1, one core; x86_64 evidence is component-only inside WSL2. Native Windows still static-audit only.
  4. Harness still uncommitted: selene/examples/ holds only rank_node.rs and selene/Cargo.toml:57-58 declares only rank_node. Mitigated, not fixed — the full scan_bench.rs source is now pasted into the PR body <details>, so a reviewer can reproduce by hand. Test-count claims (self-reported): aarch64 1,945 passed/8 ignored; x86_64 3,287 Rust + 4 Python; selene 645 with test-support and 620 --no-default-features on both. New mutation claims: deleting entries.sort_unstable_by or restoring inline deletion makes the new tests fail on FIFO, LIFO tmpfs and hash-ordered ext4.

#14 [high] Amendment: what still stands on b7bd3fa9 (manager pre-pass, no issue, process, reach)

Findings from my 2026-12-04 report that still hold on head b7bd3fa9 (verified):

  1. selene-manager's pre-pass is still sequential. selene-manager/src/disk.rs:60 recover() opens each .ckpt and calls Header::read_metadata one at a time (:77) before delegating the actual scan to record::scan (:101). par_map is pub(crate) (record.rs:1124) so the manager crate cannot reuse it. The updated description still says "selene-manager/src/disk.rs::recover delegates full directory scans to record::scan", which is true only of the scan, not the identity/fingerprint pre-pass. Unchanged from the prior head.
  2. Still no issue, bug report or maintainer request behind it. search_items "parallelize startup disk scan" returns only #734. Nearest adjacent operator complaint remains #616 (closed) and its fix #625 (merged), which added the timings.disk_scan / "Prepare host prefix cache" surface that this PR's evidence now uses (docs/prefix-cache-offload.md, selene/src/offload.rs). So the why is still self-declared but now quantified against a real served boot.
  3. Process moved: this is no longer a zero-engagement draft. triage:validation label added; one Autobot review ("Changes Requested", 0 blockers / 1 should-fix / 3 simplify / 3 nits) at 2026-12-04 22:00; one author response at 2026-12-05 01:10 answering every point. No human maintainer review yet, and no CI run is visible in the conversation (the author's numbers are local --release runs; the repo's native-serving.yml windows-2022 selene job still would be the first native-Windows signal).
  4. Reach/risk unchanged: pre-serving startup only; no on-disk v3/v4 .ckpt/.input format change, no protobuf/wire change, no new dependency, no production unsafe (only libc::geteuid() in #[cfg(unix)] tests, e.g. record.rs test at the parallel_scan_preserves_directory_on_unreadable_entry body). Thread count bounded at 16; FD concurrency bounded by workers since inspect closes its handle before returning (record.rs:1306-1353).
  5. Behaviour changes now documented rather than undeclared (see note 12). Their effect on a tight budget is unchanged: lexicographic .input admission decides which records survive (input.rs:552 + :568-585), pinned by parallel_scan_recovers_large_directory_deterministically_under_tight_budget (input.rs:1668+, seeded odd-then-even so a FIFO/LIFO/hash readdir order cannot pass).
  6. No behaviour change in the .input unreadable path: on failure Worker::new releases the reserved input bytes (selene/src/input.rs:506-510) and returns the error; the new test also asserts the budget comes back whole (budget.checkpoint_limit() == limit, checkpoint_pressure() == 0, reserve_input(limit) succeeds) at input.rs:1751-1753.
  7. record::scan still completes every inspection before reporting the first Unreadable (par_map has no early abort), so the fail-closed ordering is paid for with a full-directory inspection on failure. Documented intent now; not a defect.

#15 [high] Amendment: revised verdict and open questions for maintainers

Amended verdict for PR #734 at head b7bd3fa9 (2026-12-05). My 2026-12-04 report said "Changes Requested, evidence gap: no served workload, uncommitted harness, declared warm regression". Revised position:

#17 [high] Research summary

PR #734 was rewritten between my 2026-12-04 report (head 015076e) and head b7bd3fa9, so the amendments are substantial rather than cosmetic. Saved as scratchpad entries #12–#16.

What is now superseded. The Header::read_metadata 4 KiB read-ahead was deleted outright — head selene/src/shared/record.rs:357-372 is byte-identical to main — so the cursor-contract concern, the "coalescing helps .ckpt only" point and the read-ahead tests are moot. The declared warm .input regression was withdrawn, the "undeclared behaviour" block is now present-state docs (docs/prefix-cache-offload.md:681, :1199-1204), and the served-workload evidence gap I treated as the main blocker is closed by an end-to-end flare run A/B (cold phase 2,542.00 → 295.44 ms, 8.60x; spawn→/health −2.21 s, −12.6%), plus the ablation I asked for, which is what drove the deletion of the coalescing. Scope shrank to +498/−112 in 3 files, title lost "coalesce", triage:validation added.

What still stands. selene-manager/src/disk.rs:77's identity pre-pass is still QD=1 (par_map is pub(crate)), contradicting the unchanged "delegates full directory scans" wording; the motivation is still self-declared with no issue behind it; and risk/compat are unchanged (no format, wire, dependency or production-unsafe change). One correction worth noting: the printed timings.disk_scan covers record::scan only (selene/src/offload.rs:750-765); InputStore::start_bounded starts after it at :769, so the "2.2 → 0.2 s" figure must not be cited as the .input result.

New caveats, not blocks. The withdrawn warm regression was not re-measured like-for-like — my prior control was 2.09 ms, this round's is 4.40 ms for the same workload while the candidate barely moved — and the harness is still uncommitted (only rank_node in selene/Cargo.toml:57-58), mitigated by pasting scan_bench.rs (not opened) into the PR body. Evidence remains single-host TP1 GB10 with sparse .ckpt bodies, x86_64 component-only in WSL2, native Windows static-audit only, and no visible CI. No Autobot re-review has run since the author's 2026-12-05 01:10 response, and no human maintainer has engaged.

#18 [high] Current state at b7bd3fa9: verified file map and citations to use (supersedes stale parts of #11)

Use this instead of the file map in entry #11, which describes code that no longer exists (the read_metadata read-ahead, the "coalesce small header reads" half of the title, +554/-30 in 2 files, and the read_metadata tests).

PR metadata at this head (read_item 734): open, not draft; head b7bd3fa9032f4ee306f0995495ed6dd463818ada, base be4092d7e1f0efe8a16049568c12ec7b841a2e8e; branch perf/selene-parallel-startup-scan; title "selene: parallelize startup disk scan"; labels area:selene, performance, triage:validation; pr_files reports +498 -112 across 3 files: selene/src/shared/record.rs +352/-103, selene/src/input.rs +140/-7, docs/prefix-cache-offload.md +6/-2. Body was rewritten (read_item) to a Why / What changed / Result / Evidence & Limitations structure with the harness source in a <details> block. Merge base is now be4092d7, one commit ahead of the 22d2ac9 base in my prior report.

VERIFIED CODE MAP (head b7bd3fa9):

#19 [high] Charter/AGENTS mapping status after the revision (what is now met, what still applies)

This updates the "Project fit / charter" angle from my prior report (entry #6, as summarised in #11). The charter text itself is unchanged, so the goal mapping stands; only the compliance verdict moves.

#3 [medium] Change: read_metadata callers and cursor semantics (verified)

Callers of Header::read_metadata at PR head (from search_code), and why the new read-ahead is safe:

#16 [medium] Amendment: timing-surface correction and unchanged .input path

Refinement to my prior report's timing-surface finding, verified on head b7bd3fa9: