mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#2412
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/9
Author: @Mirtraxxx
Created: 9/26/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @Niko1221
Base:
main← Head:idle-pool-sleep📝 Commits (1)
c47e290cpu pool: sleep between requests instead of spinning (fixes #4)📊 Changes
2 files changed (+46 additions, -3 deletions)
View changed files
📝
include/strata/kernels/cpu/pool.hpp(+17 -0)📝
src/kernels/cpu/pool.cpp(+29 -3)📄 Description
Fixes #4.
What it does
A parked expert-pool worker waited for work with an endless
_mm_pausespin onepoch_, so every worker's core stayedat 100% while the engine sat idle between requests. On a Ryzen 7 5700X that's 7 cores, which the issue reports as
"CPU 50% even when doing nothing".
Now a parked worker spins exactly as before for up to 20 ms (
ExpertPool::kSpinBeforeSleep), then blocks on acondition variable:
run,run_phase, the destructor) goes through a newpublish(). It bumpsepoch_and notifiesonly if a worker is actually asleep, so the token path pays one uncontended load and never touches the mutex.
sleepers_++and then readsepoch_under themutex. The host does
epoch_++and then readssleepers_. At least one of them sees the other's write. On x86 thefetch_addis a lockedxaddeither way.stretch of a prefill they can; waking costs microseconds against chunks of hundreds of milliseconds.
Measured
RTX 3090, Ryzen 7 5700X (7 pool workers + host), 64 GB DDR4, Windows 11, Swift 1.5 IQ2_XS,
--serve,--expert-cache auto --spec 4 --adapt-swaps 0. Old and new engine, same flags, each run twice. CPU is process CPUtime over wall time, in cores.
Decode speed is unchanged within run-to-run noise. The 2.3K-token prefill came out ~7% faster in both runs, likely
because the workers sleep through the GPU-only stretches and stop competing with the host for cores.
Greedy output: the code prompt is identical across all four runs. The other two diverge late in some runs, but the
old engine also diverges from itself between runs (math at token 53), so that's the existing run-to-run variation,
not this change. The pool's arithmetic isn't touched.
Only tested on Windows / one machine. The Linux path uses the same
std::condition_variable.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.