Rationale
Mailbox user/system queues are plain arrays and dequeue via Array.shift() (src/internal/Mailbox.ts:51, 55) — O(n) at queue depth. At the default BoundedMailbox capacity of 10k a deep mailbox pays a substantial reindexing tax per message. prependUser uses spread-unshift (O(n+m), stack risk for very large batches), and the ThroughputDispatcher work queue also shift()s (src/Dispatcher.ts:82).
Scope
- Circular head/tail ring buffer in the base
Mailbox so BoundedMailbox inherits it (the default mailbox is the one that must get faster).
- Amortized O(1) enqueue/dequeue; bulk
prependUser without spread.
- Same treatment for the
ThroughputDispatcher queue.
- New deep-queue benchmark case alongside the existing single-node benches.
Documentation
- CHANGELOG entry (internal performance; no user-facing API change expected).
Acceptance
Relates
Improvement program M2. #27 (benchmarks), #407.
Rationale
Mailbox user/system queues are plain arrays and dequeue via
Array.shift()(src/internal/Mailbox.ts:51, 55) — O(n) at queue depth. At the defaultBoundedMailboxcapacity of 10k a deep mailbox pays a substantial reindexing tax per message.prependUseruses spread-unshift(O(n+m), stack risk for very large batches), and theThroughputDispatcherwork queue alsoshift()s (src/Dispatcher.ts:82).Scope
MailboxsoBoundedMailboxinherits it (the default mailbox is the one that must get faster).prependUserwithout spread.ThroughputDispatcherqueue.Documentation
Acceptance
Relates
Improvement program M2. #27 (benchmarks), #407.