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 — os: improve networkInterfaces performance by BridgeAR · Pull Request #22359 · nodejs/node

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Aug 16, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This algorithm uses less data transformations and is therefore
significantly faster than the one before.

The main pain point is how the CIDR suffix is calculated. It would
be best to port this to C++ instead of having to do this in JS as all other
transformations are done in C++. But since this improves the
performance already quite a bit it's a good first step.

Performance:

> console.time(); for(var i = 0; i < 10000; i++) os.networkInterfaces(); console.timeEnd()

// Before
default: 1170.912ms

// After:
default: 758.899ms
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • 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 Aug 16, 2018

Copy link
Copy Markdown
Collaborator

@BridgeAR build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/572/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 build Issues and PRs related to Node.js builds or CI infrastructure. os Issues and PRs related to the os subsystem. labels Aug 16, 2018
@BridgeAR BridgeAR added the performance Issues and PRs related to the performance of Node.js. label Aug 16, 2018
@BridgeAR
BridgeAR requested a review from mafintosh August 16, 2018 12:39
@BridgeAR
BridgeAR force-pushed the improve-comparison-performance branch 2 times, most recently from e7c90b9 to bb4a589 Compare August 16, 2018 13:30
@BridgeAR

BridgeAR commented Aug 16, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@BridgeAR
BridgeAR force-pushed the improve-comparison-performance branch from bb4a589 to e625c9d Compare August 16, 2018 13:38
mafintosh
mafintosh approved these changes Aug 16, 2018
View reviewed changes
@mafintosh

mafintosh commented Aug 16, 2018

Copy link
Copy Markdown
Member

LGTM, nice!

All reactions

Sorry, something went wrong.

Uh oh!

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

jasnell
jasnell approved these changes Aug 16, 2018
View reviewed changes
TimothyGu
TimothyGu approved these changes Aug 16, 2018
View reviewed changes
@BridgeAR

BridgeAR commented Aug 16, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I just pushed another commit that optimizes the algorithm. It is now a much simpler and straight forward as I calculate the number of ones right away and use modulo 2 to validate the entry.

New benchmark result:

> console.time(); for(var i = 0; i < 10000; i++) os.networkInterfaces(); console.timeEnd()
default: 758.899ms
All reactions

Sorry, something went wrong.

Uh oh!

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

maclover7
maclover7 reviewed Aug 16, 2018
View reviewed changes
Comment thread lib/os.js Resolved

Uh oh!

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

@BridgeAR

BridgeAR commented Aug 16, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

New CI https://ci.nodejs.org/job/node-test-pull-request/16506/
New CI https://ci.nodejs.org/job/node-test-pull-request/16512/

All reactions

Sorry, something went wrong.

Uh oh!

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

@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Aug 16, 2018
This was referenced Aug 17, 2018
Git lock in test-azure_msft-win10-x64-3 exists nodejs/build#1460
Closed
CI Failures: 20180817 nodejs/reliability#14
Closed
lpinca
lpinca reviewed Aug 18, 2018
View reviewed changes
Comment thread lib/os.js Outdated

@lpinca lpinca Aug 18, 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.

Since you are rewriting this for performance, is for...of as fast as the classic for loop now?

Sorry, something went wrong.

Uh oh!

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

All reactions

@BridgeAR BridgeAR Aug 19, 2018

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

Tracking bug: https://bugs.chromium.org/p/v8/issues/detail?id=8070

Sorry, something went wrong.

Uh oh!

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

All reactions
lpinca
lpinca reviewed Aug 18, 2018
View reviewed changes
Comment thread lib/os.js Outdated

@lpinca lpinca Aug 18, 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.

You could use (binary & 1) !== 0. Last time I tried the reminder operator was not optimized for this, maybe it is now, don't know.

Sorry, something went wrong.

Uh oh!

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

All reactions

@BridgeAR BridgeAR Aug 19, 2018

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

Tracking bug https://bugs.chromium.org/p/v8/issues/detail?id=8069

Sorry, something went wrong.

Uh oh!

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

All reactions

@BridgeAR BridgeAR Aug 20, 2018

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

Fixed in 6.0: https://crrev.com/35974e2da664fdbc5678b540e2ab0c64b1bbd182

Sorry, something went wrong.

Uh oh!

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

lpinca reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
addaleax
addaleax reviewed Aug 19, 2018
View reviewed changes
Comment thread lib/os.js Resolved

Uh oh!

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

@BridgeAR

BridgeAR commented Aug 19, 2018

Copy link
Copy Markdown
Member Author

Comments addressed. The performance is now again a tiny bit improved compared to before by using:

  1. Simple for loops
  2. No Object.values
  3. Using the binary operator instead of modulo
All reactions

Sorry, something went wrong.

Uh oh!

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

@BridgeAR

BridgeAR commented Aug 19, 2018

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

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

BridgeAR added 2 commits August 19, 2018 18:56
@BridgeAR
os: improve networkInterfaces performance
f7c1aed
This algorithm uses less data transformations and is therefore
significantly faster than the one before.
@BridgeAR
fixup: address comments
17f4930
@BridgeAR
BridgeAR force-pushed the improve-comparison-performance branch from 0baa2d7 to 17f4930 Compare August 19, 2018 16:57
@BridgeAR

BridgeAR commented Aug 19, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Rebased due to a hiccup with the CI. I only squashed commits that were already reviewed.

CI https://ci.nodejs.org/job/node-test-pull-request/16576/ ✔️

All reactions

Sorry, something went wrong.

Uh oh!

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

@mafintosh

mafintosh commented Aug 19, 2018

Copy link
Copy Markdown
Member

Still LGTM

All reactions

Sorry, something went wrong.

Uh oh!

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

@joyeecheung joyeecheung mentioned this pull request Aug 20, 2018
test-digitalocean-fedora27-x64-1 keeps timing out nodejs/build#1463
Closed
@joyeecheung joyeecheung mentioned this pull request Aug 20, 2018
CI failures: 20180820 nodejs/reliability#15
Closed
@BridgeAR

BridgeAR commented Aug 20, 2018

Copy link
Copy Markdown
Member Author

@addaleax @lpinca mind taking another look?

All reactions

Sorry, something went wrong.

Uh oh!

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

lpinca
lpinca approved these changes Aug 20, 2018
View reviewed changes
BridgeAR added a commit to BridgeAR/node that referenced this pull request Aug 20, 2018
@BridgeAR
os: improve networkInterfaces performance
9bcb744
This algorithm uses less data transformations and is therefore
significantly faster than the one before.

PR-URL: nodejs#22359
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@BridgeAR

BridgeAR commented Aug 20, 2018

Copy link
Copy Markdown
Member Author

Landed in 9bcb744 🎉

All reactions

Sorry, something went wrong.

Uh oh!

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

@BridgeAR BridgeAR closed this Aug 20, 2018
targos pushed a commit that referenced this pull request Aug 21, 2018
@BridgeAR @targos
os: improve networkInterfaces performance
a7d91f4
This algorithm uses less data transformations and is therefore
significantly faster than the one before.

PR-URL: #22359
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this pull request Sep 3, 2018
@BridgeAR @targos
os: improve networkInterfaces performance
3b44053
This algorithm uses less data transformations and is therefore
significantly faster than the one before.

PR-URL: #22359
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@targos targos mentioned this pull request Sep 5, 2018
Release proposal: v10.10.0 #22716
Merged
This was referenced Sep 6, 2018
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-android-nodejs#236
Closed
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-nodejs#221
Closed
@BridgeAR BridgeAR mentioned this pull request Dec 20, 2019
for ... of replacing for(;;) in library networking code? #31024
Closed
@BridgeAR
BridgeAR deleted the improve-comparison-performance branch January 20, 2020 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax left review comments
@jasnell jasnell jasnell approved these changes
@lpinca lpinca lpinca approved these changes
+3 more reviewers
@maclover7 maclover7 maclover7 left review comments
@mafintosh mafintosh mafintosh approved these changes
@TimothyGu TimothyGu TimothyGu 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

author ready PRs with CI started, the required approvals, and no outstanding review comments. build Issues and PRs related to Node.js builds or CI infrastructure. os Issues and PRs related to the os subsystem. performance Issues and PRs related to the performance of Node.js.

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.

8 participants

@BridgeAR @nodejs-github-bot @mafintosh @jasnell @addaleax @lpinca @TimothyGu @maclover7
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.