v133 ยท javascript

Atomics.pause

Adds the Atomics.pause method to hint the CPU that the current code is executing a spinlock.

concepts

  1. Atomics.pause

    Atomics.pause() โ€” CPU pause hint inside spin-wait loops. Tells the engine to back off.

  2. Worker spinlock

    The TC39-proposal motivating use case: a Worker spin-waiting on a flag in SharedArrayBuffer, with and without Atomics.pause() inside the loop.

  3. 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.

  4. SPSC queue throughput

    Single-producer/single-consumer ring buffer in SharedArrayBuffer: messages-per-second and empty-check ratio compared with and without Atomics.pause in the hot loop.

  5. Hybrid spin+wait mutex

    Restore the TC39-recommended hybrid: spin briefly with Atomics.pause(), then yield with Atomics.wait(). Tune the spin budget and compare acquisition metrics.

why it shipped

Enables writing more efficient spinlocks.

references