Explore report · NVIDIA/hyperflare-inference #625

Raw Markdown for agents: https://autobot.eidonix.com/p/abd8ca39-5532-4852-a095-1af3dc438195.md

Author: flare-autobot (COLLABORATOR; bot account, no standalone PR/issue history in 180 days; commit authored by "derek"); Discord: flare-autobot Motivation: Serving a model with a big host prefix-cache slab can take over 15 minutes to start on Linux when physical memory is fragmented, because the allocator asks the kernel for huge pages and then faults them all in at once, forcing synchronous memory compaction. This PR makes the allocator check the kernel's huge-page policy and fall back to ordinary pages promptly, and it adds per-step startup timings so operators can see where the startup time goes. Scale: +1,471 / −111 lines in 6 files Proposal:


Case file: PR #625 — Avoid THP compaction stalls in eos::map_host and report offload startup timings

Repository: NVIDIA/hyperflare-inference · Head commit 9639e57 · Base main · Branch fix/issue-616-host-slab-thp-fallback-timings (parent 59adc480, #540) · Opened 2026-11-30, state ready for review, single commit · Fixes #616.

Key findings

  1. This is a one-day-old regression fix against a merged maintainer PR, not a new feature. Issue #616 (open, P2, labels area:memory, area:preparation, area:selene, bug, performance, triage:investigate) reports 914.6 s in Prepare host prefix cache for a 119.4 GiB slab (133,790 slots), versus 71.1 s with defrag=defer. It attributes the regression explicitly to merged PR #589 (Luke Alonso, 2026-11-28 22:18), whose eos/src/unix.rs hunk replaced MAP_POPULATE with madvise(MADV_HUGEPAGE) followed by one madvise(MADV_POPULATE_WRITE). #625 rewrites that same function (+1008/−54) while keeping #589's intent (huge pages when available) — so it builds on, and partially reverses, work merged two days before it.
  2. Undeclared behaviour changes in the allocator. The description frames chunking as part of the synchronous-compaction strategy, but POPULATE_CHUNK_BYTES = 64 MiB applies to every policy and to non-Linux Unix (eos/src/unix.rs:88, populate_chunks :462, non-Linux branch :671-679). Error handling is also reversed: previously any MADV_POPULATE_WRITE failure silently fell back to volatile writes; now only EINVAL/ENOSYS fall back and everything else propagates (:446-453), and the mapping is munmaped (MappingGuard drop, :173) — SlabPool::new turns that into a hard invalid("allocate host slots: …") (selene/src/slab.rs:164-165). That new failure mode is not in the description's compatibility section.
  3. Side effects of putting kernel introspection inside the allocator. map_host now reads /sys/kernel/mm/transparent_hugepage/*, /proc/buddyinfo and /proc/vmstat on every call (eos/src/unix.rs:383, :272, :572), including for 4 KiB/8 KiB test pools and for pool staging via Region::anonymous (selene/src/pool/shm.rs:78). After a mid-slab fallback the final whole-range advice is MADV_NOHUGEPAGE even when the policy did not need it, because the branch compares only fell_back (:611-616) — so THP hints are dropped for the whole slab, head included. When both ends are PMD-aligned the code shrinks the huge-page interior by one PMD (:542-550), so the last PMD of such slabs is always base pages.
  4. Claims are backed in code but the headline numbers are unverifiable from the repository. Every mechanism in the description matches the code (see the claim table below), and the test counts cited are consistent with CI's job list. But the 128.56 s → 30.99 s (4.15x) and 57.19 s + 11.27 s figures come from a standalone map_host + cuMemHostRegister_v2 harness on the author's two machines; no script, raw log or flare run end-to-end timing is committed, and the description itself says "Expected benefit (not yet timed inside a live flare run launch)". The charter requires performance PRs to show "an actual speedup over main on a served workload (#210)", so this is the central evidence gap.
  5. No engagement at all. Zero comments, reviews, inline comments, reactions, labels, assignees or requested reviewers. Issue #616 has exactly one comment — the bot's copy of the PR description. Sibling bot PRs (#589, #576) drew an Autobot Review within ~90 minutes and #576 a human CHANGES_REQUESTED; #625 has had neither.
  6. CI failed on head 9639e57, cause not determinable from the repo. Both native-serving.yml (Linux x86_64 + windows-2022 + rdma) and helios-lifecycle.yml (path filters include eos/**, selene/**) apply. There is no cargo fmt/clippy gate in any workflow. My working hypothesis that the new map_host_rejects_zero_bytes_with_einval test breaks on windows-2022 is wrong: eos/src/unix.rs is compiled only under #[cfg(unix)] (eos/src/lib.rs:9-12), so neither that test (:816) nor mapping_guard_unmaps_on_population_error (:822) builds on Windows, and eos/src/windows.rs:166 is untouched. The failing job and log were not accessible with the available tools.

The change

Size and shape (all six files, pr_files):

File Diff Content
eos/src/unix.rs +1008/−54 map_host rewrite: policy detection, adaptive chunked population, MappingGuard, ~440 lines of new unit tests
selene/src/offload.rs +139/−47 PrepareTimings, prepare_with_inputs_budget_with_progress, on_step plumbing, summary() durations
selene/src/offload/tests.rs +274/−0 four new tests: split-by-rank, split-fallback-to-contiguous, contiguous+disk, restore-only
helios/src/offload/mod.rs +24/−3 re-export PrepareTimings; prepare_with_inputs_budget now forwards to the new function with `
helios/src/runtime_core/model.rs +2/−1 pass |step| phase.detail(step) into the new call
docs/prefix-cache-offload.md +24/−6 §2.5 population strategy, §2.11 startup phase summary

Verified mechanics in eos/src/unix.rs (post-change):

What the description does not say (beyond findings 2–3 above): the heuristic constants are compile-time only — no CLI flag, config key, env var or metric exposes 64 MiB / 16 MiB / 15 ms / 50 ms / 1 GiB/s / 256 MiB/s / total÷16 min 32 (.github/docs confirm no new key; docs/prefix-cache-offload.md:985-986 still says [prefix_cache] rejects unknown keys). Public Rust surface grows additively: Prepared::timings (selene/src/offload.rs:368), PrepareTimings (:331-340), prepare_with_inputs_budget_with_progress (:594; helios wrapper helios/src/offload/mod.rs:101), re-exported at helios/src/offload/mod.rs:30-31. The startup log line changes shape: memory X GiB (N slots, populate 12.3s, register 4.8s) · disk DIR (limit L, N records, staged, scan 0.9s) (asserted at selene/src/offload/tests.rs:1189-1193, :1246-1248, :1304-1310).

What the description says that the code does not quite do: nothing material was found — the description's technical claims all check out (claim table below). The one framing gap is scope: "advises MADV_HUGEPAGE once upfront and populates in bounded 64 MiB chunks" is presented as the defrag=defer|never behaviour, but the 64 MiB chunking is universal, so readers may underestimate how much of the old path changed for all hosts.

The why

Recent activity

Chronology around #625's base (59adc480 = #540, 2026-11-29):

People

Community

Project fit

Claims and evidence

Claim Verified? Citation
map_host(bytes: usize) -> io::Result<usize> unchanged Yes eos/src/unix.rs:664
bytes == 0 → EINVAL Yes :656-658; test :816
MappingGuard munmaps on population error Yes Drop :173; test :822-831
EINTR retry; volatile fallback only on EINVAL/ENOSYS Yes :446-453
sysfs THP/PMD parsing, 2/32/512 MiB portable defaults Yes :228-240, :383-398; tests :834+
24-cell (enabled, defrag) matrix Yes — 4 enableds × 6 defrags test :866-930
Growing PMD-aligned chunks up to max(16 MiB, hpage_pmd_size) Yes :558, :596
stall_floor = max(15 ms, bytes/1 GiB/s), hard_ceiling = max(50 ms, bytes/256 MiB/s) Yes :348-360; classification test :1040-1046
compact_stall re-sampled only when latency in (floor, ceiling] Yes :581-595
Fallback below chunk_hugepages + (total/16).min(32) Yes :343
Final whole-range advice to merge sub-VMAs Yes :611-616; smaps tests :1050-1075, :1077-1141, :1143+
PrepareTimings { slab_populate, cuda_register, disk_scan: Option<Duration> } Yes selene/src/offload.rs:331-340, field :368
prepare_with_inputs_budget_with_progress(..., on_step: impl FnMut(&str)) Yes selene/src/offload.rs:594; helios helios/src/offload/mod.rs:101
Step/timer reset on split→contiguous fallback Yes — steps asserted as allocating / populating / registering selene/src/offload/tests.rs:1230-1240
Summary adds allocate/populate, register/scan Yes tests :1189-1193, :1242-1250, :1304-1310
Restore-only and disabled summaries byte-for-byte unchanged Yes tests :1347, :1375, :255
Phase label and StartupStage::PrepareHostPrefixCache unchanged Yes helios/src/runtime_core/model.rs:934; helios/src/startup.rs:41,82; phase.detail pre-existing :325
No Protobuf/model-core/serving-ABI change Consistent — diff touches no .proto or core-format code pr_files
128.56 s → 30.99 s (4.15x); 48 GiB in 13.78 s; 119 GiB populate 57.19 s + register 11.27 s; compact_stall +25,654 → +62 Author-supplied, not reproducible from the repo — no harness, raw logs or machine setup committed description
Served-workload speedup Not claimed — description says "Expected benefit (not yet timed inside a live flare run launch)" description
Test suites cited (eos 11, selene 552+1, helios 1753+62, flare 245, flare-cli 228, selene-manager 412) Counts are plausible and match the CI job list; not re-run here native-serving.yml:47-77

Note on test strength: map_host_advises_hugepages_and_prefaults_zeroed_pages (eos/src/unix.rs:1077-1141) was rewritten to branch on the detected policy, asserting hg only in EagerHugepage, and hg-or-nh in adaptive mode — so its VmFlags assertion is policy-dependent rather than a fixed expectation. The fallback path is exercised deterministically by adaptive_mid_mapping_fallback_merges_into_single_vma (:1143+) through a synthetic read_buddyinfo_free_hugepages closure (returns u64::MAX then 0).

Reach

Process

Open questions / not found

  1. Which job failed on 9639e57, and why. Not retrievable here; both workflows apply, and no formatting gate exists, so the failure is likely a real test/compile failure on one matrix leg (Linux native, Windows native, rdma, or helios-lifecycle).
  2. Whether the strict error propagation (non-EINVAL/ENOSYS now fatal) can turn a previously recoverable ENOMEM under memory pressure into a startup failure in practice — the description does not discuss it and no test covers the fatal path end to end beyond mapping_guard_unmaps_on_population_error's synthetic ENOMEM.
  3. What the served-workload effect actually is: no flare run timing exists for either main or the branch (acknowledged in the PR). The charter's #210 requirement is therefore unmet by the evidence as filed.
  4. Whether the final MADV_NOHUGEPAGE over the whole range after a mid-slab fallback has any measurable cost for slabs that already got huge pages at the head (measured AnonHugePages=2,046 MiB retained, so populated huge pages are not split back, but no study of subsequent growth is cited).
  5. Whether selene-manager/src/arena.rs:93's unconditional MADV_HUGEPAGE will be brought in line; not in this PR's scope and not mentioned anywhere.
  6. Interaction with #323's pending signature refactor of prepare_with_inputs* and with #576's additions to eos/src/unix.rs — neither has been reconciled.