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

lib: predeclare Event.isTrusted property descriptor #46527

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

santigimeno
Copy link
Member

It improves Event creation performance.

I'm seeing these numbers:

]$ ./node benchmark/compare.js --new ./node --old ./node_old --runs 30 --filter messageport --filter eventtarget worker events  | Rscript benchmark/compare.R
[00:08:18|% 100| 2/2 files | 60/60 runs | 3/3 configs]: Done
                                                                       confidence improvement accuracy (*)   (**)  (***)
events/eventtarget.js listeners=1 n=1000000                                  ***     20.25 %       ±1.64% ±2.18% ±2.85%
events/eventtarget.js listeners=10 n=1000000                                 ***     18.27 %       ±0.88% ±1.18% ±1.53%
events/eventtarget.js listeners=5 n=1000000                                  ***     19.13 %       ±0.96% ±1.29% ±1.71%
worker/messageport.js n=1000000 style='eventemitter' payload='object'                -0.51 %       ±1.85% ±2.46% ±3.20%
worker/messageport.js n=1000000 style='eventemitter' payload='string'                 0.44 %       ±1.12% ±1.49% ±1.94%
worker/messageport.js n=1000000 style='eventtarget' payload='object'         ***      7.18 %       ±1.62% ±2.16% ±2.81%
worker/messageport.js n=1000000 style='eventtarget' payload='string'         ***     10.79 %       ±0.99% ±1.31% ±1.71%

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Feb 6, 2023
@anonrig anonrig added the performance Issues and PRs related to the performance of Node.js. label Feb 6, 2023
@anonrig anonrig added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Feb 6, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 6, 2023
@nodejs-github-bot
Copy link
Collaborator

lib/internal/event_target.js Outdated Show resolved Hide resolved
@santigimeno santigimeno force-pushed the santi/event_descriptor branch from 7e0185e to c64f53a Compare February 6, 2023 18:56
lib/internal/event_target.js Outdated Show resolved Hide resolved
It improves Event creation performance.
@santigimeno santigimeno force-pushed the santi/event_descriptor branch from c64f53a to 2820ee9 Compare February 6, 2023 19:49
@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 6, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 6, 2023
@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor

aduh95 commented Feb 6, 2023

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1294/

Results
                                                                        confidence improvement accuracy (*)    (**)   (***)
