#1 [high] Subtraction lens findings — PR #576 (affinity pinning)
PR #576 head 4b41ddc4, 7 files +226/−1.
F1 (high) — helios/native/roce_proxy.c:1505-1570 (66 lines) is a line-for-line re-implementation of eos/src/unix.rs:172-210 (77 lines): same len<2 guard, same min==max guard, same cap*10 >= max*9 filter, same midpoint fallback cap*2 > sum, same selected>=2 && selected<count gate. One copy is unit-tested (unix.rs:254-314), the other has no test in either tree. It also edits a file whose own header demands byte-identity: roce_proxy.c:6-8 "Keep the source below identical so preparation and serving share the transport ABI"; NOTICE:16-19; docs/roce-ring.md:361-364. Concrete replacement: export the tested Rust decision as one C-callable symbol (#[no_mangle] pub extern "C" fn flare_prefer_high_capacity_cpus() in eos) and replace the whole helper + both #ifdef blocks (roce_proxy.c:1505-1570, calls at :1574-1577) with a single call, keeping only (void)pthread_setname_np(pthread_self(), "flare-roce");. helios already links flare-eos (helios/src/os.rs:8 pub(crate) use flare_eos::*) and build.rs compiles the C into the same binary, so the symbol resolves. Verify static-lib link order. (After #589/ba3afb13 the same one-line call can live in the Flare-owned helios/native/roce_proxy_dlopen.c, which build.rs:72 compiles instead.)
F2 (medium) — speculative three-tier fallback eos/src/unix.rs:195-204 (+ test :298-314, 17 lines) plus the min_cap accumulator (:176,178,182) exists only for a hypothetical 3-tier SoC; no supported hardware needs it and it fires only when exactly one core is within 10 % of max. AGENTS.md:188-193 bans fallback layers/speculative compatibility without a concrete requirement. Delete :195-204 and the min_cap bookkeeping; keep the final selected.len() >= 2 && selected.len() < allowed.len() gate. Same deletion applies to the C copy (caps[i]*2 > sum branch, roce_proxy.c:1555-1565) — or moot once F1 lands.
F3 (low-medium) — two platform no-op stubs for one function: eos/src/unix.rs:247-248 (#[cfg(not(target_os = "linux"))]) and eos/src/windows.rs:219-220. Collapse into ONE stub in eos/src/lib.rs next to the re-exports: #[cfg(not(target_os = "linux"))] pub fn prefer_high_capacity_cpus() {}, deleting both module-level stubs. This removes windows.rs from the diff entirely — the one file the PR caveat admits was never compiled.
F4 (low-medium) — 4 call sites, 2 outside the claimed workflow: helios/src/execution/worker.rs:71 (ExecutionWorker) and helios/src/replay.rs:174 (ReplayWorker) are reached only from Heliopause/preparation bindings (heliopause/src/python.rs:86, 410-411) and qualification tools (helios/tests/tools/tp4_collective.rs:122, test_runtime_core.rs:71); serving enters through helios/src/server/runtime.rs:568 (single host) and helios/src/execution/parallel.rs:539 (peer rank, called from flare-cli/src/main.rs:560). AGENTS.md:165-169 requires the affected workflow be named; pinning during preparation/capture changes capture placement too, which the evidence does not cover. Either delete the two, or state that capture placement is part of the intent.
F5 (low) — select_high_capacity_cpus is pub and reaches flare-eos' public API via eos/src/lib.rs:12 pub use unix::*, but its only consumer is prefer_high_capacity_cpus in the same file (unix.rs:237) plus tests. Making it private keeps the crate surface unchanged.
Repo pattern checked: eos is the single home for host-OS ops (AGENTS.md:21-22); no pre-existing cpu_capacity/affinity helper anywhere (search_code on cpu_capacity|affinity|sched_setaffinity → only this PR + docs/prefix-cache-offload.md:866 which already says "Adding CPU affinity requires a serving-latency [argument]" — a doc sentence this PR does not update).
#2 [high] Research summary
Completed the Subtraction / Simplicity / Conventions lens on PR #576 (head 4b41ddc4, 7 files, +226/−1). Findings are in scratchpad entry 1 with exact file:line citations, verbatim quotes and concrete replacements.
Headline: the diff is not lean. Its two biggest costs are (1) the affinity-selection algorithm is written twice, once in tested Rust and once as an untested 66-line C copy inside a file whose own header forbids edits, and (2) roughly a third of the added lines exist for hardware the PR does not run on (a three-tier-SoC fallback branch plus its test, and two platform no-op stubs). Beyond that, only two of the four new call sites are on the serving path the evidence covers — the other two are in the preparation/qualification bindings.
Five suggestions, in value order:
- F1 (high) —
helios/native/roce_proxy.c:1505-1570duplicateseos/src/unix.rs:172-210line for line (samelen<2guard, samemin==maxguard, samecap*10 >= max*9filter, same midpoint fallback, sameselected>=2 && selected<countgate). The C copy has no test in either tree, and it breaksroce_proxy.c:6-8("Keep the source below identical"). Replace the whole helper plus both#ifdefcall blocks (:1505-1570,:1574-1577) with a single#[no_mangle] extern "C"call to the tested Rust function — helios already re-exports flare-eos (helios/src/os.rs:8) and links the C into the same binary — keeping only thepthread_setname_np("flare-roce")rename. After #589 this becomes a one-line call in the Flare-ownedroce_proxy_dlopen.cseam thathelios/build.rs:72already compiles. - F2 (medium) — delete the speculative three-tier fallback
eos/src/unix.rs:195-204and its test:298-314(and themin_capaccumulator at:176,178,182): it fires only for a hypothetical SoC with exactly one core within 10 % of max, andAGENTS.md:188-193rejects fallback layers without a concrete requirement. - F3 (low-medium) — collapse the two no-op stubs (
eos/src/unix.rs:247-248,eos/src/windows.rs:219-220) into one#[cfg(not(target_os = "linux"))]stub ineos/src/lib.rs; this also removeswindows.rs— the file the PR caveat admits was never compiled — from the diff. - F4 (low-medium) — two of the four call sites (
helios/src/execution/worker.rs:71,helios/src/replay.rs:174) are reached only through the Heliopause Python bindings and qualification tools, not serving (serving enters athelios/src/server/runtime.rs:568andhelios/src/execution/parallel.rs:539viaflare-cli/src/main.rs:560); delete them or state that preparation-time capture placement is intended. - F5 (low) —
select_high_capacity_cpusescapes into flare-eos' public API (eos/src/lib.rs:12wildcard re-export) with one internal consumer; make it private.
Also noted: docs/prefix-cache-offload.md:863-867 already requires a serving-latency argument before "adding CPU affinity", and this PR updates neither that sentence nor the docs/TODO debt entry; no pre-existing affinity/cpu_capacity helper exists in the repo, so there is no duplicate abstraction beyond the Rust/C pair above.
#3 [high] PR #576 subtraction lens — supporting citations and verdict
Supplement to entry 1 (same PR, head 4b41ddc4, 7 files +226/−1). Nothing here contradicts entry 1.
Verdict for the report: the diff is NOT lean. Two structural costs: (a) the capacity-selection algorithm is implemented twice — once in tested Rust, once as an untested 66-line C copy — and the C copy edits the one file the repo declares untouchable; (b) roughly a third of the added lines serve hardware the PR never runs on (three-tier fallback branch + its test + two platform no-op stubs). Secondary: half the new call sites are off the serving path the evidence covers.
Convention gap (new, worth a line in the report): docs/prefix-cache-offload.md:863-867 already states the project's rule —
"CPU: transfer threads sleep on event waits and channel receives; the disk
thread computes checksums and submits I/O. Both use SCHED_BATCH with a
positive nice value to reduce contention with the model worker, HTTP runtime,
and frontend workers. Adding CPU affinity requires a serving-latency
measurement that shows a benefit."
This PR adds affinity and updates neither this sentence nor docs/TODO.txt (per AGENTS.md:57-60, pending measurements and unresolved defects belong in docs/TODO.txt). Flagged as a documentation-convention omission, not a correctness bug.
Serving call chain for F4 (use these exact lines when saying which two call sites are on-path):
- single-host serving:
helios/src/server/runtime.rs:568inside theflare-modelthread (:565-567). - cross-host peer rank:
helios/src/execution/parallel.rs:539at the top ofserve_rank, reached fromflare-cli/src/main.rs:560(flare_helios::execution::serve_rank(...)) and fromheliopause/src/python.rs:548. - off-path:
helios/src/execution/worker.rs:71(ExecutionWorker::start,:64) andhelios/src/replay.rs:174(ReplayWorker::spawn,:151); their only non-test constructors areheliopause/src/python.rs:86(ReplayWorker::new),:410-411(ExecutionWorker::new_parallel / new), andhelios/tests/tools/tp4_collective.rs:122,156,helios/tests/tools/test_runtime_core.rs:71. - The
pthread_setname_np(pthread_self(), "flare-roce")athelios/native/roce_proxy.c:1575must survive F1:roce_start(:1661-1681,pthread_createat:1674) spawnsproxy_main, so naming the thread from Rust around thread creation is not available — the rename belongs with the one C call that stays.
Ordering to recommend: F1 and F3 together collapse ~70 of the added C/Rust lines; F2 removes another ~24; F4 and F5 are one-line deletions each.