[GH-ISSUE #4064] [Engine] Cold-start profile fill is single-threaded: 336 s of an 8.75-minute start with all workers idle #1763

Closed
opened 2026-11-04 01:53:50 +07:00 by bsakaguchi · 7 comments
Owner

Originally created by @chenyb999-zhcn on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4064

Area

Engine (from source / Terminal: strata --serve … --layer-split auto, CUDA1 verify-stage profile fill)

Reproduction status

Reproduced locally, on my own machine, with a strace -f capture I ran myself against the live startup.

Desktop app, Terminal or source?

Source (a build) — the strata engine binary built from source, launched as strata --serve … --layer-split auto

Strata version

Reported on engine 0.1.49.1; the parallel-fill fix has been validated on engine 0.2.4.2 and 0.2.5 builds.

Graphics card, memory and system

2x Tesla V100 32 GB (sm_70) · 96 GB RAM · Ubuntu 26.04.1 LTS (kernel 7.0.0-38-generic) · NVMe ZhiTai Ti600 1 TB

Model, size and settings

Qwen3.8-Flash-Next Unsloth Dynamic 2.0 Q4_K_XL MoE · 131K context · vision on

What happened

A cold strata --serve start of this configuration takes 8 min 45 s from engine started to serving. 336 s of that (65 %) is one stage: the CUDA1 verify stage's expert-cache profile fill (8 072 pairs). During those 5.6 minutes the engine's main thread sits at 100 % CPU pulling experts in one synchronous pread64 at a time, while the 8 file-tier IO threads and the 11 pool workers all sit in poll(), and the drive runs at ~55 MB/s against a measured ~390 MB/s of random-read capability on the very same file.

Today's startup (2026-10-25 13:52:47, engine 0.1.49.1) from strata-unsloth-ud-q4_k_xl.log:

strata generate: pre-filled 8592 of 8592 slots from the profile in 36.4 s (741 MB/s); slot 0 verified
strata generate: layer split, CUDA1: 24.33 GiB free of 31.73, room for experts 23.55 GiB
strata generate: layer split: CUDA1 runs layers 24-47, expert cache 8072 slots (23.55 GiB), 8072 of its 12288 profiled pairs; slot 0 verified

The CUDA0 line times itself (36.4 s, 741 MB/s - warm, and that loop asks for the next 256 pairs ahead via STRATA_FILL_AHEAD). The stages line has no timing at all, which is why this stage is invisible in a startup log: the strace window 13:54:35 → 14:00:11 puts it at 336 s, ~55 MB/s.

Smallest steps or command that reproduce it

  1. Model files on NVMe, expert profile present, cold page cache (sync; echo 3 > /proc/sys/vm/drop_caches), 2 GPUs.
  2. Start the engine exactly as the config does (same args as below).
  3. Time engine started → serving; the gap between the pre-filled … line and the layer split: CUDA1 runs layers … line is the stage (or attach strace -f -tt -e trace=pread64,mincore -p <pid>).
/mnt/Strata/engine-cuda12/strata --serve --pack /mnt/Strata-data/packs/unsloth-ud-q4_k_xl --native …/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf --expert-profile /mnt/Strata/data/expert-profile.bin --expert-cache auto --prefill auto --spec 4 --mtp /mnt/Strata-data/mtp/rt --max-context 131072 --kv int8 --kv-resident 32768 --vision --vram-reserve-mib 700 --pcie-frac 0.00 --spec-min-p 0.70 --resident-experts --pool-workers 11 --ple-io ram --layer-split auto

Expected vs actual

Expected: the profile fill is a startup-phase bulk copy with the whole worker pool idle; it should use the workers and the drive's measured random throughput - a few tens of seconds for 18.4 GB.

Actual: 336 s, single thread, one in-flight read.

Evidence (from my strace of this run)

  • Main thread: 17 757 completed pread64s of 921 600 B - 13.46 GB from the part-3 GGUF at 40 MB/s (13 081 reads) + 4.94 GB from part-4 at 14.8 MB/s (4 676 reads); total 18.4 GB in 336 s ≈ 55 MB/s.
  • The reads are almost fully random: 3 of 13 080 sequential, median offset jump 478 MB - the profile is frequency-ranked, the file layout is file order.
  • Every read is preceded by a mincore reporting not-resident (cold), so there is no page-cache help and no overlap: one read in flight, then a blocking cudaMemcpy H2D per pair.
  • Drive benchmark on the same file, same request shape (O_DIRECT, 900 KB random): 2.3 ms/read ≈ 390 MB/s (430 IOPS); sequential 1.45 GB/s. The fill uses ~1/7 of what the same drive delivers to 8 concurrent readers.
  • The other 95 threads of the process did nothing but poll() for the whole window (--pool-workers 11, plus the file tier's IO threads).

Suspected path (I also read the code, at main @ 7dd5cf1 / engine 0.1.49.2, loops identical to my 0.1.49.1)

src/program/generate.cpp: both profile-fill loops do, on the main thread, pair by pair: ExpertCache::admit → ExpertSource::blob_stable (staged copy: mincore per span + pread_full when uncached + memcpy) → ExpertCache::fill_slot_blocking (blocking cudaMemcpy H2D). The CUDA0 loop at least overlaps reads with STRATA_FILL_AHEAD madvise; the stage loop (layer split, CUDA…) has no advise, no overlap, and no timing line.

Environment

  • Strata engine 0.1.49.1 (loops byte-identical at main HEAD 7dd5cf1, engine 0.1.49.2)
  • 2× Tesla V100-SXM2 32 GB · 96 GB RAM · Ubuntu 26.04.1 LTS · ZHITAI Ti600 1 TB NVMe (model files on /mnt, ext4)
  • Qwen3.8-Flash-Next UD-Q4_K_XL (Unsloth dynamic quant) · 131072 ctx · kv int8 · vision on · --expert-cache auto --resident-experts --layer-split auto --pool-workers 11

Proposed fix (PR to follow)

Admit every pair serially first (admit touches the residency table and slot counters - the only non-thread-safe step), then run blob_stable + fill_slot_blocking across disjoint slots on N threads (default 8, STRATA_FILL_THREADS, 0/1 = today's loop, left untouched). The decode-time prompt refill already does exactly this concurrently from several device threads, so the two calls are already exercised in parallel against disjoint slots. It also adds the missing timing line to the stages fill. I will post before/after numbers from this machine in the PR.

Two related things this issue is not: the pinned cache-complement copy that runs after the fill (30.28 GiB, 37 s, separate stage), and #3897 (slow expert loading on Windows) - that report is very likely the same single-threaded fill on the Windows file tier, and its author asks for exactly the diagnosis this issue supplies.

Originally created by @chenyb999-zhcn on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4064 ### Area Engine (from source / Terminal: `strata --serve … --layer-split auto`, CUDA1 verify-stage profile fill) ### Reproduction status Reproduced locally, on my own machine, with a `strace -f` capture I ran myself against the live startup. ### Desktop app, Terminal or source? Source (a build) — the `strata` engine binary built from source, launched as `strata --serve … --layer-split auto` ### Strata version Reported on engine 0.1.49.1; the parallel-fill fix has been validated on engine 0.2.4.2 and 0.2.5 builds. ### Graphics card, memory and system 2x Tesla V100 32 GB (sm_70) · 96 GB RAM · Ubuntu 26.04.1 LTS (kernel 7.0.0-38-generic) · NVMe ZhiTai Ti600 1 TB ### Model, size and settings Qwen3.8-Flash-Next Unsloth Dynamic 2.0 Q4_K_XL MoE · 131K context · vision on ### What happened A cold `strata --serve` start of this configuration takes **8 min 45 s** from `engine started` to serving. **336 s of that (65 %) is one stage: the CUDA1 verify stage's expert-cache profile fill** (8 072 pairs). During those 5.6 minutes the engine's main thread sits at 100 % CPU pulling experts in **one synchronous `pread64` at a time**, while the 8 file-tier IO threads and the 11 pool workers all sit in `poll()`, and the drive runs at ~55 MB/s against a measured ~390 MB/s of random-read capability on the very same file. Today's startup (2026-10-25 13:52:47, engine 0.1.49.1) from `strata-unsloth-ud-q4_k_xl.log`: ```text strata generate: pre-filled 8592 of 8592 slots from the profile in 36.4 s (741 MB/s); slot 0 verified strata generate: layer split, CUDA1: 24.33 GiB free of 31.73, room for experts 23.55 GiB strata generate: layer split: CUDA1 runs layers 24-47, expert cache 8072 slots (23.55 GiB), 8072 of its 12288 profiled pairs; slot 0 verified ``` The CUDA0 line times itself (36.4 s, 741 MB/s - warm, and that loop asks for the next 256 pairs ahead via `STRATA_FILL_AHEAD`). The stages line has **no timing at all**, which is why this stage is invisible in a startup log: the strace window 13:54:35 → 14:00:11 puts it at **336 s, ~55 MB/s**. ## Smallest steps or command that reproduce it 1. Model files on NVMe, expert profile present, cold page cache (`sync; echo 3 > /proc/sys/vm/drop_caches`), 2 GPUs. 2. Start the engine exactly as the config does (same args as below). 3. Time `engine started` → serving; the gap between the `pre-filled …` line and the `layer split: CUDA1 runs layers …` line is the stage (or attach `strace -f -tt -e trace=pread64,mincore -p <pid>`). ```text /mnt/Strata/engine-cuda12/strata --serve --pack /mnt/Strata-data/packs/unsloth-ud-q4_k_xl --native …/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf --expert-profile /mnt/Strata/data/expert-profile.bin --expert-cache auto --prefill auto --spec 4 --mtp /mnt/Strata-data/mtp/rt --max-context 131072 --kv int8 --kv-resident 32768 --vision --vram-reserve-mib 700 --pcie-frac 0.00 --spec-min-p 0.70 --resident-experts --pool-workers 11 --ple-io ram --layer-split auto ``` ## Expected vs actual Expected: the profile fill is a startup-phase bulk copy with the whole worker pool idle; it should use the workers and the drive's measured random throughput - a few tens of seconds for 18.4 GB. Actual: 336 s, single thread, one in-flight read. ## Evidence (from my strace of this run) - Main thread: **17 757 completed `pread64`s of 921 600 B** - 13.46 GB from the part-3 GGUF at **40 MB/s** (13 081 reads) + 4.94 GB from part-4 at **14.8 MB/s** (4 676 reads); total 18.4 GB in 336 s ≈ **55 MB/s**. - The reads are almost fully random: 3 of 13 080 sequential, median offset jump 478 MB - the profile is frequency-ranked, the file layout is file order. - Every read is preceded by a `mincore` reporting not-resident (cold), so there is no page-cache help and no overlap: one read in flight, then a blocking `cudaMemcpy` H2D per pair. - Drive benchmark on the same file, same request shape (`O_DIRECT`, 900 KB random): **2.3 ms/read ≈ 390 MB/s (430 IOPS)**; sequential 1.45 GB/s. The fill uses ~1/7 of what the same drive delivers to 8 concurrent readers. - The other 95 threads of the process did nothing but `poll()` for the whole window (`--pool-workers 11`, plus the file tier's IO threads). ## Suspected path (I also read the code, at main @ 7dd5cf1 / engine 0.1.49.2, loops identical to my 0.1.49.1) `src/program/generate.cpp`: both profile-fill loops do, on the main thread, pair by pair: `ExpertCache::admit` → `ExpertSource::blob_stable` (staged copy: `mincore` per span + `pread_full` when uncached + memcpy) → `ExpertCache::fill_slot_blocking` (blocking `cudaMemcpy` H2D). The CUDA0 loop at least overlaps reads with `STRATA_FILL_AHEAD` madvise; the stage loop (`layer split, CUDA…`) has no advise, no overlap, and no timing line. ## Environment - Strata engine 0.1.49.1 (loops byte-identical at `main` HEAD 7dd5cf1, engine 0.1.49.2) - 2× Tesla V100-SXM2 32 GB · 96 GB RAM · Ubuntu 26.04.1 LTS · ZHITAI Ti600 1 TB NVMe (model files on /mnt, ext4) - Qwen3.8-Flash-Next UD-Q4_K_XL (Unsloth dynamic quant) · 131072 ctx · kv int8 · vision on · `--expert-cache auto --resident-experts --layer-split auto --pool-workers 11` ## Proposed fix (PR to follow) Admit every pair serially first (`admit` touches the residency table and slot counters - the only non-thread-safe step), then run `blob_stable` + `fill_slot_blocking` across disjoint slots on N threads (default 8, `STRATA_FILL_THREADS`, `0`/`1` = today's loop, left untouched). The decode-time prompt refill already does exactly this concurrently from several device threads, so the two calls are already exercised in parallel against disjoint slots. It also adds the missing timing line to the stages fill. I will post before/after numbers from this machine in the PR. Two related things this issue is **not**: the pinned cache-complement copy that runs after the fill (30.28 GiB, 37 s, separate stage), and #3897 (slow expert loading on Windows) - that report is very likely the same single-threaded fill on the Windows file tier, and its author asks for exactly the diagnosis this issue supplies.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Desktop app, Terminal or source?".
  • Fill in "Strata version".
  • Fill in "Graphics card, memory and system".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6394560510 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Desktop app, Terminal or source?". - [ ] Fill in "Strata version". - [ ] Fill in "Graphics card, memory and system". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@chenyb999-zhcn commented on GitHub (Oct 25, 2026):

Proposed fix: #4065 (parallelize the profile fill behind STRATA_FILL_THREADS, plus the missing timing line for the stages' fill).

<!-- gh-comment-id:6394685266 --> @chenyb999-zhcn commented on GitHub (Oct 25, 2026): Proposed fix: #4065 (parallelize the profile fill behind `STRATA_FILL_THREADS`, plus the missing timing line for the stages' fill).
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6398514365 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks, this follows the format now.
Author
Owner

@chenyb999-zhcn commented on GitHub (Oct 25, 2026):

Withdrawing while I re-measure: a fresh strace of a cold start on this box shows a large startup phase the fill theory does not cover, so the numbers here need re-basing. Will reopen with corrected evidence.

<!-- gh-comment-id:6399247110 --> @chenyb999-zhcn commented on GitHub (Oct 25, 2026): Withdrawing while I re-measure: a fresh strace of a cold start on this box shows a large startup phase the fill theory does not cover, so the numbers here need re-basing. Will reopen with corrected evidence.
Author
Owner

@chenyb999-zhcn commented on GitHub (Oct 25, 2026):

Reopening with the scope sharpened by a second strace of this box.

The numbers in the body stand: they are STRATA_UNBUFFERED_LOAD=1 (the O_DIRECT file tier), where the startup profile fill is a serial 64-pair batch loop and is the whole story of the slow start — that is what #4065 fixes (same tier, same binary, same cold cache: 329.0 s @ 82 MB/s + 146.8 s → 19.6 s @ 1372 MB/s + 16.4 s).

To keep the two cold paths apart, a fresh strace of a cold start on the default buffered tier shows different bottlenecks and does not contradict this report:

  • RouterLookahead::warm issues ~54k 128 KiB madvise(MADV_WILLNEED) calls from the main thread over ~90 s (the expert-blob hinting; the O_DIRECT tier has no equivalent), and the leftover random read-ahead then squeezes the concurrent PLE MADV_POPULATE_READ from its solo 28–33 s down to 152 s;
  • the page-locked cache complement then copies its 30.3 GiB through the (deliberately dropped) page cache while ~57 GiB is already mlocked, and runs at ~58 MB/s for its first 20 GiB — 353 s, against 33 s warm. The direct tier reads the same complement through its batched direct loader instead;
  • the startup profile fill on that buffered cold path was not the bottleneck (19.7 s — the warm storm had pre-read its blobs for it).

So: this issue and #4065 are the O_DIRECT tier's cold path; the buffered tier's cold path (hint storm + complement cold copy under reclaim) is being measured separately and belongs in its own report.

<!-- gh-comment-id:6399712261 --> @chenyb999-zhcn commented on GitHub (Oct 25, 2026): Reopening with the scope sharpened by a second strace of this box. The numbers in the body stand: they are `STRATA_UNBUFFERED_LOAD=1` (the `O_DIRECT` file tier), where the startup profile fill is a serial 64-pair batch loop and is the whole story of the slow start — that is what #4065 fixes (same tier, same binary, same cold cache: 329.0 s @ 82 MB/s + 146.8 s → 19.6 s @ 1372 MB/s + 16.4 s). To keep the two cold paths apart, a fresh strace of a cold start on the **default buffered tier** shows different bottlenecks and does not contradict this report: - `RouterLookahead::warm` issues ~54k 128 KiB `madvise(MADV_WILLNEED)` calls from the main thread over ~90 s (the expert-blob hinting; the `O_DIRECT` tier has no equivalent), and the leftover random read-ahead then squeezes the concurrent PLE `MADV_POPULATE_READ` from its solo 28–33 s down to 152 s; - the page-locked cache complement then copies its 30.3 GiB through the (deliberately dropped) page cache while ~57 GiB is already mlocked, and runs at ~58 MB/s for its first 20 GiB — 353 s, against 33 s warm. The direct tier reads the same complement through its batched direct loader instead; - the startup profile fill on that buffered cold path was **not** the bottleneck (19.7 s — the warm storm had pre-read its blobs for it). So: this issue and #4065 are the `O_DIRECT` tier's cold path; the buffered tier's cold path (hint storm + complement cold copy under reclaim) is being measured separately and belongs in its own report.
Author
Owner

@chenyb999-zhcn commented on GitHub (Oct 25, 2026):

The series is measured end to end on this box now (engine 0.1.50 + the branch head), cold start
00:52:40 -> 00:54:30, 110 s against the 298 s in the report:

pack dense 1416 MiB                     0.3 s   (23.6 s)
495 projection matrices 3619 MiB       18.0 s   (60.4 s)
PLE table 26.8 GiB                     24.2 s @1188 MB/s + mlock 1.4 s   (120.1 s)
MTP draft layer 835 MiB                 1.1 s   (13.6 s)
profile fill CUDA0 25.09 GiB           20.3 s @1324 MB/s   (19.6 s)
profile fill CUDA1 23.55 GiB           16.6 s @1525 MB/s   (17.1 s)
8 GiB RAM complement                    9 s

Two findings worth recording:

  • The remaining variance is the drive, not the engine. With bpftrace attached to the block layer
    (block_rq_issue/block_rq_complete, no strace) one start showed 597,929 completions in the 16-32 ms bucket
    against 64-128 us when the drive is idle, io_ticks at 96.5%, no host writes, no other reader, while the
    engine's 12 fill workers sat in io_getevents (p50 571 ms per 1.2 MiB request in a strace of the same phase).
    The same offsets read at 700 MB/s-2.2 GB/s once the episode passes; SMART is clean and the NVMe error log is
    empty. That is why the same fill is 16.4 s in one start and 252.2 s in another with identical code.
  • The fill now walks the pairs in (layer, expert) order, not profile order: the profile is ranked by routing
    frequency, so the old order was a random walk over the two 49 GiB shards - the pattern a DRAM-less QLC drive
    with a 40 MiB mapping buffer handles worst.

Also measured on the same runs: --compile-free advise_willneed in 4 MiB steps (128 KiB steps made a 3.6 GiB
load queue ~29k windows one after another), the dense/embedding/HC-Q8/MTP reads staged through 4 MiB O_DIRECT
with one cached descriptor per file, and mincore-based residency so a warm start copies a resident tensor from
its mapping instead of reading it again.

<!-- gh-comment-id:6400663505 --> @chenyb999-zhcn commented on GitHub (Oct 25, 2026): The series is measured end to end on this box now (engine 0.1.50 + the branch head), cold start `00:52:40 -> 00:54:30`, **110 s** against the 298 s in the report: ``` pack dense 1416 MiB 0.3 s (23.6 s) 495 projection matrices 3619 MiB 18.0 s (60.4 s) PLE table 26.8 GiB 24.2 s @1188 MB/s + mlock 1.4 s (120.1 s) MTP draft layer 835 MiB 1.1 s (13.6 s) profile fill CUDA0 25.09 GiB 20.3 s @1324 MB/s (19.6 s) profile fill CUDA1 23.55 GiB 16.6 s @1525 MB/s (17.1 s) 8 GiB RAM complement 9 s ``` Two findings worth recording: - **The remaining variance is the drive, not the engine.** With bpftrace attached to the block layer (`block_rq_issue`/`block_rq_complete`, no strace) one start showed 597,929 completions in the 16-32 ms bucket against 64-128 us when the drive is idle, `io_ticks` at 96.5%, no host writes, no other reader, while the engine's 12 fill workers sat in `io_getevents` (p50 571 ms per 1.2 MiB request in a strace of the same phase). The same offsets read at 700 MB/s-2.2 GB/s once the episode passes; SMART is clean and the NVMe error log is empty. That is why the same fill is 16.4 s in one start and 252.2 s in another with identical code. - **The fill now walks the pairs in (layer, expert) order**, not profile order: the profile is ranked by routing frequency, so the old order was a random walk over the two 49 GiB shards - the pattern a DRAM-less QLC drive with a 40 MiB mapping buffer handles worst. Also measured on the same runs: `--compile`-free `advise_willneed` in 4 MiB steps (128 KiB steps made a 3.6 GiB load queue ~29k windows one after another), the dense/embedding/HC-Q8/MTP reads staged through 4 MiB O_DIRECT with one cached descriptor per file, and `mincore`-based residency so a warm start copies a resident tensor from its mapping instead of reading it again.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6659935228 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1763
No description provided.