| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
|
Sorry, something went wrong.
Codecov Report❌ Patch coverage is 41.83673% with 57 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #65414 +/- ##
==========================================
- Coverage 90.12% 90.10% -0.02%
==========================================
Files 752 751 -1
Lines 252317 252490 +173
Branches 47435 47464 +29
==========================================
+ Hits 227401 227508 +107
- Misses 16209 16308 +99
+ Partials 8707 8674 -33
... and 47 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
The encode-and-enqueue transform walked the chunk code unit by code
unit, materializing a single-character string per index and building
the output with string concatenation. The only state that crosses
chunks is a trailing high (leading) surrogate, and TextEncoder.encode's
USVString conversion already replaces every interior lone surrogate
with U+FFFD, which is exactly what the spec loop produces. Join a
pending high surrogate with the incoming chunk, hold back a new
trailing high surrogate, and encode the rest in a single native call.
The streaming decode path also reuses a single options object instead
of allocating { stream: true } per chunk.
An encoding-streams benchmark is added since the suite had no
TextEncoderStream/TextDecoderStream row. Encoding improves by ~546%
with 1KB string chunks and ~20% with 16-character chunks; decode is
unchanged.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
The pull algorithm was an async function that awaited iterator.next() and then the produced value, costing an async-function frame plus two await wrappers and a controller-side reaction per chunk. Rewrite it callback-style: the next() result is adopted exactly like the previous awaits (including the observable .then lookup on plain object values), the reaction steps are created once per stream, and completion is delivered straight to the controller's cached pull reactions using the parked-algorithm-result contract. The iterator's next method is also looked up once at setup, per the spec's GetIteratorDirect. A from benchmark is added since the suite had no ReadableStream.from row. Iterating a stream built from a sync generator improves by ~27% and from an async generator by ~23%; all other rows are unchanged. Signed-off-by: Matteo Collina <hello@matteocollina.com>
The parked-result sentinel is only ever compared by identity, so a Symbol describes its purpose better than an empty null-prototype object. Signed-off-by: Matteo Collina <hello@matteocollina.com>
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR is stacked on #65143 — please review the last two commits only.
Two independent optimizations for WHATWG streams:
TextEncoderStream: encode whole chunks natively. The encode-and-enqueue transform walked every code unit in JS, materializing a one-character string per index and building the output via string concatenation. The only state that crosses chunks is a trailing high (leading) surrogate, and TextEncoder.encode()'s USVString conversion already replaces interior lone surrogates with U+FFFD exactly like the spec loop. The transform now joins a pending high surrogate, holds back a new trailing one, and encodes the rest in a single native call. Verified byte-identical to the previous algorithm over 200k randomized surrogate-heavy chunk sequences, plus the full WPT encoding suite. The streaming decode path also stops allocating a { stream: true } options object per chunk.
ReadableStream.from(): drop the async pull machinery. The pull algorithm was an async function awaiting iterator.next() and then the value — an async frame, two await wrappers, and a controller-side reaction per chunk. It is now callback-style with per-stream cached reaction steps, delivering completion directly to the controller's cached pull reactions (the parked-algorithm-result contract from #65143). Thenable adoption is preserved, including the observable .then lookup on plain object values. The iterator's next method is now looked up once at setup, matching the spec's GetIteratorDirect.
Benchmark results (benchmark/compare.js --runs 10, new rows added since the suite covered neither path):
All other webstreams rows (pipe-to ×9, pipe-through, read/read-buffered, async-iterator, tee, creation, js_transfer, decode) are unchanged. Full WPT streams + encoding suites and the parallel webstreams/whatwg test batches pass.