Repository navigation
jitv2: the compile pool takes the host's spare CPUs, not the guest's - #768
Merged
techomancer merged 1 commit intoNov 17, 2026
Merged
Conversation
The pool's auto size reserved the guest's own CPU threads as well as the device threads' one CPU, so on a four-logical-CPU host a two-CPU guest got one compile worker and a four-CPU guest also got one. That was derived from the model where every worker polled: a worker cost a core whether it had work or not. Since the pool parks instead of polling, a worker with no work costs nothing, and the guest's CPUs are not the ones a worker competes with for progress: a guest CPU that reaches a page with no compiled code does not block, it keeps interpreting until the pool publishes the page. The measured boot profile left four workers about half busy each, so the host had room to spare during exactly the phase the pool exists for, and the old rule left most of a small host idle through it. Size the pool by the guest's demand (one worker per guest CPU, the measured want) and cap it by the host's usable CPUs, one of which stays with the device threads. A two-CPU guest on a four-CPU host gets two workers again, so pages reach compiled code sooner and the compile-bound part of a boot is shorter. An explicit [jitv2] threads still wins, and an explicit 0 still reaches validate() and is refused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #763 and #764.
The problem
#764 sized the auto-sized compile pool by the host's spare room:
On a four-logical-CPU host that gives a 2-CPU guest one worker and a
4-CPU guest one worker. That rule was derived from the model where
every worker polls: a worker cost a core whether it had work or not.
Since #763 the pool parks instead of polling, so a worker with no work
costs nothing, and the guest's CPUs are not the ones a worker competes
with for progress:
block on the pool. The dispatch gate (
src/cpu/mips_exec.rs) pushesthe request and falls through to
step_int(), so the guest keepsrunning — in the interpreter — until the pool publishes the page.
clanker/jitv2/compile-time-profile.md:5,000-odd compiles at 50-55 ms over a 2.5-minute run) left four
workers roughly half busy each. The host was not saturated; the
compile latency was the limit.
So the old rule left most of a small host idle through exactly the phase
the pool exists for, and doubled the wall-clock of that phase for no
host-CPU saving.
The change
The pool's width follows the guest's demand and is capped by the host's
usable CPUs, one of which stays with the device threads (the graphics
compose, SCSI, ethernet, audio, timer).
On an i3-4130 (2 physical cores, 4 logical CPUs):
On a 16-CPU host nothing changes.
An explicit
[jitv2] threads/--jitv2-threadsstill wins and says so,and an explicit
0still reachesvalidate()and is refused rather thanbeing silently clamped.
Notes
with no work costs a wakeup every 20 ms, not a core.
j2 threadsprints the size and why, as before.clanker/jitv2/compile-pool-size-on-small-hosts.md.