Skip to content
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

feat: benchmark stream web readable #3

Merged
merged 2 commits into from
Mar 14, 2022
Merged

feat: benchmark stream web readable #3

merged 2 commits into from
Mar 14, 2022

Conversation

RafaelGSS
Copy link
Owner

I have tried to create a fair comparisson between these implementations.

However, I'm not sure if the results are confidents. I really would like to get your thoughts here: @mcollina @jasnell

@RafaelGSS
Copy link
Owner Author

Results I got locally:

streams.Readable reading 1e3 * "some data" x 2,465 ops/sec ±0.71% (87 runs sampled)
streams.web.Readable reading 1e3 * "some data" x 471 ops/sec ±0.39% (86 runs sampled)
Fastest is streams.Readable reading 1e3 * "some data"

@jasnell
Copy link

jasnell commented Mar 14, 2022

The results are not surprising. When running just a single iteration of the web streams vs node.js streams side-by-side, the performance comparison between the two should be nearly identical. However, when running it over-and-over, the web streams will be much slower for a number of reasons -- but mostly because of the heavy reliance on promises and the additional object allocations it requires. There are likely a number of performance optimizations that could be made internally but the web streams API was not designed for performance as much as it was designed for portability.

@RafaelGSS
Copy link
Owner Author

I see. Actually, I came across this benchmark because I'm investigating the undici.fetch performance (nodejs/undici#1203), and following my analysis, one of the slowest paths are in the pullAlgorithm that makes use of WebStreams (Readable/Writable).

The benchmarks in undici are also running it over-and-over, so the results make sense to this benchmark.

Thank you!

@RafaelGSS RafaelGSS merged commit 6fb22bd into main Mar 14, 2022
@RafaelGSS RafaelGSS deleted the feat/readable=bench branch March 13, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants