Skip to content

Use the ARM yield hint in the ThreadPool Barrier spin - #23

Merged
mlin merged 1 commit into
mlin:mainfrom
Wid-L-Hacker:conrad/barrier-arm-yield
Oct 28, 2026
Merged

mlin merged 1 commit into
mlin:mainfrom
Wid-L-Hacker:conrad/barrier-arm-yield

Conversation

@Wid-L-Hacker

Copy link
Copy Markdown
Contributor

ThreadPoolWithEnqueueFast::Barrier() waits for the fast queue to drain by spinning on an atomic counter, and it is reached from the nested VFS's prefetch barrier and from web file close. On x86_64 the spin uses the PAUSE instruction, but on every other architecture it falls back to std::this_thread::yield() — which on Linux is a sched_yield system call, an expensive thing to do inside a spin loop. This gives aarch64 the same treatment x86_64 already has: the spin emits the ARM yield hint, the architecture's low-power spin-wait primitive, instead of calling into the OS on every iteration.

Nothing else changes. Architectures other than x86_64 and aarch64 keep the existing fallback, and x86_64 code generation is unchanged (verified byte-identical assembly for a translation unit calling Barrier). The aarch64 build was verified with a cross-compiler: the spin loop in the emitted code contains the yield instruction where the fallback build calls sched_yield.

@mlin
mlin merged commit c27b8b7 into mlin:main Oct 28, 2026
5 checks passed
@mlin
mlin deleted the conrad/barrier-arm-yield branch October 28, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants