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 performance of hostname and homedir by Uzlopak · Pull Request #50037 · nodejs/node

Conversation

@Uzlopak

@Uzlopak Uzlopak commented Oct 4, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This PR improves the performance of the homedir and hostname.

                          confidence improvement accuracy (*)   (**)  (***)
os/hostname.js n=1000000        ***     37.28 %       ±1.16% ±1.54% ±2.01%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 1 comparisons, you can thus expect the following amount of false-positive results:
  0.05 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.01 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)
                        confidence improvement accuracy (*)   (**)  (***)
os/homedir.js n=1000000        ***     60.71 %       ±4.49% ±6.00% ±7.88%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 1 comparisons, you can thus expect the following amount of false-positive results:
  0.05 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.01 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)
                      confidence improvement accuracy (*)   (**)  (***)
os/uptime.js n=100000        ***      0.69 %       ±0.19% ±0.26% ±0.33%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 1 comparisons, you can thus expect the following amount of false-positive results:
  0.05 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.01 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

Sorry, something went wrong.

Uh oh!

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

H4ad, bricss, and Eomm reacted with rocket emoji
All reactions
  • 🚀 3 reactions
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem. labels Oct 4, 2023
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

anonrig
anonrig approved these changes Oct 4, 2023
View reviewed changes
H4ad
H4ad reviewed Oct 4, 2023
View reviewed changes
Comment thread lib/os.js Resolved

Uh oh!

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

mscdex
mscdex reviewed Oct 4, 2023
View reviewed changes
Comment thread lib/os.js Resolved

Uh oh!

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

@Uzlopak
Uzlopak force-pushed the os-cache-homedir branch from f26183c to 344e221 Compare October 4, 2023 16:05
@Uzlopak

Uzlopak commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

@H4ad
@mscdex

Removed the caching.

H4ad reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

H4ad
H4ad approved these changes Oct 4, 2023
View reviewed changes
@Uzlopak

Uzlopak commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

Updated the benchmark in initial post.

We should discuss the caching. But this is the minimal consensus, which should be mergable.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak Uzlopak changed the title os: cache homedir, remove getCheckedFunction os: improve performance of hostname and homedir, remove getCheckedFunction Oct 4, 2023
@H4ad

H4ad commented Oct 4, 2023

Copy link
Copy Markdown
Member

@Uzlopak do we have an idea how much time it takes in ms to get the homedir?

If it's quick, I think we can land without a cache, the improvements are good enough.

If it's slow, I think adding caching will not be bad, accords to docs: https://docs.libuv.org/en/v1.x/misc.html#c.uv_os_homedir doesn't look like this information will change during the execution of the process. We only need to worry about the snapshot.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak

Uzlopak commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

I dont know how to measure the lookup time

All reactions

Sorry, something went wrong.

Uh oh!

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

@H4ad

H4ad commented Oct 4, 2023

Copy link
Copy Markdown
Member

Code:

const {homedir, hostname} = require('os')

let now = performance.now();
let value = homedir();
console.log(`Diff: ${ performance.now() - now }ms`);

now = performance.now();
value = hostname();
console.log(`Diff: ${ performance.now() - now }ms`);

Output:

Diff: 0.045215003192424774ms
Diff: 0.01658099889755249ms

Since we don't have any hot path calling this code multiple times, I think we can skip caching to not add complexity without a good reason.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak

Uzlopak commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

ah, you mean like that.

Maybe programms like npm or pnpm need homedir more excessively.

All reactions

Sorry, something went wrong.

Uh oh!

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

@mscdex

mscdex commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

Package managers are more likely to have I/O or compression/decompression be their bottleneck rather than something like os.homedir().

styfle reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@Uzlopak

Uzlopak commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig can you please add the author-ready tag?

All reactions

Sorry, something went wrong.

Uh oh!

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

@anonrig anonrig added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 4, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot mentioned this pull request Oct 5, 2023
CI Reliability 2023-10-05 nodejs/reliability#684
Open
13 tasks
mscdex
mscdex reviewed Oct 5, 2023
View reviewed changes
Comment thread lib/os.js Resolved

Uh oh!

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

@nodejs-github-bot

nodejs-github-bot commented Oct 5, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot mentioned this pull request Oct 6, 2023
CI Reliability 2023-10-06 nodejs/reliability#685
Open
10 tasks
@Uzlopak

Uzlopak commented Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

@mscdex
If #49990 lands i want to anyway split to avoid an additional hideStackFrames call.

All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Oct 7, 2023
CI Reliability 2023-10-07 nodejs/reliability#686
Open
CI Reliability 2023-10-08 nodejs/reliability#687
Open
@Uzlopak

Uzlopak commented Oct 10, 2023

Copy link
Copy Markdown
Contributor Author

@mcollina can i interest you into reviewing this PR?

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot mentioned this pull request Oct 11, 2023
CI Reliability 2023-10-11 nodejs/reliability#690
Open
30 tasks
@Uzlopak

Uzlopak commented Oct 13, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig
What about now?

All reactions

Sorry, something went wrong.

Uh oh!

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

@anonrig

anonrig commented Oct 13, 2023

Copy link
Copy Markdown
Member

@anonrig

What about now?

The CI is locked. It seems the errors are fixed in main. Can you rebase and force push?

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak
os: cache homedir, remove getCheckedFunction
ed76554
@Uzlopak
Uzlopak force-pushed the os-cache-homedir branch from 216f85a to ed76554 Compare October 13, 2023 19:47
@Uzlopak

Uzlopak commented Oct 13, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig
done

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak

Uzlopak commented Oct 14, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig
can it be merged?

All reactions

Sorry, something went wrong.

Uh oh!

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

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 14, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 14, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 14, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak Uzlopak changed the title os: improve performance of hostname and homedir, remove getCheckedFunction os: improve performance of hostname and homedir Oct 14, 2023
@Uzlopak

Uzlopak commented Oct 15, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig can you give the CI some love please? :D

H4ad and anonrig reacted with laugh emoji
All reactions
  • 😄 2 reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot

nodejs-github-bot commented Oct 15, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak

Uzlopak commented Oct 15, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig
Seems that the checks pass?

All reactions

Sorry, something went wrong.

Uh oh!

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

anonrig
anonrig approved these changes Oct 15, 2023
View reviewed changes
@anonrig anonrig added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 15, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 15, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 0f0dd1a into nodejs:main Oct 15, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 15, 2023

Copy link
Copy Markdown
Collaborator

Landed in 0f0dd1a

All reactions

Sorry, something went wrong.

Uh oh!

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

@Uzlopak
Uzlopak deleted the os-cache-homedir branch October 15, 2023 08:58
@RafaelGSS RafaelGSS mentioned this pull request Oct 15, 2023
2023-10-17, Version 21.0.0 (Current) #49870
Merged
maanu1234
maanu1234 reviewed Oct 21, 2023
View reviewed changes

@maanu1234 maanu1234 left a comment

Copy link
Copy Markdown

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.

👍

Sorry, something went wrong.

Uh oh!

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

All reactions
maanu1234
maanu1234 reviewed Oct 21, 2023
View reviewed changes

@maanu1234 maanu1234 left a comment

Copy link
Copy Markdown

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.

👍

Sorry, something went wrong.

Uh oh!

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

All reactions
@maanu1234

This comment was marked as off-topic.

Sign in to view
targos pushed a commit that referenced this pull request Nov 11, 2023
@Uzlopak @targos
os: cache homedir, remove getCheckedFunction
c25716b
PR-URL: #50037
Reviewed-By: Yagiz Nizipli <[email protected]>
@targos targos mentioned this pull request Nov 12, 2023
v20.10.0 release proposal #50682
Merged
@juanarbol juanarbol mentioned this pull request Dec 6, 2023
2023-12-06, N|Solid v5.0.1 Iron Release nodesource/nsolid#41
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@anonrig anonrig anonrig approved these changes
@H4ad H4ad H4ad approved these changes
+2 more reviewers
@mscdex mscdex mscdex left review comments
@maanu1234 maanu1234 maanu1234 left review comments
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. needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem.

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.

6 participants

@Uzlopak @nodejs-github-bot @H4ad @mscdex @anonrig @maanu1234
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 01402503 — 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.