Skip to content

Use the ARM yield hint in the nested VFS prefetch wait - #23

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

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

Conversation

@Wid-L-Hacker

Copy link
Copy Markdown
Contributor

The nested VFS waits for a background prefetch job by spinning on the job's state (the semi-busy-wait in SQLiteNestedVFS.h's page-read path). On x86_64 the spin uses the PAUSE instruction, but on every other architecture it fell 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 — mirroring the identical change in sqlite_web_vfs' ThreadPool Barrier spin. Nothing else changes: other architectures keep the existing fallback, and x86_64 code generation is unchanged (verified by assembly comparison). The aarch64 build was verified with a cross-compiler: the emitted prefetch-wait loop contains the yield instruction where the previous build called sched_yield.

@mlin
mlin merged commit 6bd4ee4 into mlin:main Oct 28, 2026
5 checks passed
@mlin
mlin deleted the conrad/prefetch-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