GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: pre-allocate _events by ronag · Pull Request #50428 · nodejs/node

Conversation

@ronag

@ronag ronag commented Oct 27, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
19:50:22 streams/creation.js kind='duplex' n=50000000                                                    ***      8.93 %       ±1.20% ±1.60%  ±2.10%
19:50:22 streams/creation.js kind='readable' n=50000000                                                  ***      3.39 %       ±1.30% ±1.74%  ±2.30%
19:50:22 streams/creation.js kind='transform' n=50000000                                                 ***     58.62 %       ±1.72% ±2.29%  ±2.99%
19:50:22 streams/creation.js kind='writable' n=50000000                                                  ***     11.96 %       ±1.20% ±1.60%  ±2.08%
19:50:22 streams/destroy.js kind='duplex' n=1000000                                                      ***      5.30 %       ±2.48% ±3.30%  ±4.29%
19:50:22 streams/destroy.js kind='readable' n=1000000                                                    ***      7.73 %       ±2.38% ±3.17%  ±4.12%
19:50:22 streams/destroy.js kind='transform' n=1000000                                                   ***     16.09 %       ±1.93% ±2.57%  ±3.34%
19:50:22 streams/destroy.js kind='writable' n=1000000                                                    ***      6.01 %       ±2.11% ±2.80%  ±3.65%
19:50:22 streams/pipe-object-mode.js n=5000000                                                           ***     14.94 %       ±5.86% ±7.80% ±10.17%
19:50:22 streams/pipe.js n=5000000                                                                       ***     14.50 %       ±4.97% ±6.62%  ±8.64%
19:50:22 streams/readable-async-iterator.js sync='no' n=100000                                                   -0.00 %       ±5.84% ±7.78% ±10.12%
19:50:22 streams/readable-async-iterator.js sync='yes' n=100000                                           **      5.06 %       ±3.67% ±4.94%  ±6.54%
19:50:22 streams/readable-bigread.js n=1000                                                               **      4.02 %       ±2.77% ±3.71%  ±4.87%
19:50:22 streams/readable-bigunevenread.js n=1000                                                                 0.81 %       ±1.80% ±2.40%  ±3.14%
19:50:22 streams/readable-boundaryread.js type='buffer' n=2000                                           ***     22.18 %       ±1.51% ±2.02%  ±2.63%
19:50:22 streams/readable-boundaryread.js type='string' n=2000                                           ***      4.77 %       ±1.36% ±1.81%  ±2.35%
19:50:22 streams/readable-from.js type='array' n=10000000                                                ***     23.14 %       ±4.33% ±5.76%  ±7.51%
19:50:22 streams/readable-from.js type='async-generator' n=10000000                                      ***      6.25 %       ±0.79% ±1.05%  ±1.36%
19:50:22 streams/readable-from.js type='sync-generator-with-async-values' n=10000000                     ***      8.63 %       ±1.02% ±1.35%  ±1.76%
19:50:22 streams/readable-from.js type='sync-generator-with-sync-values' n=10000000                      ***     12.72 %       ±3.93% ±5.24%  ±6.82%
19:50:22 streams/readable-readall.js n=5000                                                                      -1.10 %       ±5.57% ±7.41%  ±9.64%
19:50:22 streams/readable-unevenread.js n=1000                                                           ***      6.29 %       ±0.49% ±0.65%  ±0.85%
19:50:22 streams/writable-manywrites.js len=1024 callback='no' writev='no' sync='no' n=100000                    -0.78 %       ±0.99% ±1.31%  ±1.71%
19:50:22 streams/writable-manywrites.js len=1024 callback='no' writev='no' sync='yes' n=100000             *      3.11 %       ±2.41% ±3.21%  ±4.18%
19:50:22 streams/writable-manywrites.js len=1024 callback='no' writev='yes' sync='no' n=100000                    0.90 %       ±1.75% ±2.33%  ±3.03%
19:50:22 streams/writable-manywrites.js len=1024 callback='no' writev='yes' sync='yes' n=100000            *     -2.74 %       ±2.45% ±3.27%  ±4.25%
19:50:22 streams/writable-manywrites.js len=1024 callback='yes' writev='no' sync='no' n=100000                    0.12 %       ±0.88% ±1.18%  ±1.54%
19:50:22 streams/writable-manywrites.js len=1024 callback='yes' writev='no' sync='yes' n=100000                  -0.57 %       ±1.86% ±2.49%  ±3.25%
19:50:22 streams/writable-manywrites.js len=1024 callback='yes' writev='yes' sync='no' n=100000                  -2.04 %       ±2.35% ±3.14%  ±4.10%
19:50:22 streams/writable-manywrites.js len=1024 callback='yes' writev='yes' sync='yes' n=100000                 -1.62 %       ±2.09% ±2.78%  ±3.62%
19:50:22 streams/writable-manywrites.js len=32768 callback='no' writev='no' sync='no' n=100000                    1.42 %       ±2.64% ±3.55%  ±4.67%
19:50:22 streams/writable-manywrites.js len=32768 callback='no' writev='no' sync='yes' n=100000                   0.52 %       ±2.67% ±3.56%  ±4.63%
19:50:22 streams/writable-manywrites.js len=32768 callback='no' writev='yes' sync='no' n=100000                   2.15 %       ±2.44% ±3.27%  ±4.31%
19:50:22 streams/writable-manywrites.js len=32768 callback='no' writev='yes' sync='yes' n=100000                 -0.64 %       ±2.51% ±3.34%  ±4.35%
19:50:22 streams/writable-manywrites.js len=32768 callback='yes' writev='no' sync='no' n=100000                   2.31 %       ±2.56% ±3.43%  ±4.52%
19:50:22 streams/writable-manywrites.js len=32768 callback='yes' writev='no' sync='yes' n=100000                 -0.01 %       ±2.33% ±3.10%  ±4.04%
19:50:22 streams/writable-manywrites.js len=32768 callback='yes' writev='yes' sync='no' n=100000                  0.73 %       ±2.70% ±3.62%  ±4.76%
19:50:22 streams/writable-manywrites.js len=32768 callback='yes' writev='yes' sync='yes' n=100000                 1.68 %       ±2.08% ±2.77%  ±3.61%

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

H4ad, bricss, and rluvaton reacted with rocket emoji benjamingr, H4ad, and bricss reacted with eyes emoji
All reactions
  • 🚀 3 reactions
  • 👀 3 reactions
@nodejs-github-bot

nodejs-github-bot commented Oct 27, 2023 •
edited by ronag
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Oct 27, 2023
@rluvaton

rluvaton commented Oct 27, 2023

Copy link
Copy Markdown
Member

Will continue the review tomorrow night, but one general note, I think you should avoid deleting those events when removing listener, and IIRC I think we use the number of keys exists in order to see how many events we listen to

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag
ronag requested review from benjamingr and mcollina October 27, 2023 15:11
@ronag
ronag force-pushed the stream-events branch from f3d826a to 321c41c Compare October 27, 2023 15:23
mcollina
mcollina approved these changes Oct 27, 2023
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ronag
ronag force-pushed the stream-events branch from 39d2410 to 7293910 Compare October 27, 2023 16:11
@ronag

ronag commented Oct 27, 2023

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag
ronag force-pushed the stream-events branch 3 times, most recently from 54755f2 to 4e46fdf Compare October 27, 2023 16:46
@ronag ronag added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Oct 27, 2023
@ronag
ronag requested a review from rluvaton October 27, 2023 17:51
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 27, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 27, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55272/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag
ronag force-pushed the stream-events branch 2 times, most recently from cc6dfe0 to 89ad099 Compare October 27, 2023 19:35
@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 27, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 27, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 27, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55274/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Oct 28, 2023
CI Reliability 2023-10-28 nodejs/reliability#700
Open
22 tasks
@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 28, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 28, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 28, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55279/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag
ronag force-pushed the stream-events branch 3 times, most recently from 673f925 to 507478e Compare October 28, 2023 06:51
@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 28, 2023
rluvaton
rluvaton reviewed Oct 28, 2023
View reviewed changes
Comment thread lib/internal/streams/duplex.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/events.js
else
delete events[type];
}
this[kShapeMode] = false;

@rluvaton rluvaton Oct 28, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why? What if we just have an object template (template in the abstract way not v8 one) and use that when resetting? (Same for the one below)

(This is not really important comment as it's not happening on a regular basis)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ronag ronag Oct 28, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don't understand

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rluvaton rluvaton Oct 29, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe reset _events to the template you provided (e.g. with data event key) instead to the default one (i.e. empty with proto null)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ronag ronag Oct 29, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

That would require us to keep the template in memory and then create copies. Maybe having some kind of reset/initEvents override is better but starts to make things complciated.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/streams/duplex.js
if (!(this instanceof Duplex))
return new Duplex(options);

this._events ??= {

@rluvaton rluvaton Oct 28, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don't really think we should modify the private property _events like that, maybe have an option or an api for setting events template in the EventEmitter class?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ronag ronag Oct 28, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Follow up PR welcome?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rluvaton reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@github-actions github-actions Bot mentioned this pull request Oct 29, 2023
CI Reliability 2023-10-29 nodejs/reliability#701
Open
21 tasks
@rluvaton rluvaton mentioned this pull request Oct 29, 2023
events: improve events performance #50422
Closed
2 tasks
@ronag ronag added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 29, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 29, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 2aaa21f into nodejs:main Oct 29, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 29, 2023

Copy link
Copy Markdown
Collaborator

Landed in 2aaa21f

rluvaton reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Oct 30, 2023
CI Reliability 2023-10-30 nodejs/reliability#702
Open
25 tasks
ronag added a commit to nxtedition/node that referenced this pull request Oct 30, 2023
@ronag
stream: remove LazyTransform
c249549
No longer necessary given recent stream and event optimziations.

Refs: nodejs#50428
Refs: nodejs#50439

PR-URL: nodejs#50440
This was referenced Oct 31, 2023
CI Reliability 2023-10-31 nodejs/reliability#703
Open
CI Reliability 2023-11-01 nodejs/reliability#704
Open
targos pushed a commit that referenced this pull request Nov 11, 2023
@ronag @targos
stream: pre-allocate _events
761a14a
PR-URL: #50428
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos mentioned this pull request Nov 12, 2023
v21.2.0 release proposal #50681
Merged
targos pushed a commit that referenced this pull request Nov 14, 2023
@ronag @targos
stream: pre-allocate _events
0116ae7
PR-URL: #50428
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Dec 11, 2023
@ronag @UlisesGascon
stream: pre-allocate _events
dd52068
PR-URL: #50428
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@UlisesGascon UlisesGascon mentioned this pull request Dec 12, 2023
v20.11.0 proposal #51124
Merged
@Qard

Qard commented Dec 28, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This seems to have broken the emitter.eventNames() function. Because it pre-allocates the _events object it will now report that it has handlers for all those pre-allocated names even if none actually exist.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Dec 28, 2023
Fix net plugin tests DataDog/dd-trace-js#3906
Merged
stream.eventNames() broken on 21.2.0+ #51302
Closed
deokjinkim added a commit to deokjinkim/node that referenced this pull request Feb 29, 2024
@deokjinkim
doc: fix actual result of example is different in events
316c57d
Refs: nodejs#50428
@deokjinkim deokjinkim mentioned this pull request Feb 29, 2024
doc: fix actual result of example is different in events #51925
Merged
nodejs-github-bot pushed a commit that referenced this pull request Mar 2, 2024
@deokjinkim
doc: fix actual result of example is different in events
9930f11
Refs: #50428
PR-URL: #51925
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
targos pushed a commit that referenced this pull request Mar 7, 2024
@deokjinkim @targos
doc: fix actual result of example is different in events
87d2acc
Refs: #50428
PR-URL: #51925
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
@deokjinkim @richardlau
doc: fix actual result of example is different in events
fc0b389
Refs: #50428
PR-URL: #51925
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rluvaton rluvaton rluvaton left review comments
@mcollina mcollina mcollina approved these changes
@jasnell jasnell jasnell approved these changes
@benjamingr benjamingr benjamingr approved these changes
@anonrig anonrig anonrig approved these changes
@H4ad H4ad H4ad approved these changes
@aduh95 aduh95 Awaiting requested review from aduh95
@lpinca lpinca Awaiting requested review from lpinca

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@ronag @nodejs-github-bot @rluvaton @Qard @mcollina @jasnell @benjamingr @anonrig @H4ad
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.