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: augment BufferList.prototype #18353

Closed
wants to merge 1 commit into from

Conversation

lpinca
Copy link
Member

@lpinca lpinca commented Jan 24, 2018

For SoC/readability and to facilitate refactoring if the BufferList underlying data structure is changed.

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
Affected core subsystem(s)

stream

Move functions that deal with `BufferList` to `BufferList.prototype`.
@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to the stream subsystem. label Jan 24, 2018
@lpinca
Copy link
Member Author

lpinca commented Jan 24, 2018

[luigi@fedora node]$ cat compare.csv | Rscript benchmark/compare.R 
                                                       improvement confidence      p.value
 streams/readable-bigread.js n=1000                        -0.18 %            5.909677e-01
 streams/readable-bigunevenread.js n=1000                   1.19 %        *** 5.431321e-04
 streams/readable-boundaryread.js type="buffer" n=2000     -0.20 %            5.733284e-01
 streams/readable-boundaryread.js type="string" n=2000      4.16 %        *** 2.807485e-08
 streams/readable-readall.js n=5000                         0.35 %            7.158884e-01
 streams/readable-unevenread.js n=1000                      1.34 %        *** 1.184393e-07
 streams/transform-creation.js n=1000000                    1.32 %            1.789189e-01
 streams/writable-manywrites.js n=2000000                   4.14 %        *** 3.774978e-09

Not sure where the 4% improvement of streams/writable-manywrites.js comes from since this doesn't touch writable.

Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

LGTM but can we either hide _getString & _getBuffer behind a symbol or make them helper functions (that accept the class instance as first argument)? I don't want to accidentally end up in a universe where someone starts using those methods and we have to support them.

(I would almost lean towards them being helper functions since there's only one place they're used.)

@lpinca
Copy link
Member Author

lpinca commented Jan 25, 2018

@apapirovski I didn't use symbols because that is an internal module.

@apapirovski
Copy link
Member

@lpinca The problem is that we can access BufferList instances via stream internals which are exposed, right? (I'm not saying it's smart to do so but I would just prefer to even not have a chance of ending up in that situation. That said, if no one else cares then I'm fine with this staying as is – hence my approval.)

@lpinca
Copy link
Member Author

lpinca commented Jan 25, 2018

Yes but by that logic all BufferList methods should be helper functions as the user should not use them. I mean the same argument is also valid for shift, clear and direct access to BufferList properties.

@apapirovski
Copy link
Member

apapirovski commented Jan 25, 2018

@lpinca true enough. 👍 It was probably the _ in the name that made me start thinking along this path.

(To be clear: I'm fine with this remaining as is. You're completely right.)

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 31, 2018
@BridgeAR
Copy link
Member

@BridgeAR
Copy link
Member

BridgeAR commented Feb 1, 2018

Landed in ccf64e5

@BridgeAR BridgeAR closed this Feb 1, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Feb 1, 2018
Move functions that deal with `BufferList` to `BufferList.prototype`.

PR-URL: nodejs#18353
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@lpinca lpinca deleted the augment/buffer-list-prototype branch February 1, 2018 11:30
@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 4, 2018
@MylesBorins
Copy link
Contributor

Should this be backported to v9.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 1, 2018
Move functions that deal with `BufferList` to `BufferList.prototype`.

PR-URL: nodejs#18353
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Move functions that deal with `BufferList` to `BufferList.prototype`.

PR-URL: nodejs#18353
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants