Skip to content

os: improve networkInterfaces() performance - #25410

Closed
mscdex wants to merge 1 commit into
nodejs:masterfrom
mscdex:os-networkinterfaces-refactor
Closed

os: improve networkInterfaces() performance#25410
mscdex wants to merge 1 commit into
nodejs:masterfrom
mscdex:os-networkinterfaces-refactor

Conversation

@mscdex

@mscdexmscdex commented Jan 9, 2019

Copy link
Copy Markdown
Contributor

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

@mscdexmscdex 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

Copy link
Copy Markdown
Collaborator

@nodejs-github-botnodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 9, 2019
Comment threadlib/os.js Outdated

@jdaltonjdaltonJan 9, 2019

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

What do you mean?

@jdaltonjdaltonJan 9, 2019

Copy link
Copy Markdown
Member

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?

@mscdexmscdexJan 9, 2019

Copy link
Copy Markdown
ContributorAuthor

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.

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

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.

Comment threadlib/os.js Outdated
@mscdex
mscdexforce-pushed the os-networkinterfaces-refactor branch from d7b7cde to b505976CompareJanuary 9, 2019 19:33
@BridgeAR

Copy link
Copy Markdown
Member

@BridgeARBridgeAR 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
Copy Markdown
Contributor

Landed in 5021b25.

@danbevdanbev 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>
@BridgeARBridgeAR 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>
@MylesBorinsMylesBorins mentioned this pull request Jan 24, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs 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++.osIssues and PRs related to the os subsystem.performanceIssues and PRs related to the performance of Node.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@mscdex@nodejs-github-bot@BridgeAR@danbev@jdalton@jasnell