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

@mscdex mscdex 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

@mscdex mscdex added buffer Issues and PRs related to the buffer subsystem. performance Issues and PRs related to the performance of Node.js. labels Aug 19, 2019
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

const common = require('../common.js');

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

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.

Copy link
Contributor Author

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?

Copy link
Member

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 👍

@Trott
Copy link
Member

Trott commented Aug 21, 2019

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

@Trott
Copy link
Member

Trott 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.

Copy link
Member

@Trott Trott 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 needs a change to avoid breaking test-benchmark-buffer

@mscdex
Copy link
Contributor Author

mscdex commented Aug 21, 2019

Shouldn't the test fail if it was breaking?

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott 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'
Copy link
Member

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?

Copy link
Member

@Trott Trott 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 or without my additional optional nit

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Aug 22, 2019

Landed in f0c8898

@Trott Trott closed this Aug 22, 2019
Trott pushed a commit to Trott/io.js that referenced this pull request Aug 22, 2019
PR-URL: nodejs#29199
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@mscdex mscdex deleted the buffer-equals-perf branch August 22, 2019 12:51
BridgeAR pushed a commit that referenced this pull request Sep 3, 2019
PR-URL: #29199
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants