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

crypto: use new.target instead of instaceof to detect construct calls #51026

Merged
merged 3 commits into from
Dec 5, 2023

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Dec 3, 2023

The former is much more performant.

Refs: nodejs/performance#136

On macOS + M2:

                                                                                confidence improvement accuracy (*)   (**)  (***)
crypto/webcrypto-digest.js n=100000 method='SHA-1' data=10 sync='createHash'           ***      4.19 %       ±1.05% ±1.40% ±1.84%
crypto/webcrypto-digest.js n=100000 method='SHA-1' data=100 sync='createHash'          ***      4.83 %       ±0.64% ±0.85% ±1.10%
crypto/webcrypto-digest.js n=100000 method='SHA-1' data=20 sync='createHash'            **      3.77 %       ±2.59% ±3.49% ±4.62%
crypto/webcrypto-digest.js n=100000 method='SHA-1' data=50 sync='createHash'           ***      5.10 %       ±0.56% ±0.75% ±0.98%
crypto/webcrypto-digest.js n=100000 method='SHA-256' data=10 sync='createHash'         ***      5.82 %       ±2.27% ±3.05% ±4.04%
crypto/webcrypto-digest.js n=100000 method='SHA-256' data=100 sync='createHash'        ***      5.86 %       ±2.46% ±3.31% ±4.37%
crypto/webcrypto-digest.js n=100000 method='SHA-256' data=20 sync='createHash'         ***      5.92 %       ±2.24% ±3.02% ±4.00%
crypto/webcrypto-digest.js n=100000 method='SHA-256' data=50 sync='createHash'         ***      5.67 %       ±0.50% ±0.66% ±0.87%
crypto/webcrypto-digest.js n=100000 method='SHA-384' data=10 sync='createHash'         ***      4.68 %       ±0.72% ±0.96% ±1.25%
crypto/webcrypto-digest.js n=100000 method='SHA-384' data=100 sync='createHash'        ***      5.83 %       ±2.52% ±3.39% ±4.49%
crypto/webcrypto-digest.js n=100000 method='SHA-384' data=20 sync='createHash'           *      2.91 %       ±2.73% ±3.68% ±4.88%
crypto/webcrypto-digest.js n=100000 method='SHA-384' data=50 sync='createHash'         ***      4.19 %       ±0.79% ±1.06% ±1.39%
crypto/webcrypto-digest.js n=100000 method='SHA-512' data=10 sync='createHash'          **      3.51 %       ±2.28% ±3.07% ±4.06%
crypto/webcrypto-digest.js n=100000 method='SHA-512' data=100 sync='createHash'        ***      5.01 %       ±0.54% ±0.71% ±0.93%
crypto/webcrypto-digest.js n=100000 method='SHA-512' data=20 sync='createHash'          **      4.38 %       ±2.64% ±3.53% ±4.64%
crypto/webcrypto-digest.js n=100000 method='SHA-512' data=50 sync='createHash'          **      4.01 %       ±2.40% ±3.22% ±4.26%
crypto/create-hash.js n=100000        ***      6.77 %       ±3.00% ±3.99% ±5.20%

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Dec 3, 2023
@joyeecheung
Copy link
Member Author

@targos
Copy link
Member

targos commented Dec 3, 2023

There's a typo in the commit message (instaceof)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

benchmark/crypto/create-hash.js Outdated Show resolved Hide resolved
@tniessen
Copy link
Member

tniessen commented Dec 3, 2023

As usual, amazing work @joyeecheung :)

…t calls

Co-authored-by: Vinicius Lourenço <12551007+H4ad@users.noreply.github.com>
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 3, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 3, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@joyeecheung joyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Dec 5, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 5, 2023
@nodejs-github-bot nodejs-github-bot merged commit c97322a into nodejs:main Dec 5, 2023
56 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in c97322a

RafaelGSS pushed a commit that referenced this pull request Dec 15, 2023
PR-URL: #51026
Refs: nodejs/performance#136
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Dec 15, 2023
richardlau pushed a commit that referenced this pull request Mar 25, 2024
PR-URL: #51026
Refs: nodejs/performance#136
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@richardlau richardlau mentioned this pull request Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants