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

events: refactor to use optional chaining #36763

Merged
merged 1 commit into from
Jan 11, 2021

Conversation

Lxxyx
Copy link
Member

@Lxxyx Lxxyx commented Jan 4, 2021

Benchmark running on my computer, performance looks good
                                                           confidence improvement accuracy (*)    (**)   (***)
 events/ee-add-remove.js n=1000000                                ***      4.30 %      ±2.08% ±2.77% ±3.61%
 events/ee-emit.js listeners=1 argc=0 n=2000000                            2.90 %      ±3.52% ±4.68% ±6.09%
 events/ee-emit.js listeners=1 argc=10 n=2000000                           1.92 %      ±3.73% ±4.96% ±6.45%
 events/ee-emit.js listeners=1 argc=2 n=2000000                            2.20 %      ±2.87% ±3.83% ±5.00%
 events/ee-emit.js listeners=1 argc=4 n=2000000                           -0.39 %      ±2.89% ±3.84% ±5.00%
 events/ee-emit.js listeners=10 argc=0 n=2000000                  ***      4.52 %      ±2.30% ±3.06% ±3.99%
 events/ee-emit.js listeners=10 argc=10 n=2000000                   *      2.49 %      ±1.88% ±2.51% ±3.27%
 events/ee-emit.js listeners=10 argc=2 n=2000000                   **      2.97 %      ±2.13% ±2.84% ±3.70%
 events/ee-emit.js listeners=10 argc=4 n=2000000                  ***      3.65 %      ±2.09% ±2.78% ±3.62%
 events/ee-emit.js listeners=5 argc=0 n=2000000                   ***      6.47 %      ±2.15% ±2.86% ±3.72%
 events/ee-emit.js listeners=5 argc=10 n=2000000                           2.22 %      ±2.27% ±3.02% ±3.93%
 events/ee-emit.js listeners=5 argc=2 n=2000000                            1.60 %      ±2.92% ±3.89% ±5.06%
 events/ee-emit.js listeners=5 argc=4 n=2000000                   ***      4.25 %      ±2.34% ±3.12% ±4.07%
 events/ee-listener-count-on-prototype.js n=50000000               **     -1.74 %      ±1.27% ±1.70% ±2.21%
 events/ee-listeners.js raw='false' listeners=5 n=5000000          **      3.73 %      ±2.37% ±3.16% ±4.12%
 events/ee-listeners.js raw='false' listeners=50 n=5000000        ***     14.41 %      ±2.32% ±3.09% ±4.02%
 events/ee-listeners.js raw='true' listeners=5 n=5000000                  -2.63 %      ±2.69% ±3.58% ±4.65%
 events/ee-listeners.js raw='true' listeners=50 n=5000000         ***     29.31 %      ±3.29% ±4.40% ±5.76%
 events/ee-once.js argc=0 n=20000000                              ***      7.21 %      ±3.15% ±4.19% ±5.46%
 events/ee-once.js argc=1 n=20000000                              ***      5.66 %      ±3.06% ±4.07% ±5.29%
 events/ee-once.js argc=4 n=20000000                              ***      6.00 %      ±2.72% ±3.62% ±4.71%
 events/ee-once.js argc=5 n=20000000                               **      4.62 %      ±2.93% ±3.90% ±5.09%
 events/eventtarget.js listeners=1 n=1000000                      ***      4.41 %      ±1.93% ±2.57% ±3.35%
 events/eventtarget.js listeners=10 n=1000000                       *      2.75 %      ±2.34% ±3.11% ±4.05%
 events/eventtarget.js listeners=5 n=1000000                      ***      3.50 %      ±1.87% ±2.49% ±3.25%

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

Benchmark commands: node ./node-master/benchmark/compare.js --old ./node-master/out/Release/node --new ./node/out/Release/node -- events

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

@nodejs-github-bot nodejs-github-bot added the events Issues and PRs related to the events subsystem / EventEmitter. label Jan 4, 2021
lib/internal/event_target.js Outdated Show resolved Hide resolved
lib/internal/event_target.js Outdated Show resolved Hide resolved
@Lxxyx Lxxyx force-pushed the events-refactor-use-optional-chaining branch from 970111c to f45ec89 Compare January 4, 2021 09:15
@Lxxyx Lxxyx requested a review from aduh95 January 5, 2021 08:23
@aduh95
Copy link
Contributor

aduh95 commented Jan 5, 2021

@Lxxyx
Copy link
Member Author

Lxxyx commented Jan 6, 2021

Benchmark Results

No regressions or improvements
                                                          confidence improvement accuracy (*)   (**)   (***)
events/ee-add-remove.js n=1000000                                         1.22 %       ±3.43% ±4.59%  ±6.02%
events/ee-emit.js listeners=10 argc=0 n=2000000                           1.94 %       ±2.91% ±3.92%  ±5.18%
events/ee-emit.js listeners=10 argc=10 n=2000000                          0.49 %       ±2.11% ±2.82%  ±3.67%
events/ee-emit.js listeners=10 argc=2 n=2000000                           0.99 %       ±1.09% ±1.45%  ±1.90%
events/ee-emit.js listeners=10 argc=4 n=2000000                           0.64 %       ±0.92% ±1.22%  ±1.60%
events/ee-emit.js listeners=1 argc=0 n=2000000                           -1.92 %       ±4.05% ±5.39%  ±7.02%
events/ee-emit.js listeners=1 argc=10 n=2000000                           2.49 %       ±3.21% ±4.28%  ±5.60%
events/ee-emit.js listeners=1 argc=2 n=2000000                           -0.64 %       ±4.76% ±6.34%  ±8.25%
events/ee-emit.js listeners=1 argc=4 n=2000000                            3.24 %       ±3.69% ±4.92%  ±6.41%
events/ee-emit.js listeners=5 argc=0 n=2000000                            1.45 %       ±2.08% ±2.76%  ±3.60%
events/ee-emit.js listeners=5 argc=10 n=2000000                          -1.55 %       ±1.91% ±2.54%  ±3.32%
events/ee-emit.js listeners=5 argc=2 n=2000000                           -0.91 %       ±1.57% ±2.09%  ±2.72%
events/ee-emit.js listeners=5 argc=4 n=2000000                            0.31 %       ±1.83% ±2.44%  ±3.18%
events/ee-listener-count-on-prototype.js n=50000000                       3.16 %       ±5.58% ±7.43%  ±9.69%
events/ee-listeners.js raw='false' listeners=50 n=5000000                 0.31 %       ±1.45% ±1.93%  ±2.51%
events/ee-listeners.js raw='false' listeners=5 n=5000000                  0.42 %       ±1.58% ±2.10%  ±2.74%
events/ee-listeners.js raw='true' listeners=50 n=5000000                  0.32 %       ±1.43% ±1.90%  ±2.48%
events/ee-listeners.js raw='true' listeners=5 n=5000000                   3.06 %       ±3.64% ±4.85%  ±6.31%
events/ee-once.js argc=0 n=20000000                                       1.06 %       ±1.70% ±2.27%  ±2.95%
events/ee-once.js argc=1 n=20000000                                      -0.74 %       ±1.13% ±1.51%  ±1.97%
events/ee-once.js argc=4 n=20000000                                      -1.08 %       ±2.29% ±3.05%  ±3.97%
events/ee-once.js argc=5 n=20000000                                       0.25 %       ±1.79% ±2.38%  ±3.09%
events/eventtarget.js listeners=10 n=1000000                              0.08 %       ±6.18% ±8.22% ±10.70%
events/eventtarget.js listeners=1 n=1000000                              -0.22 %       ±3.54% ±4.75%  ±6.25%
events/eventtarget.js listeners=5 n=1000000                               0.16 %       ±4.67% ±6.27%  ±8.28%

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jan 6, 2021
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 6, 2021
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: nodejs#36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95 aduh95 force-pushed the events-refactor-use-optional-chaining branch from f45ec89 to eb8422c Compare January 11, 2021 10:39
@aduh95 aduh95 merged commit eb8422c into nodejs:master Jan 11, 2021
@aduh95
Copy link
Contributor

aduh95 commented Jan 11, 2021

Landed in eb8422c

@Lxxyx Lxxyx deleted the events-refactor-use-optional-chaining branch January 11, 2021 10:42
danielleadams pushed a commit that referenced this pull request Jan 12, 2021
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@danielleadams danielleadams mentioned this pull request Jan 12, 2021
targos pushed a commit that referenced this pull request May 25, 2021
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos pushed a commit that referenced this pull request May 30, 2021
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos pushed a commit that referenced this pull request Jun 5, 2021
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos pushed a commit that referenced this pull request Jun 11, 2021
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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. events Issues and PRs related to the events subsystem / EventEmitter.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants