Repository navigation
Description
On a Linux host with transparent huge pages (THP) and THP defragmentation both set to madvise, FLARE v0.4.4 spent 914.6 seconds in Prepare host prefix cache. The disk namespace was empty. With THP still enabled in madvise mode and defragmentation set to defer from process launch, the same signed core prepared the same-sized cache in 71.1 seconds. During the slow startup, tools inspecting processes on the host also became slow to respond.
Observations
| Runtime | THP defragmentation during startup | Disk records staged | Host-cache phase |
|---|---|---|---|
2bdc8472, previous deployment |
madvise |
5,244 | 131.8 s |
| v0.4.4, first private start | madvise |
0 | 914.6 s |
| v0.4.4, second private start after clearing the filesystem page cache | madvise initially, switched to defer after about 18 minutes |
959 | 1,279.5 s |
| v0.4.4, production start | defer throughout |
965 | 71.1 s |
All starts used a 119.4 GiB host prefix cache with 133,790 slots. The three v0.4.4 runs used the same executable and signed core. Host load varied between runs. The v0.4.4 runtime carries a local retry for sealing the embedding-table memfd. Its allocator and Selene slab code match the release tag.
Linux reported abundant available memory. During the second slow start, both NUMA nodes' Normal zones had zero free 2 MiB blocks in a /proc/buddyinfo sample. The partially populated slab had over 52 GiB of anonymous huge pages in /proc/PID/smaps. Direct-compaction stalls were rising. After the operator changed the defragmentation policy, the process finished populating the slab. Near the end of the same journal phase, eight consecutive main-thread samples showed an ioctl on an NVIDIA device. These runs did not time population and device registration separately.
Environment and reproduction
- Linux
7.0.0-42-generic, 4 KiB base pages, two NUMA nodes, two discrete RTX PRO 6000 Blackwell GPUs. - FLARE v0.4.4 at
993396063fe8. The Qwen TP2 C32 MTP core uses RAM for the embedding table,--prefix-cache-memory 128Gand an enabled local disk tier. - On a similarly fragmented test host, capture the THP enablement and defragmentation settings, the Normal-zone free-block counts, and the
Prepare host prefix cacheelapsed time when starting the same core. The first v0.4.4 result above occurred with zero disk records, so a large persisted cache is unnecessary to observe the delay.
Suspected cause and expected behavior
PR 589 changed eos::map_host from populating the mapping before advising huge pages to issuing MADV_HUGEPAGE before MADV_POPULATE_WRITE. Selene uses this function for the contiguous host slab. On Linux, madvise defragmentation permits synchronous reclaim and compaction for a huge-page-advised range. The ordering and observations are consistent with compaction delaying initial population. They do not quantify its share of the full journal phase. Allocator change · Tagged allocator · Selene slab · Linux THP policy
Could the large slab use an allocation strategy that falls back promptly to base pages when contiguous huge pages are scarce? Separate startup timings for slab population and CUDA registration would also make this regression easier to diagnose. Our working mitigation changes the host-wide THP defragmentation policy, which also affects unrelated workloads.
Activity
flare-autobot commentedon Nov 30, 2026
Verified on
origin/main(493f24c3).Root Cause
In
eos/src/unix.rs:85-119,map_hostcreates an anonymous mapping, unconditionally advisesMADV_HUGEPAGEover the entire range, and prefaults it in a singlemadvise(MADV_POPULATE_WRITE)syscall. Contiguous host prefix-cache slabs (SlabPool::newinselene/src/slab.rs:162-178, invoked fromselene/src/offload.rs:642-658whenever disk offload, pool sharing, KV compression, or non-VMM fallback is active) and remote pool staging (Region::anonymousinselene/src/pool/shm.rs:74-86) both allocate througheos::map_host.Under Linux transparent huge pages (THP) configured with
defrag=madvise(ordefer+madviseoralways), advisingMADV_HUGEPAGEbeforeMADV_POPULATE_WRITEenables synchronous direct reclaim and compaction whenever contiguous PMD-sized (2 MiB on 4 KiB kernels) blocks are unavailable. Faulting a 119 GiB mapping in one call keepsmmap_lockheld across sustained compaction stalls and amplifies host-wide contention. In addition,NativeModel::prepare_offload(helios/src/runtime_core/model.rs:924-981) ran slab population, CUDA host registration, and disk record scanning insidePrepare host prefix cachewithout intermediate step details or separate elapsed timings inPrepared::summary()(selene/src/offload.rs:400-444).Implemented Fix
All cache schemes and contiguous host-slab offload configurations share
eos::map_hostandselene::offload, so the fix applies across every supported model contract without model-specific paths, runtime flags, or environment variables:eos/src/unix.rs):map_hostrejectsbytes == 0withEINVAL, wraps the anonymous mapping in an RAIIMappingGuardthat callsmunmapon population failure, retriesMADV_POPULATE_WRITEonEINTR, falls back to page-strided volatile writes only onEINVALorENOSYS, and propagates fatal errors.map_hostinspects/sys/kernel/mm/transparent_hugepage/{enabled,defrag,hpage_pmd_size}(deriving portable 2 MiB / 32 MiB / 512 MiB PMD defaults for 4 KiB / 16 KiB / 64 KiB kernels whenhpage_pmd_sizeis unreadable):enabled=never: populates in bounded 64 MiB base-page chunks without THP advice.defrag=deferornever: advisesMADV_HUGEPAGEupfront and populates in bounded 64 MiB chunks.enabled=alwayswithdefrag=madviseordefer+madvise: omitsMADV_HUGEPAGEand populates in bounded 64 MiB chunks via the kernel's opportunistic path.enabled=madvisewithdefrag=madvise|defer+madvise|always, orenabled=alwayswithdefrag=always, or unknown policy): pre-anchors one sharedanon_vmaon the unsplit mapping, walks growing PMD-aligned chunks up tomax(16 MiB, hpage_pmd_size)while checking order-weighted free huge pages in/proc/buddyinfo, chunk fault latency thresholds, and/proc/vmstatcompact_stall, falls back promptly to 64 MiB base-page chunks when free huge pages are low or compaction stalls begin, and issues a final whole-rangemadvise(MADV_NOHUGEPAGEafter fallback,MADV_HUGEPAGEotherwise) so Linux merges all sub-VMAs back into one contiguous VMA beforecuMemHostRegister_v2oribv_reg_mr.selene/src/offload.rs,helios/src/offload/mod.rs,helios/src/runtime_core/model.rs,docs/prefix-cache-offload.md):PrepareTimings(slab_populate,cuda_register,disk_scan), exposesprepare_with_inputs_budget_with_progress(preserving existing signatures), updates livephase.detail(...)labels duringPrepare host prefix cache(including resetting step and timer when split-by-rank VMM allocation falls back to a contiguous slab), and appendsallocate,populate,register, andscandurations insidePrepared::summary()while leaving restore-only and disabled summaries unchanged.Verification & Unrun Checks
Two-NUMA x86_64 Linux 6.8.0-151-generic + discrete NVIDIA RTX PRO 6000 Blackwell Max-Q (SM120) (4 KiB base pages, 2 MiB
hpage_pmd_size, THPenabled=madvise,defrag=madvise, initial free huge pages ~12.4 GiB across bothNormalzones out of 236.8 GiB available RAM):eos: 11/11 tests passed;selene(--features test-support): 552 unit + 1 integration tests passed.eos::map_hostvs priorMADV_HUGEPAGE+ singleMADV_POPULATE_WRITE) and discrete SM120cuMemHostRegister_v2+ DMA round-trip:compact_stall+62, 1 merged VMA,AnonHugePages=2,046 MiB,VmFlagsnh) vs 128.56 s (compact_stall+25,654) on the prior path (4.15x faster);cuMemHostRegister_v2(48 GiB, PORTABLE)9.48 s (rc=0), 4 MiB head->SM120->tail DMA round-trip passed.AnonHugePages=43,230 MiB, 90% huge pages, 1 VMA).eos::map_host(119 GiB)): populate 57.19 s (compact_stall+2,031, 1 merged VMA,AnonHugePages=43,454 MiB,VmFlagsnh) +cuMemHostRegister_v2(119 GiB, PORTABLE)11.27 s (rc=0, 68.46 s combined), 4 MiB head->SM120->tail DMA round-trip passed.Linux ARM64 SM121 (NVIDIA GB10, Linux
7.0.0-1025-nvidia, THPenabled=madvise,defrag=madvise):eos: 11/11 tests passed, including live/proc/self/smapssingle-VMA merging on both normalmap_hostand forced mid-mapping fallback (adaptive_mid_mapping_fallback_merges_into_single_vma).selene(--features test-support): 552 unit + 1 integration tests passed (including 4 offload timing and progress-step tests);selene --tests --features rdmacompiled cleanly.selene-manager(--features test-support): 412 passed across 11 binaries (1 ignored) and 11/11 passed ontests/pool_store.rsfollow-up (one pre-existing timing-ratio testa_freed_window_credit_is_granted_without_waiting_for_the_clockflaked identically on unmodified parent commit59adc480).helios(--features runtime-core,serverwith prepared frontend templates): 1,753 lib and 62 integration tests passed;flare: 245 passed;flare-cli: 228 passed.FLARE_RUN_CUDA_TESTS=1on NVIDIA GB10):host_registration_unregisters_when_dropped_on_another_threadandbatched_copies_round_trip_through_registered_memoryboth passed, and a directcuMemHostRegister_v2+ H2D/D2H check passed on pure-THP (16 MiB, 1 VMA), pure-base-page (16 MiB, 1 VMA), and mixed THP-prefix plus base-page-tail merged allocations (32 MiB, 1 VMA,AnonHugePages=8192 kB,VmFlagsnh).Unrun checks:
flare runwith--prefix-cache-memoryand--prefix-cache-diskandtests/server/test_prefix_cache_offload.py(the discrete SM120 host lackedcmakefor nativeturbojpeg-sysbuilds, and the SM121 host had no exported cores).ibv_reg_mrregistration, 16 KiB/64 KiB ARM64 Linux kernels, and kernels withoutCONFIG_TRANSPARENT_HUGEPAGE(covered by deterministic parser and policy unit tests only).A companion pull request containing this fix is open at #625.