perf(#316): hoist state-lock sleep buffer out of retry loop (#399)

acquireStateLock was allocating a fresh SharedArrayBuffer on every retry
iteration via Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), ...).
The buffer is never mutated and never escapes, so hoisting it before the loop
is a provably-equivalent transformation — Atomics.wait always sees value 0
whether the buffer is fresh or reused.

Fixes #316

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-27 20:21:52 -04:00
committed by GitHub
parent a393e28b34
commit 1868947088
3 changed files with 211 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
type: Fixed
pr: 316
---
acquireStateLock no longer allocates a fresh SharedArrayBuffer on every retry iteration — the sleep buffer is now hoisted before the retry loop and reused, eliminating per-retry heap pressure. (#316)