Repository navigation
stream: fold desired-size check into WHATWG backpressure update - #64451
Merged
Merged
Conversation
The [[queue]] backing the controllers became a ring buffer, but the read and write request queues (readRequests, readIntoRequests, writeRequests) were left as plain arrays consumed with ArrayPrototypeShift, which is O(n) and, even for the single pending request of the await-each regime, far slower than an indexed head advance. Back them with the same Queue, materialized lazily from the shared empty queue so acquiring a reader or constructing a writer allocates no request storage until a read or write actually parks. pipe-to: +4.7% to +9.4% (all 16 configs, ***) readable-read type=byob: +2.3% (**) parked read loop: +15%, write loop: +11% (local harness) Follow-up to nodejs#64312. Signed-off-by: Matteo Collina <hello@matteocollina.com>
writableStreamUpdateBackpressure ran two release-mode assertions and took a precomputed backpressure value that every caller derived with a separate GetBackpressure/GetDesiredSize call pair. All callers already hold the 'writable', not-close-queued invariant the assertions checked, so derive the backpressure from the desired size inside the function and drop the assertions and the helper. This runs up to twice per write. writer.write() loop: +10%, pipe-to: +4.6% avg over 16 configs (local harness / benchmark, all configs positive). Signed-off-by: Matteo Collina <hello@matteocollina.com>
writableStreamUpdateBackpressureran two release-mode assertions and took a precomputed backpressure value that every caller derived with a separateGetBackpressure/GetDesiredSizecall pair. All callers already hold thewritable, not-close-queued invariant the assertions checked, so the backpressure is now derived from the desired size inside the function, dropping the assertions and the helper. This runs up to twice per write.The first commit is #64431; only the last commit is new here.