Parent: #493
Related: #474, #480, #482, #495
Problem
The realm-local unhandled- and handled-rejection queues are growable arrays, but each host checkpoint removes index zero with orderedRemove(0). The private ABI drains those functions in a loop, so N JavaScript-created rejection notifications copy Θ(N²) Promise pointers while repeatedly holding realm_lock. Rejection fanout is script-controlled, making this an avoidable latency and contention surface.
Required implementation
- Replace front-removal with an exact FIFO cursor so each queued Promise is consumed in O(1) amortized work and event order is unchanged.
- Reset the cursor and logical storage as soon as the queue is exhausted, reusing bounded retained capacity rather than retaining consumed logical entries indefinitely.
- Trace and relocate only pending queue entries while preserving precise Promise rooting, early-handled skipping, one-time notification state, and realm-lock synchronization.
- Preserve reentrant behavior: rejection callbacks may enqueue more notifications, which must follow the already-pending FIFO entries and drain in the same checkpoint.
- Do not reverse events, use unordered removal, cap valid fanout, defer required notifications, weaken locking, or add workload-recognizing paths.
Acceptance
Parent: #493
Related: #474, #480, #482, #495
Problem
The realm-local unhandled- and handled-rejection queues are growable arrays, but each host checkpoint removes index zero with
orderedRemove(0). The private ABI drains those functions in a loop, so N JavaScript-created rejection notifications copy Θ(N²) Promise pointers while repeatedly holdingrealm_lock. Rejection fanout is script-controlled, making this an avoidable latency and contention surface.Required implementation
Acceptance