#1 [high] S1: selector can be 7 lines, three branches are dead or speculative
eos/src/unix.rs:188-226 select_high_capacity_cpus is 39 lines; a 6-7 line equivalent preserves every reachable behavior.
(a) DEAD: eos/src/unix.rs:201-203
if min_cap == max_cap {
return None;
}
Provably unreachable in effect: when min==max every CPU passes the 90% filter, so selected.len() == allowed_with_capacity.len(), and the final guard at :221 (selected.len() < allowed_with_capacity.len()) already returns None. Deleting the block changes no result, in any input, with or without the fallback below.
(b) SPECULATIVE: eos/src/unix.rs:211-220
if selected.len() < 2 {
// Avoid collapsing multiple busy threads onto a single prime core on
// three-tier topologies: fall back to all cores above the capacity midpoint.
let sum = u64::from(min_cap) + u64::from(max_cap);
selected = allowed_with_capacity
.iter()
.filter(|&&(_, cap)| u64::from(cap) * 2 > sum)
.map(|&(cpu, _)| cpu)
.collect();
}
Only reachable on a topology with >=3 distinct capacity tiers where <2 CPUs are within 90% of the max — not the GB10 two-tier part this PR targets, not any hardware the PR qualifies (718..731 vs 997..1024, 10 top CPUs). On GB10 selected is always 10, so deleting the branch keeps GB10 behavior bit-identical and turns hypothetical 3-tier hardware into the existing no-op. AGENTS.md:188-193: "Do not add ... speculative compatibility, fallback layers ... without a concrete requirement." With (a) and (b) gone, min_cap becomes unused (it is read only by :198, :201 and :214), so the whole min-tracking pass goes.
(c) UNREACHABLE guard: eos/src/unix.rs:195-197
if cap == 0 {
return None;
}
The only producer (prefer_high_capacity_cpus, :241-252) returns early when the sysfs file cannot be read or parsed (:244-249) and only reads CPUs set in sched_getaffinity, i.e. online CPUs; CPU capacity for an online CPU is positive. Its test case [(0, 0), (1, 1024)] (:311) returns None anyway via the >= 2 guard (min=0, max=1024, midpoint 512 selects only cpu 1).
Replacement (whole body, ~7 lines):
pub fn select_high_capacity_cpus(allowed_with_capacity: &[(usize, u32)]) -> Option<Vec<usize>> {
let max_cap = allowed_with_capacity.iter().map(|&(_, cap)| cap).max()?;
let selected: Vec<usize> = allowed_with_capacity
.iter()
.filter(|&&(_, cap)| u64::from(cap) * 10 >= u64::from(max_cap) * 9)
.map(|&(cpu, _)| cpu)
.collect();
(selected.len() >= 2 && selected.len() < allowed_with_capacity.len()).then_some(selected)
}
len() < 2 early return (:189-191) is then subsumed by selected.len() >= 2.
Test fallout: select_high_capacity_cpus_avoids_single_core_collapse_on_three_tier_soc (:314-330) exists only for (b) and must be deleted with it; the two other tests (:270-312) keep passing unchanged.
#5 [high] Research summary
Subtraction/Simplicity/Conventions review of PR #576 complete. Findings are saved in scratchpad entries 1–4.
Main finding (high): eos/src/unix.rs:188-226 select_high_capacity_cpus is 39 lines that reduce to ~7 without changing any reachable behavior. Three pieces can go: (a) the min_cap == max_cap early return at :201-203 is dead — when min==max every CPU passes the 90% filter, so the final selected.len() < allowed_with_capacity.len() guard at :221 already returns None; (b) the midpoint fallback at :211-220 is speculative — reachable only on ≥3-tier topologies with <2 CPUs within 90% of max, not the GB10 two-tier part the PR targets and not any hardware it qualifies, so it fails AGENTS.md:188-193 ("no fallback layers ... without a concrete requirement"); (c) the cap == 0 guard at :195-197 is unreachable from the only producer (:241-252 returns early on read/parse failure and only reads online CPUs). With those gone, min_cap and the min-tracking pass disappear too. The replacement body is quoted verbatim in the scratchpad, and the three-tier test at :314-330 must be deleted with (b).
Second (medium): helios/native/roce_proxy.c:1505-1570 re-implements exactly the same policy in C, carrying the identical dead min_cap == max_cap half (:1543) and identical midpoint fallback (:1555-1565). Because the file is a vendored witness (:8, NOTICE:16-19, roce_proxy_dlopen.c:7-9), the C side should stay verbatim and only the Rust side should be trimmed — but then the PR's "verified equivalent" claim needs a note, since the two would differ in the fallback.
Checked and cleared: the five prefer_high_capacity_cpus() call sites are five genuinely distinct threads (verified each spawn site), so the one-line repetition is forced by Linux affinity inheritance, not gratuitous duplication. The Windows stub eos/src/windows.rs:218-220 is required by eos/src/lib.rs:9-16's whole-module cfg selection. No leftover flags, config knobs, dead imports or test scaffolding in the diff. Two minor trims recorded: the unix non-Linux stub can be folded into the body's cfg, and select_high_capacity_cpus need not be pub (its only caller and users are in-file). One comment (helios/src/server/runtime.rs:721-723) over-claims a property the code does not have and should be trimmed, not extended.
#6 [high] S5: verdict, ranking, and surfaces cleared as lean
VERDICT: the diff is lean except for one function. Four suggestions, ranked: S1 (high, eos/src/unix.rs:188-226 → ~7 lines) >> S2 (medium, C copy carries the same two removable branches, but the file is a vendored witness so the C side must stay) >> S3 (medium, no merge available across the 5 threads; trim the over-claiming comment) > S4 (low, two cosmetic surface trims). Everything else in the 8-file, +230/−1 diff is one-line call sites, a 3-line Windows stub, and a self-contained C function — nothing else to delete.
CLEARED, with evidence, so the report does not need to re-derive:
- No new flag, config-file key, env var, or Cargo feature: the diff touches only 8 files (per PR body) and none is
Cargo.toml,flare-cli/src/cli.rs, or a config schema. AGENTS.md:452-460 ("never read an environment variable to choose behavior"; settings live in recipe/config/flag) is satisfied — the behavior is unconditional, which is itself the separate criticism the Correctness lens owns, not a subtraction finding. - No new dependency:
flare_eosis already a dependency of helios (helios/src/os.rs:8pub(crate) use flare_eos::*;), and ~20 existing sites call throughcrate::os::(helios/src/cuda.rs:454,helios/src/offload/transfer.rs:282,helios/src/runtime_core/protection.rs:356, etc.). The five new sites could have usedcrate::os::prefer_high_capacity_cpus()for local consistency instead of the crate path; cosmetic only, do not raise it as a finding. - No build-system work needed:
helios/build.rs:69-74already rebuilds and compilesnative/roce_proxy_dlopen.c, which#includesroce_proxy.cat:236; the new C function needs no build change. - No dead code beyond S1's three branches: no unused
use, no test-only scaffolding, no speculative pub API other thanselect_high_capacity_cpus(S4). The#ifdef __linux__guards (roce_proxy.c:1505,:1570,:1574) match the file's existing style, andhelios/src/execution/roce.rs:23PROXY_ABI = 14is untouched, so no ABI churn. - Tests are proportionate, not removable: 3 unit tests, ~60 lines, pin the two-tier split, the three no-op classes, and the (to-be-deleted) three-tier fallback. Only the third goes, with S1. No test asserts on the affinity syscall itself, so deleting S1's fallback needs no other test edit; the two survivors at
eos/src/unix.rs:270-312keep passing against the 7-line replacement. - No duplication against an existing repo helper:
search_codeforsched_setaffinity|sched_getaffinity|cpu_capacity|CPU_SETreturns no prior affinity helper anywhere (eos/srchad none; hits elsewhere areavailable_parallelism()sizing inselene/src/shared/codec.rs:41,selene/src/disk.rs:732,helios/src/frontend/mod.rs:334, and Pythonos.sched_getaffinityinignition/preparation/host_memory.py:31for worker budgets, not placement). There is nothing to reuse; the new helper is genuinely new, which is why S1 is about trimming it, not replacing it. - No structural AGENTS.md violation of the maintainability kind: the placement decision (defer past child spawn) is documented at the call site (
helios/src/server/runtime.rs:721-723), module boundaries are respected (eoskeeps the OS primitive, Helios calls it), and no module gains a new responsibility. The doc/witness obligations AGENTS.md anddocs/TODO.txt:80-86impose are the Correctness/Docs lenses' findings (A3), not duplication findings.
#2 [medium] S2: C hunk re-implements the same policy, fallback included
helios/native/roce_proxy.c:1505-1570 is a second, independent copy of the same 90%-of-max policy: pin_high_capacity_cpus (~65 lines of C) mirrors eos/src/unix.rs:188-226 field for field, including the same two items from S1:
helios/native/roce_proxy.c:1543if (count < 2 || min_cap == max_cap) { return; }— themin_cap == max_caphalf is dead for the same reason as the Rust one (if min==max,selected == count, so:1566selected < countalready skips the call).helios/native/roce_proxy.c:1555-1565the midpoint fallback, reachable only on hypothetical 3+-tier hardware.helios/native/roce_proxy.c:1534val == 0mirrors the unreachable Rust zero guard.
Constraint that changes the recommendation: the file is a vendored witness (helios/native/roce_proxy.c:8 "Keep the source below identical", NOTICE:16-19, helios/native/roce_proxy_dlopen.c:7-9, docs/roce-ring.md:361-364). If the hunk is verbatim from flashinfer#156 (335459b2) it must stay as upstream wrote it, so S1 should be applied to the Rust side only — but then the two implementations differ in the fallback and that must be stated, since the PR body claims the Rust selector is "verified equivalent" to the C one. Cheapest resolution: keep the C verbatim, delete the unreachable/speculative branches on the Rust side, and note the divergence in the body or a comment.
Secondary C cost, only if the hunk is Flare-authored rather than vendored: int cpus[CPU_SETSIZE]; uint32_t caps[CPU_SETSIZE]; (:1516-1517) is 8 KiB of stack for two parallel arrays that a single pass over next/allowed would not need.
#3 [medium] S3: five call sites are five real threads - no merge available
Verified the five call sites are five distinct OS threads, so there is no site to merge; each is one line and correctly placed after that thread's resource setup:
helios/src/server/runtime.rs:724—flare-modelthread (spawn :566-568), after RankExecutor::new (:585), offload open (:684-707), ImagePreparation::new (:719).helios/src/execution/worker.rs:86—flare-executionthread (spawn :68-70), after RankExecutor::new (:75).helios/src/execution/threaded.rs:683— eachflare-rank-{index+1}thread (spawn :668-670), after GraphExecutor::new_unstarted (:672). Needed separately becauseRankExecutor::newforRankPeers::Threads(helios/src/execution/ranks.rs:34-37) spawns these on the (still unnarrowed) worker thread.helios/src/execution/parallel.rs:573—serve_rankpeer main thread, after GraphExecutor::new_unstarted (:563).helios/src/replay.rs:174—flare-cudathread (spawn :171-173), first statement of the closure.
Note: this per-thread placement is forced by the deferral design, because Linux affinity is inherited by children — a single process-wide pin would leak onto the KV-codec/disk/image-prep threads the PR deliberately keeps unnarrowed. So the 5× repetition of one call is the price of the approach, not gratuitous duplication. Pinning inside selene/src/shared/codec.rs's pool workers + selene/src/disk.rs would instead be the alternative shape, and is what fixes the A1 defect.
Small subtraction here: helios/src/server/runtime.rs:721-723
// Narrow affinity only after RankExecutor, host offload/codec/disk, and image
// preparation child threads have been spawned so background workers stay free
// to run on efficiency cores and observe the full process cpuset.
asserts a property the code does not have (the lazily built flare-kv-codec-{i} pool from selene/src/shared/codec.rs:37-60 is created later, on this already-narrowed thread, and inherits the narrowed mask). Either delete the second sentence or fix the behavior; do not extend the comment.
#4 [low] S4: stub pair + pub visibility - small surface trims only
prefer_high_capacity_cpus needs two bodies only because eos/src/lib.rs:9-16 selects unix vs windows as whole modules (#[cfg(unix)] mod unix; pub use unix::*;). The Windows stub is therefore required (eos/src/windows.rs:218-220) — a Helios caller cannot be #[cfg(unix)]-gated because helios/src/replay.rs, worker.rs, parallel.rs, threaded.rs, server/runtime.rs call it unconditionally. NOT removable.
But the unix-side stub is removable by moving the cfg inside the body: replace eos/src/unix.rs:231 #[cfg(target_os = "linux")] + :263-264
#[cfg(not(target_os = "linux"))]
pub fn prefer_high_capacity_cpus() {}
with a single
pub fn prefer_high_capacity_cpus() {
#[cfg(target_os = "linux")]
{ /* ... */ }
}
Saves a duplicated signature; only matters for macOS-class cfg(unix) targets that no CI builds.
Separately: eos/src/unix.rs:188 pub fn select_high_capacity_cpus(...) — its only caller is prefer_high_capacity_cpus (:253) and its only other users are the tests in the same file (eos/src/unix.rs:267 mod tests). Because of pub use unix::* (eos/src/lib.rs:12) it becomes part of flare_eos's public surface for no consumer. Make it private (fn), and the crate gains no API it does not use. Same argument applies to nothing else in the diff.
Dead/duplicated code check on the rest of the diff: no unused imports added (flare_eos already a dependency of helios, helios/src/os.rs:8 re-exports it as crate::os::*, so the five sites could equally have been written crate::os::prefer_high_capacity_cpus() for consistency with the ~20 existing crate::os:: call sites — cosmetic, not worth a change). No leftover flags, no config knobs, no test-only scaffolding. The #ifdef __linux__ guards in C (:1505, :1570, :1574) match the file's existing style.