v133 ยท javascript
Atomics.pause
Adds the Atomics.pause method to hint the CPU that the current code is executing a spinlock.
concepts
-
Atomics.pause
Atomics.pause() โ CPU pause hint inside spin-wait loops. Tells the engine to back off.
-
Worker spinlock
The TC39-proposal motivating use case: a Worker spin-waiting on a flag in
SharedArrayBuffer, with and withoutAtomics.pause()inside the loop. -
Exponential backoff
The textbook spinlock pattern: doubling
Atomics.pause(1 << attempt)on every retry. Live benchmark of tight vs backing-off iterations across a fixed window. -
SPSC queue throughput
Single-producer/single-consumer ring buffer in
SharedArrayBuffer: messages-per-second and empty-check ratio compared with and withoutAtomics.pausein the hot loop. -
Hybrid spin+wait mutex
Restore the TC39-recommended hybrid: spin briefly with
Atomics.pause(), then yield withAtomics.wait(). Tune the spin budget and compare acquisition metrics.
why it shipped
Enables writing more efficient spinlocks.