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

benchmark: Add NodeError and Error benchmark #43077

Closed
wants to merge 1 commit into from

Conversation

RafaelGSS
Copy link
Member

While investigating fetch performance (nodejs/undici#1203 (comment)) I've found that NodeError is a bottleneck in WebStreams.

I created this Pull Request to share the insights and help as I can to improve the NodeError performance. We can use this PR thread to discuss approaches to solve it.

For reference, this is the benchmark result I'm getting:

  *-cpu
       description: CPU
       product: AMD Ryzen 5 3500X 6-Core Processor
       vendor: Advanced Micro Devices [AMD]
       physical id: 2f
       bus info: cpu@0
       version: AMD Ryzen 5 3500X 6-Core Processor
       serial: Unknown
       slot: AM4
       size: 4030MHz
       capacity: 4100MHz
       width: 64 bits
       clock: 100MHz
rafaelgss@rafaelgss-desktop:~/repos/os/node$ ./node benchmark/error/error.js
error/error.js disableEntropyCache=0 n=10000000: 506,239.3888750024
error/error.js disableEntropyCache=1 n=10000000: 490,143.20360859093
rafaelgss@rafaelgss-desktop:~/repos/os/node$ ./node benchmark/error/node-error.js
error/node-error.js disableEntropyCache=0 n=10000000: 159,137.83392330573
error/node-error.js disableEntropyCache=1 n=10000000: 159,349.56687673234

cc: @jasnell @mcollina

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels May 12, 2022
@RafaelGSS RafaelGSS added discuss Issues opened for discussions and feedbacks. and removed util Issues and PRs related to the built-in util module. labels May 12, 2022
@RafaelGSS
Copy link
Member Author

Furthermore, I can go deeper into the analysis and share my thoughts here.

lib/util.js Outdated Show resolved Hide resolved
@mscdex
Copy link
Contributor

mscdex commented May 12, 2022

What is the purpose of disableEntropyCache?

@RafaelGSS RafaelGSS force-pushed the benchmark/node-error branch 2 times, most recently from 7a0b11e to f5ece4a Compare May 24, 2022 14:47
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

@RafaelGSS
Copy link
Member Author

Well, lately I have had no time to investigate/improve how the NodeError is managed. I think it's ready to land with just the benchmark. I plan to back to it whenever I have free time.

A few insights to solve it can be found in: nodejs/undici#1203 (comment).

@RafaelGSS RafaelGSS marked this pull request as ready for review May 24, 2022 15:04
@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label May 24, 2022
@RafaelGSS RafaelGSS changed the title bench: node-error benchmark benchmark: Add NodeError and Error benchmark May 24, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 24, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS RafaelGSS added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 25, 2022
@aduh95
Copy link
Contributor

aduh95 commented May 25, 2022

@RafaelGSS RafaelGSS force-pushed the benchmark/node-error branch from f5ece4a to 64fc8c1 Compare May 25, 2022 20:28
@aduh95
Copy link
Contributor

aduh95 commented May 25, 2022

@aduh95
Copy link
Contributor

aduh95 commented May 25, 2022

Can you add a test, similarly as

'use strict';
require('../common');
const runBenchmark = require('../common/benchmark');
runBenchmark('misc', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

Copy link
Member

@juanarbol juanarbol left a comment

Choose a reason for hiding this comment

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

LGTM

@RafaelGSS RafaelGSS force-pushed the benchmark/node-error branch from 64fc8c1 to df87435 Compare May 25, 2022 23:56
@RafaelGSS
Copy link
Member Author

Can you add a test, similarly as

'use strict';
require('../common');
const runBenchmark = require('../common/benchmark');
runBenchmark('misc', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

Just did, I knew I was forgetting something.

@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label May 26, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 26, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS RafaelGSS force-pushed the benchmark/node-error branch from df87435 to da88923 Compare May 27, 2022 11:47
@RafaelGSS
Copy link
Member Author

Just rebased on master to check if the flaky tests are gone

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS RafaelGSS added the commit-queue Add this label to land a pull request using GitHub Actions. label May 30, 2022
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels May 30, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/43077
✔  Done loading data for nodejs/node/pull/43077
----------------------------------- PR info ------------------------------------
Title      benchmark: Add NodeError and Error benchmark (#43077)
Author     Rafael Gonzaga  (@RafaelGSS)
Branch     RafaelGSS:benchmark/node-error -> nodejs:master
Labels     discuss, author ready, needs-ci
Commits    1
 - benchmark: add node-error benchmark
Committers 1
 - RafaelGSS 
PR-URL: https://github.com/nodejs/node/pull/43077
Reviewed-By: Matteo Collina 
Reviewed-By: Juan José Arboleda 
Reviewed-By: Antoine du Hamel 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/43077
Reviewed-By: Matteo Collina 
Reviewed-By: Juan José Arboleda 
Reviewed-By: Antoine du Hamel 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - benchmark: add node-error benchmark
   ℹ  This PR was created on Thu, 12 May 2022 19:26:45 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/43077#pullrequestreview-983394804
   ✔  - Juan José Arboleda (@juanarbol): https://github.com/nodejs/node/pull/43077#pullrequestreview-985584535
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/43077#pullrequestreview-985886311
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-05-29T18:37:24Z: https://ci.nodejs.org/job/node-test-pull-request/44228/
   ℹ  Last Benchmark CI on 2022-05-25T23:03:58Z: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1145/
- Querying data for job/node-test-pull-request/44228/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/2409007414

@RafaelGSS RafaelGSS removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. discuss Issues opened for discussions and feedbacks. labels May 30, 2022
RafaelGSS added a commit that referenced this pull request May 30, 2022
PR-URL: #43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@RafaelGSS
Copy link
Member Author

Landed in 0903515

@RafaelGSS RafaelGSS closed this May 30, 2022
bengl pushed a commit that referenced this pull request May 30, 2022
PR-URL: #43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@bengl bengl mentioned this pull request May 31, 2022
F3n67u pushed a commit to F3n67u/node that referenced this pull request Jun 1, 2022
PR-URL: nodejs#43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
danielleadams pushed a commit that referenced this pull request Jun 27, 2022
PR-URL: #43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#43077
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
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. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants