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

buffer: improve equals() performance #29199

Closed
wants to merge 1 commit into from

Conversation

@mscdex
Copy link
Contributor

commented Aug 19, 2019

Results:

                                                            confidence improvement accuracy (*)   (**)  (***)
 buffers/buffer-equals.js n=10000000 difflen='false' size=0          ***    520.06 %       ±1.38%  ±1.85%   ±2.44%
 buffers/buffer-equals.js n=10000000 difflen='true' size=0           ***    674.98 %       ±2.18%  ±2.92%   ±3.85%
 buffers/buffer-equals.js n=10000000 difflen='true' size=16          ***    874.14 %       ±5.80%  ±7.81%  ±10.36%
 buffers/buffer-equals.js n=10000000 difflen='true' size=512         ***   1072.12 %       ±6.67%  ±8.98%  ±11.92%
 buffers/buffer-equals.js n=10000000 difflen='true' size=4096        ***   2569.30 %       ±4.33%  ±5.83%   ±7.74%
 buffers/buffer-equals.js n=4000000 difflen='true' size=16386        ***   7526.00 %      ±32.02% ±43.15%  ±57.28%

I'm not sure offhand what's up with the large variance for size=16386, especially since trying the same n 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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
@nodejs-github-bot

This comment has been minimized.

@mscdex mscdex force-pushed the mscdex:buffer-equals-perf branch from cf617f4 to 8ffa33f Aug 19, 2019

@nodejs-github-bot

This comment has been minimized.

@targos
targos approved these changes Aug 19, 2019
const common = require('../common.js');

const bench = common.createBenchmark(main, {
size: [0, 16, 512, 4096, 16386],

This comment has been minimized.

Copy link
@BridgeAR

BridgeAR Aug 19, 2019

Member

It should be sufficient to just keep e.g., 0, 512 and 16386. The other options are just intermediate steps.

This comment has been minimized.

Copy link
@mscdex

mscdex Aug 19, 2019

Author Contributor

FWIW I copied this from buffer-compare.js, does that mean that should be changed as well?

This comment has been minimized.

Copy link
@BridgeAR

BridgeAR Aug 20, 2019

Member

That would IMO be ideal 👍

@ZYSzys
ZYSzys approved these changes Aug 19, 2019
@lpinca
lpinca approved these changes Aug 19, 2019
@Trott

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Need to add difflen to test/benchmark/test-benchmark-buffer so that it still passes?

@Trott

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Need to add difflen to test/benchmark/test-benchmark-buffer so that it still passes?

Confirmed. This is needed. I tried to add a fixup commit but I don't have permission to the branch.

@Trott
Copy link
Member

left a comment

LGTM but needs a change to avoid breaking test-benchmark-buffer

@mscdex

This comment has been minimized.

Copy link
Contributor Author

commented Aug 21, 2019

Shouldn't the test fail if it was breaking?

@mscdex mscdex force-pushed the mscdex:buffer-equals-perf branch from 8ffa33f to f3f3b97 Aug 21, 2019

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@Trott

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Shouldn't the test fail if it was breaking?

benchmark tests only run nightly in CI and only if you run make test-all locally. I'd be +1 on running them a bit more widely, but we scaled it back when people complained about tests taking too long and benchmark test in particular being unreliable in certain environments, IIRC.

@@ -26,6 +26,7 @@ runBenchmark('buffers',
'source=array',
'type=',
'value=0',
'withTotalLength=0'
'withTotalLength=0',
'difflen=false'

This comment has been minimized.

Copy link
@Trott

Trott Aug 21, 2019

Member

Super minor optional nit: The rest of the options are alphabetized. Can this go after line 14 intstead?

@Trott
Trott approved these changes Aug 21, 2019
Copy link
Member

left a comment

LGTM with or without my additional optional nit

@mscdex mscdex force-pushed the mscdex:buffer-equals-perf branch from f3f3b97 to c7fe371 Aug 22, 2019

@mscdex mscdex force-pushed the mscdex:buffer-equals-perf branch from c7fe371 to 36f9f73 Aug 22, 2019

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@Trott

This comment has been minimized.

Copy link
Member

commented Aug 22, 2019

Landed in f0c8898

@Trott Trott closed this Aug 22, 2019

Trott added a commit to Trott/io.js that referenced this pull request Aug 22, 2019
buffer: improve equals() performance
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>

@mscdex mscdex deleted the mscdex:buffer-equals-perf branch Aug 22, 2019

ronag added a commit to nxtedition/node that referenced this pull request Aug 23, 2019
buffer: improve equals() performance
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>
BridgeAR added a commit that referenced this pull request Sep 3, 2019
buffer: improve equals() performance
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>
@BridgeAR BridgeAR referenced this pull request Sep 3, 2019
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
buffer: improve equals() performance
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>
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
buffer: improve equals() performance
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.