stream: use the ring buffer for WHATWG stream request queues#64431
Open
mcollina wants to merge 1 commit into
Open
stream: use the ring buffer for WHATWG stream request queues#64431mcollina wants to merge 1 commit into
mcollina wants to merge 1 commit into
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 reader.read() loop: +15%, writer.write() loop: +11% (local harness) Follow-up to nodejs#64312. Signed-off-by: Matteo Collina <hello@matteocollina.com>
e8dd939 to
e203888
Compare
Member
|
Need a signature for first commit message. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64431 +/- ##
==========================================
- Coverage 90.24% 90.24% -0.01%
==========================================
Files 741 741
Lines 241384 241400 +16
Branches 45480 45484 +4
==========================================
+ Hits 217844 217854 +10
+ Misses 15097 15093 -4
- Partials 8443 8453 +10
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
[[queue]]backing the controllers is now a ring buffer, but the read/write request queues (readRequests,readIntoRequests,writeRequests) were left as plain arrays consumed withArrayPrototypeShift. Back them with the sameQueue, materialized lazily from the shared empty queue so acquiring a reader or constructing a writer allocates no request storage until a read/write parks.Follow-up to #64312.