#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:
Header::read_metadata(selene/src/shared/record.rs:355-397): reads into a stack buffer[0u8; HEADER_BYTES + 4096]in a singleread()loop (handles short reads + EINTR), so v3 headers and v4 directories <= 4096 B are covered by one syscall; larger v4 falls back toVec+read_exactfor 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).- New
par_maphelper (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; usesstd::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. record::scan(record.rs:1206-1280) split into collect-candidates →par_mapsymlink_metadata+inspect→ serial reduction that deletes.tmp/invalid files only after noUnreadableerror; thenremove_orphans.Worker::scan(selene/src/input.rs:518-585): collects.inputentries, sorts paths,par_map(inspect), returns the first non-InvalidDataerror before unlinking.input.pendingor mutatingself.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):
- Deletion is now deferred and best-effort-ordered: previously
record::scandeleted.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-scanUnreadableerror 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 inWorker::scanfor.input.pendingfiles (input.rs:548-568) —.pendingfiles used to be deleted as encountered insideread_dir, now only after all inspects succeed. Worker::scannow sorts.inputpaths lexicographically before inspecting (input.rs:552entries.sort()). This is a new deterministic admission order underMAX_DISK_RECORDS/DiskBudget; before, order followedfs::read_dirorder. The description mentions it, but it is a behaviour change in which records survive a tight budget, not just a perf change. Testparallel_scan_recovers_large_directory_deterministically_under_tight_budget(input.rs:1645+) pins the new order.Worker::scanerror selection changed: it reports the first non-InvalidData error by sorted path order, and usesswap_removeon 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.par_mapispub(crate)and lives inshared::record(record.rs:1148).selene-managercannot use it;selene-manager/src/disk.rs::recover(disk.rs:60-108) still does its own sequential per-directoryHeader::read_metadataloop over the first entries to find identity/fingerprint before delegating the actual scan torecord::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.- Symlink handling unchanged:
inspectstill usesfs::symlink_metadataand requiresis_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-1262if !metadata.is_file() { return Inspection::Absent }). - 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 usesread_exact_atat 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)
- record::scan is called with the directory lock held by
DirectoryLock::acquireat selene/src/offload.rs:681-684 and from selene-manager/src/disk.rs::recover (disk.rs:69-108). - The scan itself is timed and reported to operators:
Prepare host prefix cachephase emitson_step("scanning disk records")and storestimings.disk_scan = Some(started.elapsed())(selene/src/offload.rs:750-765);Prepared::summary()appendsscan Z.Zs(added by merged PR #625 "Avoid THP compaction stalls in eos::map_host and report offload startup timings", helios/src/runtime_core/model.rs:1049progress.phase("Prepare host prefix cache")). Documented at docs/prefix-cache-offload.md:1070-1076 ("the record directory, disk limit, scanned record count, staged transport, andscanduration"). => Connection: #625 (merged 2026-12-01) is what makes this PR's target measurable in operator output; #734 does not add metrics of its own (no new counters/gauge;disk_scantiming already existed). InputStore::start_boundedis called from the same function (offload.rs:767-779) and itsWorker::scanruns there, so both timed components are insidePrepare host prefix cache. #734's own limitation note says it times record::scan and InputStore::start_bounded in isolation, not the phase.- docs/prefix-cache-offload.md:677-680 documents the startup scan contract that #734 preserves (reads each header, validates magic/version/identity/fingerprint/name, derives row presence from size, seeds access order from mtime, deletes temporaries and missing-parent nodes). docs/prefix-cache-offload.md:113-116 notes v3 writers/readers prune v4
.ckptfiles during the startup scan (format-compat behaviour the scan must not change).
#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:
- #497 (merged 2026-11-29) "Reduce disk offload restore latency and integrated-memory intake overhead" — added bounded
std::thread::scopeparallel xxh3 page hashing inselene/src/disk.rs(cacheparallel_cpusatWorker::new,MAX_HASH_THREADS = 4,HASH_PARALLEL_MIN_PAGES = 4, inline fallback if a helper can't spawn) and a single-read raw open (header + page checksums in one 4 KiB-aligned transfer). #734 applies the identical pattern to startup scanning (bounded scoped threads, calling thread participates, fallback on spawn failure) plus a coalesced-metadata read. Note #497's coalescing is for the restore path; #734's is for the scan path — complementary, not overlapping. - #496 (merged 2026-11-29) "Coalesce shared ancestor reads across concurrent Selene disk fetches" — also touches
selene/src/shared/record.rs(+119/−1:HeaderHash,packed::LayoutEq/Hash) and is where read coalescing in the fetch path landed. Does not overlapHeader::read_metadataorscan. - Autobot reviews on #496/#497 raised the same themes this PR will likely meet: evidence must name the exact head, isolated component numbers must be labelled as such, spawn-failure fallbacks, and
available_parallelism()policy. #497's review nit explicitly flagged "available_parallelism()per batch" — #734 computes it once perpar_mapcall (record.rs:1149). - Other recent record.rs work: #610 (merged, yatesdr)
fix(selene): fix local storage tier, input cache, sharding, and codec edge cases— touched both changed files (input.rs +129/−29, record.rs +34) and is the last commit on either file (a56333a0, 2026-11-29). #734 builds on that but conflicts with none of it (no commits on main since 22d2ac9 touch these files).
#6 [high] Project fit: matches charter goals; deviates from the served-workload evidence rule
AGENTS.md (repo root) requirements vs. what this PR supplies:
- Performance PRs need served-workload evidence (charter "Bring real evidence": "Performance PRs need benchmarks showing an actual speedup over
mainon a served workload (#210)"). #734's own Limitations say the timings are "isolated component microbenchmarks, not end-to-endflare runstartup timings". So the headline numbers do not meet the letter of the served-workload rule; the change is a startup metadata scan, where a component benchmark may be the only tractable measurement, but the gap should be stated in the case file as a claim/evidence gap. - Four-part PR description (why/what/result/evidence, AGENTS.md:88-112): #734 complies unusually thoroughly, including a p50/p10–p90 table on two architectures, an interleaved A-B-B-A method, and explicit "does not do" notes. It distinguishes component from whole-model results (AGENTS.md:98-100) and states unrun checks (Windows).
- Benchmark reproducibility rule (AGENTS.md:110-112: reproduction commands must identify inputs directly): the harness lives in an uncommitted
selene/examples/scan_bench.rs, not in the diff, andselene/Cargo.toml:57-59only declares therank_nodeexample. So the numbers cannot be reproduced from the branch; they can only be reproduced by pasting the description's code. - Charter goals: "Store prefix-cache checkpoints in host memory and share them across Flare instances via Selene" — squarely in scope; no per-model branch, no new flag, no new dependency, no on-disk/wire change, so no non-goal sign-off needed.
- Guidance to read (AGENTS.md:233): prefix-cache offload / Selene changes require docs/prefix-cache-offload.md, selene-manager/README.md, selene-manager/PROTOCOL.md. #734 changes no docs; docs/prefix-cache-offload.md:677-680 already describes the startup scan contract it must preserve (it does). No doc update is included for the new parallel behaviour, the new thread names, or the changed deletion timing — consistent with the repo's preference for not expanding docs unnecessarily, but worth noting since §2.11 (docs:1070-1076) reports
scanduration that this PR makes much smaller.
#7 [high] Process & community: draft, zero engagement, no CI, no review yet
- Comments/reviews: none.
pr_commentsreturns "No comments" at the time of this case file; no reviews, no reactions, no maintainer engagement yet. - Process state: open and marked DRAFT; head
015076e; no CI checks reported on the head commit. The repo does have a CI job that would exercise this:.github/workflows/native-serving.yml:48-55runscargo test --locked --release --manifest-path selene/Cargo.toml --features test-supporton ubuntu-24.04 and (withouttest-support) on windows-2022, plusselene-managertests on Linux. So the untested-on-Windows caveat the description admits would be partly covered by CI once it runs — the newparallel_scan_handles_large_mixed_v3_v4_directory_deterministicallytest is not#[cfg(unix)]and writes/renames/handles symlinks only under#[cfg(unix)], so it would execute on Windows. - Age: opened and last updated 2026-12-04 (same day as this case file) — very new.
- Author labels applied by triage:
area:selene,performance(notriage:*label yet, unlike #496/#497 which hadtriage:validation/triage:review). - Precedent for process: the author's #496/#497 went through multiple Autobot review rounds (Changes Requested → Ready To Merge) and the author rebased/answered each round; expect the same here once review starts.
#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:
- "9.93x cold / 2.28x warm speedup for
record::scanof 10,000.ckpton 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, control22d2ac9vs candidate015076e, 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. - Cold cells are the strong result (all cold cells have non-overlapping ranges). Warm cells are much weaker:
record::scanwarm 1.38x (500), 1.85x (2000), 2.28x (10000) on x86_64. - One measured regression is declared honestly: warm
InputStore::start_boundedon x86_64 goes2.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). aarch64warm distributions are bimodal and overlap between arms onInputStore; the author says so. Cold ratios on GB10 are ~9–10x.- 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 withrustc1.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. - Claim "all five callers in
seleneandselene-managereither drop the file handle or use positionalread_exact_at" — verified correct (see scratchpad entry on callers): record.rs:1334, disk.rs:1478 (positional reads at disk.rs:1464 and io_uringspan.offset), shard.rs:1200, shard.rs:1251, selene-manager/src/disk.rs:77. - Claim "
0productionunsafe,0new dependencies" — verified: diff adds nounsafe;Cargo.tomluntouched (std::thread::scope/spawn_scopedonly). The onlyunsafein the added code islibc::geteuid()inside a#[cfg(unix)]test (record.rs testparallel_scan_preserves_directory_on_unreadable_entry). - Claim "+105 net non-test production LOC (+135/−30)": not independently recounted;
pr_filesreports +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). - NOT claimed and not measured: any end-to-end
flare runstartup 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. - 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):
- Users/operators: every
flare runwith--prefix-cache-disk(local disk tier) and, in multi-host, every rank process; plus anyselene-managerserving a record root. No configuration, flag, or metric name changes. ThePrepare host prefix cachephase'sscanduration (docs/prefix-cache-offload.md:1070-1076) will shrink, so operator-visible startup timing changes without a docs change. - Compatibility: none broken. On-disk v3/v4
.ckptand.inputformats untouched (diff only reads/writes through existingHeader::encode/packed_metadata), Protobuf/wire untouched, model core loading untouched, noCargo.tomledit..inputHEADERstays 88 bytes (selene/src/input.rs:21).MAX_DISK_RECORDS = 4096(input.rs:26) still caps recovery, but which records survive a tight budget is now path-sorted (input.rs:552). - Deployment: new short-lived threads named
flare-scan(≤16, only when a directory has ≥64 candidates), spawned duringPrepare host prefix cache— i.e. before serving starts, so no interaction with the model worker or CUDA launch threads; no priority change (contrastselene/src/shared/codec.rs:47-54, which nices codec workers). Under a cgroup CPU quotaavailable_parallelism()is quota-aware, so the pool shrinks. - Reach into other crates:
record::scanispuband used byhelios/src/offload/gpu_tests.rs(4 sites),selene-manager/tests/{client,packed}.rs,selene/tests/mixed_codec_root.rs, plus many selene-internal tests — same signature, same ordering guarantee.par_mapispub(crate), so selene-manager cannot reuse it: itsrecoverpre-pass (selene-manager/src/disk.rs:71-98) that finds identity/fingerprint is still sequential per directory (it only delegates the actual scan, selene-manager/src/disk.rs:101). - Threading-model question (not a defect):
selenealready has a rayoncpu_pool(shared/codec.rs:37-60) and scoped threads at disk.rs:605 and pool/startup.rs:241;par_mapuses rawstd::thread+spawn_scopedrather than the existing rayon pool.selene's default feature iscodec(selene/Cargo.toml:13-16), so the evidence's--no-default-featuresrun is the slim/restore-only build. - Serial-path cost where
rayonwas already available: the new code does not consultcpu_pool, so startup scan parallelism is independent of the codec pool's nice(10) policy. - Nothing on
mainsince22d2ac9touches the two changed files; the last change to either was #610 (a56333a0, 2026-11-29), which also reworkedinput.rsscan/eviction error handling — #734's fail-closed changes compose with it rather than reverse it. - Undone/reversed by this PR: nothing. It does not reverse #496 (fetch-path coalescing), #497 (restore-path parallel hashing + single-read raw open), or #610. It is additive, in the startup path only.
- Open issues in the area that this PR does not address: #703 (helios/selene CPU retry storm under DRAM spill saturation), #78 (Engram disk cache first-touch latency), #189 (closed: startup row thinning overflow). None is a startup-scan report — which is why the "why" rests on the description's own argument rather than a filed bug or maintainer request.
#10 [high] Why: the motivation is self-declared, not issue-backed
- The "why" has no filed issue, no linked report, and no maintainer request.
search_itemsfor "startup disk scan recovery parallel", "selene recovery slow startup records", "selene scan ckpt header read latency", and "startup time record directory scan" returns only #734 itself (plus unrelated hits such as #625 and #254). Nothing in the tracker asks for faster startup scanning. So the problem statement is the PR's own: "serial metadata inspection leaves storage queue depth unutilized and stalls startup" for "hundreds to tens of thousands of records". - The nearest adjacent operator-visible startup complaint is #616 / merged PR #625: "v0.4.4 takes over 15 minutes to prepare a 119 GiB host prefix cache on fragmented Linux memory" — that was host slab population, not the record scan, and #625's own fix added the per-step
scanduration that would now show this PR's win. #625's description explicitly separatespopulate/registerfromscan, which is the only place in the repo that treatsscanas a startup cost worth measuring. - Scale argument is checkable:
MAX_DISK_RECORDS = 4096caps the input store (selene/src/input.rs:26) soWorker::scansees at most ~4,096 relevant files per directory; the.ckptrecord directory is bounded only by--prefix-cache-disk-limit(defaultfree_space/10, selene/src/offload.rs:658-664), so tens of thousands of.ckptfiles are plausible — the 10,000-record row of the benchmark is the realistic upper end, and 500 is the common case. - How long it has been wanted: no history of requests. The scan code's sequential shape dates back to the original Selene record store (#92, #141, #168 all touch
record.rs); the only prior latency work in this file family is fetch-side (#496, #497), not startup-side. So this is a first-of-its-kind (in this repo) startup-latency PR.
#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:
- selene/src/shared/record.rs:1334
inspect()— file handle dropped at end ofinspect. - selene/src/disk.rs:1478
Worker::open— keeps the File inRecord::Reading, but later reads are positional:read_exact_at(&mut buf, offset)at disk.rs:1464 and io_uring submits with explicit offsets (span.offset) at disk.rs:2126-2165. So the moved cursor is harmless. - selene/src/shard.rs:1200 and :1251 —
File::openinline, handle dropped immediately. - selene-manager/src/disk.rs:77 —
Header::read_metadata(File::open(entry.path())?), temporary dropped each iteration. So the doc-comment caveat ("callers must not rely on the reader cursor position") holds today, but it is a new public-API footgun on apub fn(record.rs:361), reachable from external crates (helios, selene-manager) with no compile-time guard.