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

os: improve networkInterfaces() performance #25410

Closed
wants to merge 1 commit into from

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Jan 9, 2019

With included benchmark:

                                  confidence improvement accuracy (*)   (**)  (***)
 os/networkInterfaces.js n=10000        ***      3.86 %       ±0.26% ±0.34% ±0.44%

and also makes the C++ implementation mirror the C++ cpu enumeration code for whatever that's worth.

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@mscdex mscdex added os Issues and PRs related to the os subsystem. performance Issues and PRs related to the performance of Node.js. labels Jan 9, 2019
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 9, 2019
if (existing !== undefined)
existing.push(entry);
else
result[name] = [entry];
}
Copy link
Member

@jdalton jdalton Jan 9, 2019

Choose a reason for hiding this comment

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

Can you explain the perf benefit for networkInterfaces()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Member

@jdalton jdalton Jan 9, 2019

Choose a reason for hiding this comment

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

At first glance it looks like a lot of unrolled code with an extra object being created. Could you please step me through the optimization being done in networkInterfaces(). If you drop the rework to networkInterfaces() do you still see perf wins?

Copy link
Contributor Author

@mscdex mscdex Jan 9, 2019

Choose a reason for hiding this comment

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

It's more or less moving the object creation from C++ to JS land, just like we do for CPU enumeration.

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

I personally wonder if it would not be faster to just move everything to C++ instead.

The changes LGTM besides the result object. It should be kept as regular object.

lib/os.js Outdated Show resolved Hide resolved
@mscdex mscdex force-pushed the os-networkinterfaces-refactor branch from d7b7cde to b505976 Compare January 9, 2019 19:33
@BridgeAR
Copy link
Member

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 10, 2019
@danbev
Copy link
Contributor

danbev commented Jan 14, 2019

Landed in 5021b25.

@danbev danbev closed this Jan 14, 2019
danbev pushed a commit that referenced this pull request Jan 14, 2019
PR-URL: #25410
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@mscdex mscdex deleted the os-networkinterfaces-refactor branch January 14, 2019 07:14
addaleax pushed a commit that referenced this pull request Jan 14, 2019
PR-URL: #25410
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR BridgeAR mentioned this pull request Jan 16, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
PR-URL: nodejs#25410
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2019
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 pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. os Issues and PRs related to the os subsystem. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants