Skip to content

Conversation

@ronag
Copy link
Member

@ronag ronag commented Oct 2, 2023

Try to inline condition checks and try to avoid read state properties in hot paths.

                                                                                          confidence improvement accuracy (*)   (**)  (***)
streams/writable-manywrites.js len=1024 callback='no' writev='no' sync='no' n=100000            ***      8.14 %       ±4.15% ±5.56% ±7.29%
streams/writable-manywrites.js len=1024 callback='no' writev='no' sync='yes' n=100000           ***     11.35 %       ±2.60% ±3.46% ±4.50%
streams/writable-manywrites.js len=1024 callback='no' writev='yes' sync='no' n=100000             *      2.04 %       ±2.03% ±2.71% ±3.54%
streams/writable-manywrites.js len=1024 callback='no' writev='yes' sync='yes' n=100000          ***     17.89 %       ±2.05% ±2.73% ±3.56%
streams/writable-manywrites.js len=1024 callback='yes' writev='no' sync='no' n=100000           ***      5.99 %       ±2.28% ±3.04% ±3.97%
streams/writable-manywrites.js len=1024 callback='yes' writev='no' sync='yes' n=100000          ***     11.62 %       ±2.35% ±3.13% ±4.08%
streams/writable-manywrites.js len=1024 callback='yes' writev='yes' sync='no' n=100000          ***      3.82 %       ±1.59% ±2.12% ±2.78%
streams/writable-manywrites.js len=1024 callback='yes' writev='yes' sync='yes' n=100000         ***     14.31 %       ±3.41% ±4.56% ±5.99%
streams/writable-manywrites.js len=32768 callback='no' writev='no' sync='no' n=100000           ***      6.87 %       ±2.67% ±3.55% ±4.63%
streams/writable-manywrites.js len=32768 callback='no' writev='no' sync='yes' n=100000          ***      7.86 %       ±2.17% ±2.90% ±3.79%
streams/writable-manywrites.js len=32768 callback='no' writev='yes' sync='no' n=100000          ***      8.60 %       ±4.29% ±5.74% ±7.53%
streams/writable-manywrites.js len=32768 callback='no' writev='yes' sync='yes' n=100000         ***      7.28 %       ±2.42% ±3.24% ±4.26%
streams/writable-manywrites.js len=32768 callback='yes' writev='no' sync='no' n=100000          ***      6.23 %       ±1.55% ±2.07% ±2.69%
streams/writable-manywrites.js len=32768 callback='yes' writev='no' sync='yes' n=100000         ***     10.18 %       ±1.71% ±2.28% ±2.98%
streams/writable-manywrites.js len=32768 callback='yes' writev='yes' sync='no' n=100000         ***      5.76 %       ±1.70% ±2.26% ±2.95%
streams/writable-manywrites.js len=32768 callback='yes' writev='yes' sync='yes' n=100000        ***     10.23 %       ±2.66% ±3.55% ±4.64%

@ronag ronag requested review from benjamingr and mcollina October 2, 2023 10:06
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@ronag ronag added the stream Issues and PRs related to the stream subsystem. label Oct 2, 2023
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Oct 2, 2023
ronag added a commit to nxtedition/node that referenced this pull request Oct 2, 2023
@ronag
Copy link
Member Author

ronag commented Oct 2, 2023

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

ronag added a commit to nxtedition/node that referenced this pull request Oct 2, 2023
} else {
state.pendingcb--;
finishMaybe(stream, state, true);
if ((state.state & kEnding) !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may as well optimize needFinish?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more about inlining.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could maybe inline needFinish but that would impact readability for little gain

@ronag ronag force-pushed the writable-opt branch 2 times, most recently from 1dfbfb5 to dc1debf Compare October 2, 2023 10:22
Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@ronag
Copy link
Member Author

ronag commented Oct 2, 2023

@ronag ronag added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Oct 2, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 2, 2023
@nodejs-github-bot
Copy link
Collaborator

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 2, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 2, 2023
@nodejs-github-bot
Copy link
Collaborator

@benjamingr
Copy link
Member

The Node.js streams team keeps on optimizing Writable and Readable streams with more double-digit performance gains. In this version streams maintainer Robert Nagy lead an effort to further optimize streams by reducing the number of checks performed, using bitmaps and scheduling callbacks in a more clever way.

^ This is assuming the other streams changes land in the next version too

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 4, 2023
@nodejs-github-bot nodejs-github-bot merged commit 95b8f5d into nodejs:main Oct 4, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 95b8f5d

@RafaelGSS
Copy link
Member

The Node.js streams team keeps on optimizing Writable and Readable streams with more double-digit performance gains. In this version streams maintainer Robert Nagy lead an effort to further optimize streams by reducing the number of checks performed, using bitmaps and scheduling callbacks in a more clever way.

^ This is assuming the other streams changes land in the next version too

@benjamingr which other streams changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants