Skip to content

events: inline hybrid dispatch closures - #64473

Closed
slagiewka wants to merge 2 commits into
nodejs:mainfrom
slagiewka:et
Closed

events: inline hybrid dispatch closures#64473
slagiewka wants to merge 2 commits into
nodejs:mainfrom
slagiewka:et

Conversation

@slagiewka

Copy link
Copy Markdown
Contributor

lib: inline createEvent hybrid dispatch closure

Originally added in 16b11cd, it first
had three callers. Now there's only one branch requireing it.

lib: inline iterationCondition hybrid dispatch closure

While more readable, the removed closure overhead unlocks 10-20% in
eventtarget.js benchmark (30 runs).

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jul 13, 2026
@slagiewka

Copy link
Copy Markdown
Contributor Author

Looks like the convention for commit scope here is either events or lib. I'm fine with both, LMK and I will rewrite these commits.

Originally added in 16b11cd, it first
had three callers. Now there's only one branch requireing it.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
While more readable, the removed closure overhead unlocks 10-20% in
eventtarget.js benchmark.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
@slagiewka slagiewka changed the title lib: inline hybrid dispatch closures events: inline hybrid dispatch closures Jul 14, 2026
@avivkeller avivkeller added the needs-benchmark-ci PR that need a benchmark CI run. label Jul 21, 2026
@avivkeller

Copy link
Copy Markdown
Member

@nodejs/events

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.24%. Comparing base (384d7a4) to head (27fce3a).
⚠️ Report is 632 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64473      +/-   ##
==========================================
+ Coverage   90.21%   90.24%   +0.03%     
==========================================
  Files         741      741              
  Lines      241608   241680      +72     
  Branches    45534    45542       +8     
==========================================
+ Hits       217972   218110     +138     
+ Misses      15154    15112      -42     
+ Partials     8482     8458      -24     
Files with missing lines Coverage Δ
lib/internal/event_target.js 99.17% <100.00%> (-0.01%) ⬇️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@slagiewka

Copy link
Copy Markdown
Contributor Author

@nodejs/events

@atlowChemi atlowChemi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assuming benchmarks support this

@atlowChemi atlowChemi added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2026
@atlowChemi

Copy link
Copy Markdown
Member

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2026
@nodejs-github-bot

This comment was marked as outdated.

@trivikr trivikr added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Aug 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr

trivikr commented Aug 24, 2026

Copy link
Copy Markdown
Member

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

Output from Benchmarking CI

                                                                 confidence improvement accuracy (*)   (**)   (***)
events/ee-add-remove.js n=1000000 removeListener=0 newListener=0                -0.63 %       ±1.28% ±1.70%  ±2.22%
events/ee-add-remove.js n=1000000 removeListener=0 newListener=1                -0.28 %       ±1.11% ±1.48%  ±1.93%
events/ee-add-remove.js n=1000000 removeListener=1 newListener=0                -1.02 %       ±1.04% ±1.38%  ±1.80%
events/ee-add-remove.js n=1000000 removeListener=1 newListener=1                -0.15 %       ±1.10% ±1.47%  ±1.91%
events/ee-emit.js listeners=1 argc=0 n=2000000                           **      4.95 %       ±3.70% ±4.94%  ±6.45%
events/ee-emit.js listeners=1 argc=10 n=2000000                          **      9.13 %       ±5.51% ±7.33%  ±9.55%
events/ee-emit.js listeners=1 argc=2 n=2000000                                   4.57 %       ±5.80% ±7.72% ±10.04%
events/ee-emit.js listeners=1 argc=4 n=2000000                          ***     10.33 %       ±5.72% ±7.62%  ±9.94%
events/ee-emit.js listeners=10 argc=0 n=2000000                                  0.25 %       ±1.13% ±1.50%  ±1.96%
events/ee-emit.js listeners=10 argc=10 n=2000000                         **      3.40 %       ±2.22% ±2.97%  ±3.90%
events/ee-emit.js listeners=10 argc=2 n=2000000                                 -0.42 %       ±1.49% ±1.98%  ±2.57%
events/ee-emit.js listeners=10 argc=4 n=2000000                                  1.19 %       ±1.56% ±2.08%  ±2.71%
events/ee-emit.js listeners=5 argc=0 n=2000000                                  -0.40 %       ±2.02% ±2.68%  ±3.49%
events/ee-emit.js listeners=5 argc=10 n=2000000                          **      4.01 %       ±2.52% ±3.36%  ±4.38%
events/ee-emit.js listeners=5 argc=2 n=2000000                           **      3.27 %       ±2.31% ±3.08%  ±4.02%
events/ee-emit.js listeners=5 argc=4 n=2000000                          ***      4.70 %       ±2.29% ±3.05%  ±3.98%
events/ee-listen-unique.js n=1000000 events=1                                    0.61 %       ±1.23% ±1.64%  ±2.14%
events/ee-listen-unique.js n=1000000 events=10                                   0.53 %       ±1.61% ±2.14%  ±2.78%
events/ee-listen-unique.js n=1000000 events=2                                   -0.55 %       ±1.31% ±1.74%  ±2.27%
events/ee-listen-unique.js n=1000000 events=20                                  -0.51 %       ±1.70% ±2.26%  ±2.95%
events/ee-listen-unique.js n=1000000 events=3                                    0.39 %       ±1.48% ±1.97%  ±2.57%
events/ee-listen-unique.js n=1000000 events=5                                    0.22 %       ±1.26% ±1.68%  ±2.19%
events/ee-listener-count-on-prototype.js n=50000000                             -0.95 %       ±1.76% ±2.34%  ±3.04%
events/ee-listeners.js raw='false' listeners=5 n=5000000                         1.05 %       ±1.28% ±1.70%  ±2.22%
events/ee-listeners.js raw='false' listeners=50 n=5000000                       -0.32 %       ±0.52% ±0.69%  ±0.90%
events/ee-listeners.js raw='true' listeners=5 n=5000000                          2.06 %       ±2.25% ±3.00%  ±3.93%
events/ee-listeners.js raw='true' listeners=50 n=5000000                         0.19 %       ±0.64% ±0.86%  ±1.11%
events/ee-once.js argc=0 n=20000000                                             -0.55 %       ±1.37% ±1.82%  ±2.37%
events/ee-once.js argc=1 n=20000000                                              0.71 %       ±1.74% ±2.31%  ±3.01%
events/ee-once.js argc=4 n=20000000                                             -0.24 %       ±1.77% ±2.36%  ±3.07%
events/ee-once.js argc=5 n=20000000                                              0.13 %       ±1.31% ±1.75%  ±2.28%
events/eventtarget-add-remove-abort.js nListener=1 n=100000                      1.87 %       ±2.39% ±3.19%  ±4.15%
events/eventtarget-add-remove-abort.js nListener=10 n=100000                     0.71 %       ±1.48% ±1.97%  ±2.57%
events/eventtarget-add-remove-abort.js nListener=5 n=100000                      0.59 %       ±2.28% ±3.03%  ±3.94%
events/eventtarget-add-remove.js nListener=1 n=100000                           -1.62 %       ±2.94% ±3.91%  ±5.11%
events/eventtarget-add-remove.js nListener=10 n=100000                          -0.48 %       ±1.22% ±1.63%  ±2.12%
events/eventtarget-add-remove.js nListener=5 n=100000                            0.67 %       ±2.07% ±2.75%  ±3.58%
events/eventtarget-creation.js n=1000000                                         2.08 %       ±4.94% ±6.60%  ±8.65%
events/eventtarget.js listeners=1 n=1000000                             ***     19.23 %       ±1.94% ±2.58%  ±3.36%
events/eventtarget.js listeners=10 n=1000000                            ***     13.47 %       ±1.09% ±1.46%  ±1.90%
events/eventtarget.js listeners=5 n=1000000                             ***     14.48 %       ±1.08% ±1.44%  ±1.88%

@trivikr

trivikr commented Aug 24, 2026

Copy link
Copy Markdown
Member

@atlowChemi Looks like this is ready to merge.

@atlowChemi atlowChemi added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. labels Aug 25, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in e618b1b...984e46f

nodejs-github-bot pushed a commit that referenced this pull request Aug 25, 2026
Originally added in 16b11cd, it first
had three callers. Now there's only one branch requireing it.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: #64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
nodejs-github-bot pushed a commit that referenced this pull request Aug 25, 2026
While more readable, the removed closure overhead unlocks 10-20% in
eventtarget.js benchmark.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: #64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 25, 2026
@slagiewka
slagiewka deleted the et branch August 25, 2026 08:17
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
Originally added in 16b11cd, it first
had three callers. Now there's only one branch requireing it.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: #64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
While more readable, the removed closure overhead unlocks 10-20% in
eventtarget.js benchmark.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: #64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
Originally added in 16b11cd, it first
had three callers. Now there's only one branch requireing it.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: #64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
While more readable, the removed closure overhead unlocks 10-20% in
eventtarget.js benchmark.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: #64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
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 outstanding review comments, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants