mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4064] [Engine] Cold-start profile fill is single-threaded: 336 s of an 8.75-minute start with all workers idle #1763
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1763
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 -fcapture I ran myself against the live startup.Desktop app, Terminal or source?
Source (a build) — the
strataengine binary built from source, launched asstrata --serve … --layer-split autoStrata 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 --servestart of this configuration takes 8 min 45 s fromengine startedto 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 synchronouspread64at a time, while the 8 file-tier IO threads and the 11 pool workers all sit inpoll(), 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: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
sync; echo 3 > /proc/sys/vm/drop_caches), 2 GPUs.engine started→ serving; the gap between thepre-filled …line and thelayer split: CUDA1 runs layers …line is the stage (or attachstrace -f -tt -e trace=pread64,mincore -p <pid>).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)
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.mincorereporting not-resident (cold), so there is no page-cache help and no overlap: one read in flight, then a blockingcudaMemcpyH2D per pair.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.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:mincoreper span +pread_fullwhen uncached + memcpy) →ExpertCache::fill_slot_blocking(blockingcudaMemcpyH2D). The CUDA0 loop at least overlaps reads withSTRATA_FILL_AHEADmadvise; the stage loop (layer split, CUDA…) has no advise, no overlap, and no timing line.Environment
mainHEAD7dd5cf1, engine 0.1.49.2)--expert-cache auto --resident-experts --layer-split auto --pool-workers 11Proposed fix (PR to follow)
Admit every pair serially first (
admittouches the residency table and slot counters - the only non-thread-safe step), then runblob_stable+fill_slot_blockingacross 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.
@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:
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
@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).@github-actions[bot] commented on GitHub (Oct 25, 2026):
Thanks, this follows the format now.
@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.
@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(theO_DIRECTfile 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::warmissues ~54k 128 KiBmadvise(MADV_WILLNEED)calls from the main thread over ~90 s (the expert-blob hinting; theO_DIRECTtier has no equivalent), and the leftover random read-ahead then squeezes the concurrent PLEMADV_POPULATE_READfrom its solo 28–33 s down to 152 s;So: this issue and #4065 are the
O_DIRECTtier'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.@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:Two findings worth recording:
(
block_rq_issue/block_rq_complete, no strace) one start showed 597,929 completions in the 16-32 ms bucketagainst 64-128 us when the drive is idle,
io_ticksat 96.5%, no host writes, no other reader, while theengine'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.
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-freeadvise_willneedin 4 MiB steps (128 KiB steps made a 3.6 GiBload 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 fromits mapping instead of reading it again.
@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:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.