-
Notifications
You must be signed in to change notification settings - Fork 30k
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: improve equals() performance #29199
Conversation
cf617f4
to
8ffa33f
Compare
benchmark/buffers/buffer-equals.js
Outdated
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
size: [0, 16, 512, 4096, 16386], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be sufficient to just keep e.g., 0
, 512
and 16386
. The other options are just intermediate steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I copied this from buffer-compare.js
, does that mean that should be changed as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would IMO be ideal 👍
Need to add |
Confirmed. This is needed. I tried to add a fixup commit but I don't have permission to the branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but needs a change to avoid breaking test-benchmark-buffer
Shouldn't the test fail if it was breaking? |
8ffa33f
to
f3f3b97
Compare
benchmark tests only run nightly in CI and only if you run |
@@ -26,6 +26,7 @@ runBenchmark('buffers', | |||
'source=array', | |||
'type=', | |||
'value=0', | |||
'withTotalLength=0' | |||
'withTotalLength=0', | |||
'difflen=false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor optional nit: The rest of the options are alphabetized. Can this go after line 14 intstead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with or without my additional optional nit
f3f3b97
to
c7fe371
Compare
c7fe371
to
36f9f73
Compare
Landed in f0c8898 |
PR-URL: nodejs#29199 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #29199 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Results:
I'm not sure offhand what's up with the large variance for
size=16386
, especially since trying the samen
value as the other cases actually resulted in an even larger variance. Anyway, the actual numbers don't really matter so much as the trend.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes