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 — cluster: use Maps to track handles, indexes, etc. by cjihrig · Pull Request #23125 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Sep 27, 2018

Copy link
Copy Markdown
Contributor

Using Maps over POJOs is more idiomatic, and avoids many expensive delete operations. This PR only touches internal APIs.

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

Sorry, something went wrong.

Uh oh!

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

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot

nodejs-github-bot commented Sep 27, 2018

Copy link
Copy Markdown
Collaborator

@cjihrig build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/1041/pipeline

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 cluster Issues and PRs related to the cluster subsystem. label Sep 27, 2018
@mscdex

mscdex commented Sep 27, 2018

Copy link
Copy Markdown
Contributor

Do we have benchmarks to compare a possible change in performance with these changes?

All reactions

Sorry, something went wrong.

Uh oh!

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

@cjihrig

cjihrig commented Sep 27, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

There is only one cluster benchmark, but it seems to improve with these changes:

before:
cluster/echo.js n=100000 sendsPerBroadcast=1 payload="string" workers=1: 20,023.718912019016
cluster/echo.js n=100000 sendsPerBroadcast=10 payload="string" workers=1: 7,540.0656667259545
cluster/echo.js n=100000 sendsPerBroadcast=1 payload="object" workers=1: 15,415.718044848363
cluster/echo.js n=100000 sendsPerBroadcast=10 payload="object" workers=1: 5,995.307144914562

after:
cluster/echo.js n=100000 sendsPerBroadcast=1 payload="string" workers=1: 21,580.722871510236
cluster/echo.js n=100000 sendsPerBroadcast=10 payload="string" workers=1: 8,586.962318302709
cluster/echo.js n=100000 sendsPerBroadcast=1 payload="object" workers=1: 15,989.847697757608
cluster/echo.js n=100000 sendsPerBroadcast=10 payload="object" workers=1: 6,376.197549671379```
All reactions

Sorry, something went wrong.

Uh oh!

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

@mscdex

mscdex commented Sep 27, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

The existing benchmark doesn't exercise the code paths being changed in this PR, since it is just passing messages and not handles. We need an additional benchmark that passes handles to the forked processes.

As far as the existing benchmark results go, I would expect the difference to not be statistically significant over many runs.

lundibundi reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

devsnek
devsnek approved these changes Sep 27, 2018
View reviewed changes

@devsnek devsnek 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.

dunno about the speed, but the semantics look good 👍

Sorry, something went wrong.

Uh oh!

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

All reactions
targos
targos approved these changes Sep 27, 2018
View reviewed changes
Comment thread lib/internal/cluster/utils.js Outdated

@targos targos Sep 27, 2018

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.

If this is used in tests, shouldn't tests be updated?

Sorry, something went wrong.

Uh oh!

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

All reactions

@cjihrig cjihrig Sep 27, 2018

Copy link
Copy Markdown
Contributor 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.

@targos the only test that was using it was removed. See #23131

Sorry, something went wrong.

Uh oh!

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

All reactions
@cjihrig

cjihrig commented Sep 27, 2018

Copy link
Copy Markdown
Contributor Author

It might not be possible to create a benchmark that passes handles in a similar fashion. At least on macOS, Node hangs after ~10-11k "echoes" (on master even without this PR, more investigation is needed there) Additionally, on master, it seems that using a Map is a good bit faster (although I wouldn't expect the Map vs. Object decision to be the bottleneck in these IPC heavy applications anyway):

$ ./node benchmark/es/map-bench.js 
es/map-bench.js n=1000000 method="object": 355,619.17415044963
es/map-bench.js n=1000000 method="nullProtoObject": 369,429.81874460133
es/map-bench.js n=1000000 method="nullProtoLiteralObject": 365,293.87356241985
es/map-bench.js n=1000000 method="storageObject": 365,471.84898171073
es/map-bench.js n=1000000 method="fakeMap": 330,257.280692661
es/map-bench.js n=1000000 method="map": 642,936.8119129504
All reactions

Sorry, something went wrong.

Uh oh!

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

addaleax
addaleax approved these changes Sep 28, 2018
View reviewed changes
jasnell
jasnell approved these changes Sep 28, 2018
View reviewed changes
trivikr
trivikr approved these changes Sep 29, 2018
View reviewed changes
lundibundi
lundibundi approved these changes Sep 29, 2018
View reviewed changes
cjihrig added 5 commits September 30, 2018 11:03
@cjihrig
cluster: use Map to track callbacks
97dad7e
Use a Map to avoid delete operations in callback tracking.

PR-URL: nodejs#23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@cjihrig
cluster: use Map to track round robin workers
6654c59
PR-URL: nodejs#23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@cjihrig
cluster: use Map to track indexes
aa899aa
PR-URL: nodejs#23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@cjihrig
cluster: use Map to track handles in cluster child
5a50989
PR-URL: nodejs#23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@cjihrig
cluster: use Map to track handles in master
847037e
PR-URL: nodejs#23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@cjihrig
cjihrig force-pushed the cluster branch from a7fbab1 to 847037e Compare September 30, 2018 15:04
@cjihrig

cjihrig commented Sep 30, 2018

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@cjihrig
cjihrig merged commit 847037e into nodejs:master Sep 30, 2018
@cjihrig
cjihrig deleted the cluster branch September 30, 2018 15:06
targos pushed a commit that referenced this pull request Oct 1, 2018
@cjihrig @targos
cluster: use Map to track callbacks
1172bc4
Use a Map to avoid delete operations in callback tracking.

PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 1, 2018
@cjihrig @targos
cluster: use Map to track round robin workers
fc61175
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 1, 2018
@cjihrig @targos
cluster: use Map to track indexes
bdb4309
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 1, 2018
@cjihrig @targos
cluster: use Map to track handles in cluster child
c7a9360
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 1, 2018
@cjihrig @targos
cluster: use Map to track handles in master
278dbf2
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 3, 2018
@cjihrig @targos
cluster: use Map to track callbacks
22f51a6
Use a Map to avoid delete operations in callback tracking.

PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 3, 2018
@cjihrig @targos
cluster: use Map to track round robin workers
64f840a
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 3, 2018
@cjihrig @targos
cluster: use Map to track indexes
2dd157f
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 3, 2018
@cjihrig @targos
cluster: use Map to track handles in cluster child
0f133eb
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
targos pushed a commit that referenced this pull request Oct 3, 2018
@cjihrig @targos
cluster: use Map to track handles in master
cb0d823
PR-URL: #23125
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@targos targos mentioned this pull request Oct 7, 2018
Release proposal: v10.12.0 #23313
Merged
This was referenced Oct 10, 2018
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#225
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#239
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#226
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#240
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#227
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#241
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#242
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#228
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#243
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#229
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@trivikr trivikr trivikr approved these changes
+3 more reviewers
@targos targos targos approved these changes
@devsnek devsnek devsnek approved these changes
@lundibundi lundibundi lundibundi approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

cluster Issues and PRs related to the cluster subsystem.

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

@cjihrig @nodejs-github-bot @mscdex @jasnell @addaleax @targos @devsnek @lundibundi @trivikr
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 01402775 — 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.