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

stream: refactor Writable buffering #31046

Closed
wants to merge 1 commit into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Dec 20, 2019

Another try on this, now without the reduced performance:

 streams/writable-manywrites.js callback='no' writev='no' sync='no' n=2000000           ***      8.49 %       ±1.42% ±1.88% ±2.42%
 streams/writable-manywrites.js callback='no' writev='no' sync='yes' n=2000000                   0.28 %       ±1.38% ±1.84% ±2.40%
 streams/writable-manywrites.js callback='no' writev='yes' sync='no' n=2000000          ***     36.63 %       ±3.10% ±4.09% ±5.28%
 streams/writable-manywrites.js callback='no' writev='yes' sync='yes' n=2000000                 -0.72 %       ±2.57% ±3.42% ±4.46%
 streams/writable-manywrites.js callback='yes' writev='no' sync='no' n=2000000          ***      6.75 %       ±1.16% ±1.54% ±1.99%
 streams/writable-manywrites.js callback='yes' writev='no' sync='yes' n=2000000                 -0.67 %       ±1.86% ±2.48% ±3.23%
 streams/writable-manywrites.js callback='yes' writev='yes' sync='no' n=2000000         ***     10.91 %       ±1.75% ±2.33% ±3.02%
 streams/writable-manywrites.js callback='yes' writev='yes' sync='yes' n=2000000                -1.70 %       ±2.71% ±3.61% ±4.70%

Benchmarks from #31066

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to the stream subsystem. label Dec 20, 2019
@ronag ronag force-pushed the stream-writable-buffered2 branch 4 times, most recently from 24f8b15 to 0c9b7e7 Compare December 20, 2019 22:20
@mscdex
Copy link
Contributor

mscdex commented Dec 21, 2019

Might be a good idea to check CITGM to check for dependencies on the old internal state properties?

@ronag
Copy link
Member Author

ronag commented Dec 21, 2019

@mscdex: I noticed that using symbol accessors seems slower than regular properties. Is this something we are aware of or am I just unlucky in my benchmarks?

@ronag

This comment has been minimized.

@ronag ronag force-pushed the stream-writable-buffered2 branch 5 times, most recently from bd5e468 to 3df92f4 Compare December 23, 2019 15:27
benchmark/streams/writable-manywrites.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Dec 25, 2019

@ronag
Copy link
Member Author

ronag commented Jan 1, 2020

rebased to fix conflicts

@ronag ronag force-pushed the stream-writable-buffered2 branch 3 times, most recently from 5b9a81c to b161293 Compare January 1, 2020 14:23
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

This looks very promising!

lib/_stream_writable.js Show resolved Hide resolved
lib/_stream_writable.js Show resolved Hide resolved
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM with a green CITGM.

lib/_stream_writable.js Show resolved Hide resolved
@ronag ronag removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 22, 2020
@mafintosh
Copy link
Member

LGTM on green canary

@ronag ronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 23, 2020
@ronag
Copy link
Member Author

ronag commented Apr 23, 2020

@ronag
Copy link
Member Author

ronag commented Apr 23, 2020

CITGM OK. ws failure is expected and not related to this PR.

@ronag

This comment has been minimized.

ronag added a commit that referenced this pull request Apr 23, 2020
Refactors buffering in Writable to use an array
instead of a linked list.

PR-URL: #31046
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@ronag
Copy link
Member Author

ronag commented Apr 23, 2020

Landed in d8c57cb

@ronag ronag closed this Apr 23, 2020
@mscdex
Copy link
Contributor

mscdex commented Apr 23, 2020

There seems to have been some significant performance regressions with the latest changes:

                                                                                confidence improvement accuracy (*)   (**)  (***)
streams/creation.js kind='duplex' n=50000000                                             *      2.44 %       ±1.87% ±2.49% ±3.25%
streams/creation.js kind='readable' n=50000000                                                  0.57 %       ±3.10% ±4.12% ±5.36%
streams/creation.js kind='transform' n=50000000                                          *      3.44 %       ±2.81% ±3.73% ±4.86%
streams/creation.js kind='writable' n=50000000                                         ***      8.08 %       ±3.53% ±4.70% ±6.12%
streams/pipe.js n=5000000                                                                       1.95 %       ±3.32% ±4.43% ±5.81%
streams/pipe-object-mode.js n=5000000                                                   **      4.76 %       ±3.29% ±4.40% ±5.78%
streams/readable-bigread.js n=1000                                                             -0.19 %       ±3.43% ±4.57% ±5.97%
streams/readable-bigunevenread.js n=1000                                                        0.49 %       ±2.05% ±2.73% ±3.56%
streams/readable-boundaryread.js type='buffer' n=2000                                           0.98 %       ±2.30% ±3.06% ±3.99%
streams/readable-boundaryread.js type='string' n=2000                                           0.32 %       ±1.20% ±1.60% ±2.08%
streams/readable-readall.js n=5000                                                              1.62 %       ±2.92% ±3.89% ±5.09%
streams/readable-unevenread.js n=1000                                                          -1.05 %       ±2.03% ±2.70% ±3.53%
streams/writable-manywrites.js callback='no' writev='no' sync='no' n=2000000           ***     11.18 %       ±1.51% ±2.01% ±2.62%
streams/writable-manywrites.js callback='no' writev='no' sync='yes' n=2000000          ***    -18.20 %       ±4.62% ±6.15% ±8.01%
streams/writable-manywrites.js callback='no' writev='yes' sync='no' n=2000000          ***     24.39 %       ±2.88% ±3.85% ±5.05%
streams/writable-manywrites.js callback='no' writev='yes' sync='yes' n=2000000                  0.52 %       ±5.40% ±7.23% ±9.49%
streams/writable-manywrites.js callback='yes' writev='no' sync='no' n=2000000          ***      8.15 %       ±1.76% ±2.35% ±3.05%
streams/writable-manywrites.js callback='yes' writev='no' sync='yes' n=2000000         ***    -22.02 %       ±3.14% ±4.20% ±5.50%
streams/writable-manywrites.js callback='yes' writev='yes' sync='no' n=2000000         ***      6.31 %       ±2.80% ±3.74% ±4.87%
streams/writable-manywrites.js callback='yes' writev='yes' sync='yes' n=2000000                -1.93 %       ±3.50% ±4.66% ±6.07%

@jasnell
Copy link
Member

jasnell commented Apr 23, 2020

@ronag .... it would appear that maybe one of the handful of streams related PRs you just landed may be having some CI issues: https://ci.nodejs.org/job/node-test-commit-linux/34504/

test-stream-pipeline consistently failing on Linux...

image

@ronag
Copy link
Member Author

ronag commented Apr 23, 2020

@ronag .... it would appear that maybe one of the handful of streams related PRs you just landed may be having some CI issues: ci.nodejs.org/job/node-test-commit-linux/34504

That's strange. I'm on it.

@ronag
Copy link
Member Author

ronag commented Apr 23, 2020

All of them have green CI, so it must be that one of them made the other fail.

@jasnell
Copy link
Member

jasnell commented Apr 23, 2020

Entirely possible. Just ran the tests a second time (with a different unrelated PR) and seeing the same failures. https://ci.nodejs.org/job/node-test-commit-linux/34506/

@ronag
Copy link
Member Author

ronag commented Apr 23, 2020

Entirely possible. Just ran the tests a second time (with a different unrelated PR) and seeing the same failures. https://ci.nodejs.org/job/node-test-commit-linux/34506/

Yep, Working towards a PR to resolve it.

ronag added a commit to nxtedition/node that referenced this pull request Apr 23, 2020
While nodejs#31046 did make async
writes faster it at the same time made sync writes slower.

This PR corrects this while maintaining performance improvements.
ronag added a commit that referenced this pull request Apr 25, 2020
While #31046 did make async
writes faster it at the same time made sync writes slower.

This PR corrects this while maintaining performance improvements.

PR-URL: #33032
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
BethGriggs pushed a commit that referenced this pull request Apr 27, 2020
Refactors buffering in Writable to use an array
instead of a linked list.

PR-URL: #31046
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 27, 2020
While #31046 did make async
writes faster it at the same time made sync writes slower.

This PR corrects this while maintaining performance improvements.

PR-URL: #33032
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
@BethGriggs BethGriggs mentioned this pull request Apr 27, 2020
BethGriggs pushed a commit that referenced this pull request Apr 28, 2020
Refactors buffering in Writable to use an array
instead of a linked list.

PR-URL: #31046
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 28, 2020
While #31046 did make async
writes faster it at the same time made sync writes slower.

This PR corrects this while maintaining performance improvements.

PR-URL: #33032
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
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. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.