Skip to content

Conversation

@cjihrig
Copy link
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

@nodejs-github-botnodejs-github-bot added the cluster Issues and PRs related to the cluster subsystem. label Sep 27, 2018
@mscdex
Copy link
Contributor

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

@cjihrig
Copy link
ContributorAuthor

cjihrig commented Sep 27, 2018

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``` 

@mscdex
Copy link
Contributor

mscdex commented Sep 27, 2018

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.

Copy link
Member

@devsnekdevsnek left a 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 👍

Copy link
Member

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?

Copy link
ContributorAuthor

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

@cjihrig
Copy link
ContributorAuthor

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 

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]>
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]>
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]>
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]>
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
Copy link
ContributorAuthor

@cjihrigcjihrig merged commit 847037e into nodejs:masterSep 30, 2018
@cjihrigcjihrig deleted the cluster branch September 30, 2018 15:06
targos pushed a commit that referenced this pull request Oct 1, 2018
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
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
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
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
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
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
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
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
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]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clusterIssues and PRs related to the cluster subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@cjihrig@nodejs-github-bot@mscdex@jasnell@addaleax@targos@devsnek@lundibundi@trivikr