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: optimize EventTarget.addEventListener #55312

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ronag
Copy link
Member

@ronag ronag commented Oct 8, 2024

events/eventtarget-add-remove-abort.js nListener=1 n=100000         ***    223.45 %      ±12.03% ±16.12% ±21.21%
events/eventtarget-add-remove-abort.js nListener=10 n=100000        ***    199.33 %       ±9.42% ±12.63% ±16.65%
events/eventtarget-add-remove-abort.js nListener=5 n=100000         ***    221.94 %       ±8.80% ±11.78% ±15.47%

Fixes: #55311

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Oct 8, 2024

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Oct 8, 2024
lib/internal/event_target.js Outdated Show resolved Hide resolved
@ronag ronag force-pushed the eventtarget-perf branch 4 times, most recently from 4a4c150 to 6f397eb Compare October 8, 2024 06:52
@ronag
Copy link
Member Author

ronag commented Oct 8, 2024

@benjamingr could we use a Set instead of linked list? At least in the non-weak case?

@KhafraDev
Copy link
Member

Is there a reason we can't skip using addEventListener altogether and directly append the listener to the signal's abort algorithms?

@ronag ronag marked this pull request as ready for review October 9, 2024 15:54
@ronag ronag force-pushed the eventtarget-perf branch 2 times, most recently from 26c85fa to 9570840 Compare October 9, 2024 16:04
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.40%. Comparing base (d2ad9b4) to head (c934127).
Report is 53 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55312      +/-   ##
==========================================
- Coverage   88.41%   88.40%   -0.02%     
==========================================
  Files         652      652              
  Lines      186594   186788     +194     
  Branches    36054    36037      -17     
==========================================
+ Hits       164980   165126     +146     
- Misses      14883    14925      +42     
- Partials     6731     6737       +6     
Files with missing lines Coverage Δ
lib/internal/event_target.js 99.15% <100.00%> (+<0.01%) ⬆️

... and 69 files with indirect coverage changes

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 10, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 10, 2024
@nodejs-github-bot
Copy link
Collaborator

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 11, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 11, 2024
@nodejs-github-bot
Copy link
Collaborator

@RedYetiDev RedYetiDev added the events Issues and PRs related to the events subsystem / EventEmitter. label Oct 11, 2024
@RedYetiDev RedYetiDev added the performance Issues and PRs related to the performance of Node.js. label Oct 11, 2024
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

@mcollina
Copy link
Member

@ronag linting is failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events Issues and PRs related to the events subsystem / EventEmitter. 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.

signal.add/removeEventListener('abort', fn) is slow
9 participants