-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: performance improvement on readline async iterator #41276
Commits on Oct 18, 2022
-
lib: performance improvement on readline async iterator
Using a direct approach to create the readline async iterator allowed an iteration over 20 to 58% faster. **BREAKING CHANGE**: With that change, the async iteterator obtained from the readline interface doesn't have the property "stream" any longer. This happened because it's no longer created through a Readable, instead, the async iterator is created directly from the events of the readline interface instance, so, if anyone is using that property, this change will break their code. Also, the Readable added a backpressure control that is fairly compensated by the use of FixedQueue + monitoring its size. This control wasn't really precise with readline before, though, because it only pauses the reading of the original stream, but the lines generated from the last message received from it was still emitted. For example: if the readable was paused at 1000 messages but the last one received generated 10k lines, but no further messages were emitted again until the queue was lower than the readable highWaterMark. A similar behavior still happens with the new implementation, but the highWaterMark used is fixed: 1024, and the original stream is resumed again only after the queue is cleared. Before making that change, I created a package implementing the same concept used here to validate it. You can find it [here](https://github.com/Farenheith/faster-readline-iterator) if this helps anyhow.
Configuration menu - View commit details
-
Copy full SHA for c467ffe - Browse repository at this point
Copy the full SHA c467ffeView commit details -
lib: undoing accidental changes
Some Changes I just sent wasn't related to the PR in question, so I'm undoing then (in events.js and the addition of linkedMap.js) Also, fixed the [SymbolAsyncIterator] function returned by eventsToAsyncIteratorFactory, that was referencing a no longer available variable
Configuration menu - View commit details
-
Copy full SHA for 05db8ff - Browse repository at this point
Copy the full SHA 05db8ffView commit details -
lib: changing once to on in waitNext
After seeing how once method works on EventEmitter, it was clear that it doesn't make sense to use it into the waitNext method, as the callback will already remove the events
Configuration menu - View commit details
-
Copy full SHA for 3ecee3c - Browse repository at this point
Copy the full SHA 3ecee3cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 83919d2 - Browse repository at this point
Copy the full SHA 83919d2View commit details -
lib: adding different lines multiplier
Adding different lines multipliers is good for this bench because we can see how well the change performs in different scales. That way we can find out if there some curve with some point where the benefits starts or ends
Configuration menu - View commit details
-
Copy full SHA for 03ac26d - Browse repository at this point
Copy the full SHA 03ac26dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 870b5cf - Browse repository at this point
Copy the full SHA 870b5cfView commit details -
Configuration menu - View commit details
-
Copy full SHA for ae3325c - Browse repository at this point
Copy the full SHA ae3325cView commit details -
Configuration menu - View commit details
-
Copy full SHA for bb6f6ab - Browse repository at this point
Copy the full SHA bb6f6abView commit details -
lib: performance improvement on readline async iterator
Using a direct approach to create the readline async iterator allowed an iteration over 20 to 58% faster. **BREAKING CHANGE**: With that change, the async iteterator obtained from the readline interface doesn't have the property "stream" any longer. This happened because it's no longer created through a Readable, instead, the async iterator is created directly from the events of the readline interface instance, so, if anyone is using that property, this change will break their code. Also, the Readable added a backpressure control that is fairly compensated by the use of FixedQueue + monitoring its size. This control wasn't really precise with readline before, though, because it only pauses the reading of the original stream, but the lines generated from the last message received from it was still emitted. For example: if the readable was paused at 1000 messages but the last one received generated 10k lines, but no further messages were emitted again until the queue was lower than the readable highWaterMark. A similar behavior still happens with the new implementation, but the highWaterMark used is fixed: 1024, and the original stream is resumed again only after the queue is cleared. Before making that change, I created a package implementing the same concept used here to validate it. You can find it [here](https://github.com/Farenheith/faster-readline-iterator) if this helps anyhow.
Configuration menu - View commit details
-
Copy full SHA for 221e239 - Browse repository at this point
Copy the full SHA 221e239View commit details -
lib: undoing accidental changes
Some Changes I just sent wasn't related to the PR in question, so I'm undoing then (in events.js and the addition of linkedMap.js) Also, fixed the [SymbolAsyncIterator] function returned by eventsToAsyncIteratorFactory, that was referencing a no longer available variable
Configuration menu - View commit details
-
Copy full SHA for b536144 - Browse repository at this point
Copy the full SHA b536144View commit details -
lib: changing once to on in waitNext
After seeing how once method works on EventEmitter, it was clear that it doesn't make sense to use it into the waitNext method, as the callback will already remove the events
Configuration menu - View commit details
-
Copy full SHA for 31efb2d - Browse repository at this point
Copy the full SHA 31efb2dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e04a18 - Browse repository at this point
Copy the full SHA 0e04a18View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7a8c3fa - Browse repository at this point
Copy the full SHA 7a8c3faView commit details -
Configuration menu - View commit details
-
Copy full SHA for 156837b - Browse repository at this point
Copy the full SHA 156837bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 87da1a2 - Browse repository at this point
Copy the full SHA 87da1a2View commit details -
Configuration menu - View commit details
-
Copy full SHA for e7f358a - Browse repository at this point
Copy the full SHA e7f358aView commit details -
Configuration menu - View commit details
-
Copy full SHA for d5917c9 - Browse repository at this point
Copy the full SHA d5917c9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0143cdf - Browse repository at this point
Copy the full SHA 0143cdfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 917c51b - Browse repository at this point
Copy the full SHA 917c51bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4e8be80 - Browse repository at this point
Copy the full SHA 4e8be80View commit details -
refactor: Apply suggestions from code review
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 610a275 - Browse repository at this point
Copy the full SHA 610a275View commit details -
Configuration menu - View commit details
-
Copy full SHA for e1dd9d3 - Browse repository at this point
Copy the full SHA e1dd9d3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 26d066b - Browse repository at this point
Copy the full SHA 26d066bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 835bb5f - Browse repository at this point
Copy the full SHA 835bb5fView commit details -
Configuration menu - View commit details
-
Copy full SHA for e83baea - Browse repository at this point
Copy the full SHA e83baeaView commit details