events/ee-add-remove.js n=1000000 removeListener=0 newListener=0                        0.43 %       ±2.53%  ±3.40%  ±4.48%
events/ee-add-remove.js n=1000000 removeListener=0 newListener=1                       -0.11 %       ±1.62%  ±2.16%  ±2.81%
events/ee-add-remove.js n=1000000 removeListener=1 newListener=0                        0.31 %       ±1.17%  ±1.56%  ±2.04%
events/ee-add-remove.js n=1000000 removeListener=1 newListener=1                        0.20 %       ±1.08%  ±1.44%  ±1.87%
events/ee-emit.js listeners=1 argc=0 n=2000000                                         -3.53 %       ±4.02%  ±5.42%  ±7.18%
events/ee-emit.js listeners=1 argc=10 n=2000000                                         1.19 %       ±6.31%  ±8.40% ±10.94%
events/ee-emit.js listeners=1 argc=2 n=2000000                                         -2.07 %       ±4.10%  ±5.52%  ±7.32%
events/ee-emit.js listeners=1 argc=4 n=2000000                                          0.47 %       ±4.73%  ±6.30%  ±8.21%
events/ee-emit.js listeners=10 argc=0 n=2000000                                        -1.08 %       ±3.24%  ±4.31%  ±5.61%
events/ee-emit.js listeners=10 argc=10 n=2000000                                        0.47 %       ±2.89%  ±3.85%  ±5.01%
events/ee-emit.js listeners=10 argc=2 n=2000000                                        -0.26 %       ±2.35%  ±3.12%  ±4.08%
events/ee-emit.js listeners=10 argc=4 n=2000000                                        -1.86 %       ±4.34%  ±5.77%  ±7.52%
events/ee-emit.js listeners=5 argc=0 n=2000000                                          5.84 %       ±7.96% ±10.61% ±13.86%
events/ee-emit.js listeners=5 argc=10 n=2000000                                        -0.10 %       ±5.75%  ±7.65%  ±9.96%
events/ee-emit.js listeners=5 argc=2 n=2000000                                          0.49 %       ±7.78% ±10.35% ±13.47%
events/ee-emit.js listeners=5 argc=4 n=2000000                                         -2.79 %       ±6.36%  ±8.47% ±11.03%
events/ee-listen-unique.js n=1000000 events=1                                           0.55 %       ±1.14%  ±1.52%  ±1.98%
events/ee-listen-unique.js n=1000000 events=10                                          0.76 %       ±1.25%  ±1.67%  ±2.17%
events/ee-listen-unique.js n=1000000 events=2                                           0.35 %       ±0.85%  ±1.13%  ±1.47%
events/ee-listen-unique.js n=1000000 events=20                                         -0.26 %       ±1.77%  ±2.36%  ±3.07%
events/ee-listen-unique.js n=1000000 events=3                                          -1.00 %       ±1.51%  ±2.02%  ±2.65%
events/ee-listen-unique.js n=1000000 events=5                                          -0.72 %       ±1.32%  ±1.77%  ±2.30%
events/ee-listener-count-on-prototype.js n=50000000                                     1.49 %       ±1.94%  ±2.59%  ±3.37%
events/ee-listeners.js raw='false' listeners=5 n=5000000                                0.93 %       ±2.73%  ±3.63%  ±4.73%
events/ee-listeners.js raw='false' listeners=50 n=5000000                              -0.88 %       ±2.66%  ±3.54%  ±4.61%
events/ee-listeners.js raw='true' listeners=5 n=5000000                                -1.96 %       ±7.83% ±10.42% ±13.56%
events/ee-listeners.js raw='true' listeners=50 n=5000000                               -0.46 %       ±2.85%  ±3.79%  ±4.94%
events/ee-once.js argc=0 n=20000000                                                    -0.61 %       ±1.35%  ±1.82%  ±2.39%
events/ee-once.js argc=1 n=20000000                                                     0.38 %       ±0.65%  ±0.86%  ±1.14%
events/ee-once.js argc=4 n=20000000                                                     0.52 %       ±1.72%  ±2.32%  ±3.07%
events/ee-once.js argc=5 n=20000000                                                    -0.73 %       ±1.33%  ±1.77%  ±2.32%
events/eventtarget.js listeners=1 n=1000000                                    ***     19.73 %       ±1.89%  ±2.51%  ±3.27%
events/eventtarget.js listeners=10 n=1000000                                   ***     15.00 %       ±2.71%  ±3.63%  ±4.77%
events/eventtarget.js listeners=5 n=1000000                                    ***     17.72 %       ±2.43%  ±3.24%  ±4.22%
worker/atomics-wait.js n=10000000                                               **     -2.19 %       ±1.58%  ±2.10%  ±2.75%
worker/bench-eventlooputil.js method='ELU_passed' n=1000000                             4.06 %       ±5.00%  ±6.71%  ±8.87%
worker/bench-eventlooputil.js method='ELU_simple' n=1000000                             0.51 %       ±6.67%  ±8.88% ±11.56%
worker/echo.js n=100000 sendsPerBroadcast=1 payload='object' workers=1                 -1.61 %       ±5.24%  ±6.97%  ±9.07%
worker/echo.js n=100000 sendsPerBroadcast=1 payload='string' workers=1                  0.91 %       ±6.01%  ±7.99% ±10.40%
worker/echo.js n=100000 sendsPerBroadcast=10 payload='object' workers=1                -1.56 %       ±3.70%  ±4.92%  ±6.41%
worker/echo.js n=100000 sendsPerBroadcast=10 payload='string' workers=1                -1.37 %       ±3.77%  ±5.04%  ±6.61%
worker/messageport.js n=1000000 style='eventemitter' payload='object'                   0.60 %       ±2.29%  ±3.05%  ±3.98%
worker/messageport.js n=1000000 style='eventemitter' payload='string'                  -0.86 %       ±2.61%  ±3.48%  ±4.53%
worker/messageport.js n=1000000 style='eventtarget' payload='object'           ***      8.44 %       ±3.07%  ±4.08%  ±5.31%
worker/messageport.js n=1000000 style='eventtarget' payload='string'           ***     12.80 %       ±4.71%  ±6.26%  ±8.15%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 45 comparisons, you can thus
expect the following amount of false-positive results:
  2.25 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.45 false positives, when considering a   1% risk acceptance (**, ***),
  0.04 false positives, when considering a 0.1% risk acceptance (***)

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 7, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 8, 2023
@nodejs-github-bot nodejs-github-bot merged commit 85c8b78 into nodejs:main Feb 8, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 85c8b78

MylesBorins pushed a commit that referenced this pull request Feb 18, 2023
It improves Event creation performance.

PR-URL: #46527
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 19, 2023
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
It improves Event creation performance.

PR-URL: #46527
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rafael Gonzaga <[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. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.