-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Conversation
if (existing !== undefined) | ||
existing.push(entry); | ||
else | ||
result[name] = [entry]; | ||
} |
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.
Can you explain the perf benefit for networkInterfaces()
?
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.
What do you mean?
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.
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?
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.
It's more or less moving the object creation from C++ to JS land, just like we do for CPU enumeration.
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 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.
d7b7cde
to
b505976
Compare
Landed in 5021b25. |
PR-URL: #25410 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #25410 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#25410 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
With included benchmark:
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), orvcbuild test
(Windows) passes