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.15% -0.19%
==========================================
Files 751 751
Lines 250341 254051 +3710
Branches 47322 47897 +575
==========================================
+ Hits 226145 229037 +2892
- Misses 15575 16276 +701
- Partials 8621 8738 +117
🚀 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 |
a6618fd to
b3d857e
Compare
Signed-off-by: Luciano Leggieri <230980@gmail.com> Assisted-by: Sol 5.6
b3d857e to
df55497
Compare
|
@nodejs/streams I know you guys have probably 20 million PRs to review but if you could add this one to the queue I'd really appreciate it :) |
ovflowd
left a comment
There was a problem hiding this comment.
The changes on streams/operators are quite significant, making the review of the code much harder. It'd be helpful if you could reorganize your changes in a way that minimizes diff. Or decouple current behavior from the added behavior of "data already being available"
My main concern is due to the nature of the diff, it is hard to see/visualize what actually was changed in terms of behavior/logic versus what is just moving code around. I'm not an expert on the streams implementation within node, but possibly my peers would argue the same.
Do you believe there any improvements you can do to the current diff?
@ovflowd thanks for taking a look at the code. I could split the changes in In terms of the logic inside I could also split the changes into a few sections (maybe different commits?): Functions that return a
I reiterate that Functions that return a value:
|
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.