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 performance caused by primordials #30235

Closed
wants to merge 3 commits into from

Conversation

jizusun
Copy link
Contributor

@jizusun jizusun commented Nov 3, 2019

This is my first try, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Benchmark compared with master version using the methods mentioned here

Perf Comparison

                                                                                confidence improvement accuracy (*)    (**)   (***)
 buffers/buffer-compare-offset.js n=1000000 size=16 method='offset'                            -2.56 %       ±5.19%  ±6.93%  ±9.07%
 buffers/buffer-compare-offset.js n=1000000 size=16 method='slice'                     ***     17.14 %       ±4.95%  ±6.60%  ±8.60%
 buffers/buffer-compare-offset.js n=1000000 size=16386 method='offset'                         -1.76 %       ±4.77%  ±6.35%  ±8.26%
 buffers/buffer-compare-offset.js n=1000000 size=16386 method='slice'                  ***     21.40 %       ±6.61%  ±8.81% ±11.50%
 buffers/buffer-compare-offset.js n=1000000 size=4096 method='offset'                           1.69 %       ±5.34%  ±7.12%  ±9.28%
 buffers/buffer-compare-offset.js n=1000000 size=4096 method='slice'                   ***     20.82 %       ±5.64%  ±7.52%  ±9.84%
 buffers/buffer-compare-offset.js n=1000000 size=512 method='offset'                           -1.59 %       ±5.90%  ±7.86% ±10.26%
 buffers/buffer-compare-offset.js n=1000000 size=512 method='slice'                    ***     20.01 %       ±4.67%  ±6.22%  ±8.10%

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Fixes: nodejs#29766
Refs: nodejs/code-and-learn#97
Refs: nodejs#29633
@nodejs-github-bot nodejs-github-bot added the buffer Issues and PRs related to the buffer subsystem. label Nov 3, 2019
lib/buffer.js Outdated
@@ -21,7 +21,8 @@

'use strict';

const { Math, Object } = primordials;
const { Object: { defineProperties, defineProperty, setPrototypeOf, create } } = primordials;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run make lint? It would usually complain about a line longer than 80 characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good afternoon 😃
Oh what a quick feedback!
Thank you♥️
I'll fix it when I'm back home.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing to ask for help, what's the correct way to do prettify? Normally I have prettier set up with eslint, but I didn't find similar in the Makefile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make lint-js-fix :)

Copy link
Contributor Author

@jizusun jizusun Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I mean, for the max-len rule, the eslint --fix cannot help.
So I have to correct it by myself, right?

@gireeshpunathil gireeshpunathil added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Nov 3, 2019
@jizusun
Copy link
Contributor Author

jizusun commented Nov 3, 2019

I think I also need to include a benchmark section to make my first PR better 😏 , but I don't have time today.
I'll dive deep into it tomorrow.


benchmark attached

lib/buffer.js Outdated Show resolved Hide resolved
Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % one nit in comments.

lib/buffer.js Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@jizusun
Copy link
Contributor Author

jizusun commented Nov 4, 2019

Dear all reviewers,

I saw the several builds fails in Jenkins, and one build node-test-commit-freefsd fails because

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Do you think it's because of my change or the job is not stable (ignore it / re-trigger it)?

@nodejs-github-bot
Copy link
Collaborator

@gireeshpunathil
Copy link
Member

@jizusun - we have seen that earlier and reported in #29802 , so don't worry about that.

ZYSzys pushed a commit that referenced this pull request Nov 4, 2019
This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

PR-URL: #30235
Refs: #29766
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@ZYSzys
Copy link
Member

ZYSzys commented Nov 4, 2019

Landed in 22799be.

Thanks for the contribution! 🎉

(If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.)

@ZYSzys ZYSzys closed this Nov 4, 2019
targos pushed a commit that referenced this pull request Nov 5, 2019
This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

PR-URL: #30235
Refs: #29766
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@targos targos mentioned this pull request Nov 5, 2019
targos pushed a commit that referenced this pull request Nov 8, 2019
This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

PR-URL: #30235
Refs: #29766
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Nov 10, 2019
This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

PR-URL: #30235
Refs: #29766
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Nov 10, 2019
This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

PR-URL: #30235
Refs: #29766
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Nov 11, 2019
This is my first PR, and it's based on the code-and-learn guidances
This restore some performance after introducing primordialias.

Refs: #29766
Refs: nodejs/code-and-learn#97
Refs: #29633

PR-URL: #30235
Refs: #29766
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
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. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants