Implementation of Readable iteration helpers that does not rely on Async Iteration - #64429
Implementation of Readable iteration helpers that does not rely on Async Iteration#64429lukiano wants to merge 1 commit into
Conversation
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64429 +/- ##
==========================================
- Coverage 90.33% 90.14% -0.19%
==========================================
Files 751 752 +1
Lines 250341 252245 +1904
Branches 47322 47459 +137
==========================================
+ Hits 226145 227389 +1244
- Misses 15575 16191 +616
- Partials 8621 8665 +44
🚀 New features to boost your workflow:
|
fae33f0 to
17e0105
Compare
|
I'm seeing #64447, which may change the measured performance of the current implementation. |
17e0105 to
43335b2
Compare
e10c1f8 to
9050881
Compare
9050881 to
64a5a60
Compare
|
macbook-stream-operator-throughput-report.pdf |
64a5a60 to
e751328
Compare
Signed-off-by: Luciano Leggieri <230980@gmail.com> Assisted-by: Sol 5.6
e751328 to
a6618fd
Compare
Hi, I'd like to offer an alternative implementation of Readable iteration helpers like find() that don't rely on
for await (...)to consume items from the stream. This results in improved performance when the data is already available, such as when creating aReadablefrom an array, as shown in the attached screenshot (executed on a MacBook M2 Max).The main con is increased duplication and code complexity. My understanding is that these helpers are still in the experimental phase, which I hope makes a change like this easier to accept.
There are many commits in the branch, but I'll squash them before merging.Edit: I merged them to fix CI issues
The affected helpers are
map()filter()reduce()find()toArray()some()every()drop()Unaffected helpers:
flatmap()take()There's also a change to the
from()method that increases the buffer watermark when the source is an array of data.At first, I coded the changes manually, but eventually I had assistance from AI to keep backward compatibility. Still, there's a small break as can be seen in the updated test in
test/parallel/test-stream-reduce.js.The file
benchmark/streams/operator-throughput.jsallows interested parties to run the benchmarks on their computers or modify them to try other scenarios. I can remove it before merging.