-
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
buffer,util: refactor for performance #12153
Conversation
internal/util.js definied toInteger() and toLength() but they were only used by buffer.js. Inlining these small functions results in a small but statistically-significant performance gain.
$ node benchmark/compare.js --old /var/tmp/node-master --new /var/tmp/node-new --filter buffer-from --set 'source=arraybuffer' --set 'source=arraybuffer-middle' buffers > /var/tmp/compare.csv
[00:01:09|% 100| 1/1 files | 60/60 runs | 4/4 configs]: Done
$ cat /var/tmp/compare.csv | Rscript benchmark/compare.R
improvement confidence p.value
buffers/buffer-from.js n=1024 len=10 source="arraybuffer-middle" 7.12 % *** 1.415439e-18
buffers/buffer-from.js n=1024 len=10 source="arraybuffer" 0.05 % 9.482883e-01
buffers/buffer-from.js n=1024 len=2048 source="arraybuffer-middle" 4.91 % ** 2.134363e-03
buffers/buffer-from.js n=1024 len=2048 source="arraybuffer" 0.94 % 2.267840e-01
$ |
I thought the idea was to use these in other places @thefourtheye ? |
@cjihrig ... I'm sure it could be, but until there's a need for that, this should be fine. We can revert this if it proves necessary. |
internal/util.js definied toInteger() and toLength() but they were only used by buffer.js. Inlining these small functions results in a small but statistically-significant performance gain. PR-URL: #12153 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 1e6186e |
cc @Trott |
internal/util.js definied toInteger() and toLength() but they were only used by buffer.js. Inlining these small functions results in a small but statistically-significant performance gain. PR-URL: nodejs#12153 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
internal/util.js definied toInteger() and toLength() but they were only used by buffer.js. Inlining these small functions results in a small but statistically-significant performance gain. PR-URL: nodejs#12153 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
internal/util.js definied toInteger() and toLength() but they were only used by buffer.js. Inlining these small functions results in a small but statistically-significant performance gain. PR-URL: #12153 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
should we backport to v6.x? I've added the baking label as we should wait a bit if it is going to land |
I am going to take a wild guess here. The performance improvement seen here could be because of the hidden |
@MylesBorins Backport to v6.x PR: #13046 |
internal/util.js defined toInteger() and toLength() but they were only used by buffer.js. Inlining these small functions results in a small but statistically-significant performance gain. PR-URL: nodejs#12153 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
internal/util.js
definiedtoInteger()
andtoLength()
but they were onlyused by
lib/buffer.js
. Inlining these small functions results in a small butstatistically-significant performance gain.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
buffer util