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 copy() performance #33214

Closed
wants to merge 2 commits into from
Closed

buffer: improve copy() performance #33214

wants to merge 2 commits into from

Conversation

seishun
Copy link
Contributor

@seishun seishun commented May 2, 2020

There is no need to create a slice when sourceEnd is out of bounds.

Results of included benchmark:

                                                                           confidence improvement accuracy (*)     (**)    (***)
 buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=0                     3.30 %      ±4.96%  ±6.62%  ±8.65%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=128                  -0.66 %      ±3.54%  ±4.71%  ±6.13%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=32768                -3.02 %      ±8.44% ±11.30% ±14.83%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=8                     2.80 %      ±5.54%  ±7.37%  ±9.61%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=0                      2.29 %      ±4.58%  ±6.10%  ±7.98%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=128                    1.90 %      ±3.39%  ±4.52%  ±5.88%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=32768                  0.23 %      ±7.59% ±10.10% ±13.16%
 buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=8                      2.75 %      ±4.06%  ±5.42%  ±7.07%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=0                      2.68 %      ±4.89%  ±6.52%  ±8.50%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=128           ***    135.43 %      ±7.70% ±10.31% ±13.57%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=32768           *      5.98 %      ±4.85%  ±6.46%  ±8.40%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=8             ***    142.55 %     ±10.22% ±13.71% ±18.06%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=0                       4.42 %      ±4.67%  ±6.26%  ±8.23%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=128                     0.66 %      ±2.75%  ±3.66%  ±4.77%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=32768                  -1.10 %      ±7.26%  ±9.67% ±12.59%
 buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=8                       2.74 %      ±3.92%  ±5.23%  ±6.82%
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

There is no need to create a slice when sourceEnd is out of bounds.
@nodejs-github-bot nodejs-github-bot added the buffer Issues and PRs related to the buffer subsystem. label May 2, 2020
@seishun seishun requested a review from mscdex May 2, 2020 17:39
@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 7, 2020
@nodejs-github-bot
Copy link
Collaborator

addaleax pushed a commit that referenced this pull request May 9, 2020
There is no need to create a slice when sourceEnd is out of bounds.

PR-URL: #33214
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@addaleax
Copy link
Member

addaleax commented May 9, 2020

Landed in 339690c

@addaleax addaleax closed this May 9, 2020
@seishun seishun deleted the buffer-copy-perf branch May 9, 2020 14:06
codebytere pushed a commit that referenced this pull request May 11, 2020
There is no need to create a slice when sourceEnd is out of bounds.

PR-URL: #33214
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@codebytere codebytere mentioned this pull request May 18, 2020
codebytere pushed a commit that referenced this pull request Jun 7, 2020
There is no need to create a slice when sourceEnd is out of bounds.

PR-URL: #33214
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@codebytere codebytere mentioned this pull request Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants