Uh oh!
There was an error while loading. Please reload this page.
os: improve performance of hostname and homedir - #50037
Conversation
nodejs-github-bot
commented
Oct 4, 2023
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uzlopak
commented
Oct 4, 2023
Uzlopak
commented
Oct 4, 2023
Updated the benchmark in initial post. We should discuss the caching. But this is the minimal consensus, which should be mergable. |
H4ad
commented
Oct 4, 2023
@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. |
Uzlopak
commented
Oct 4, 2023
I dont know how to measure the lookup time |
H4ad
commented
Oct 4, 2023
Code: const{homedir, hostname}=require('os')letnow=performance.now();letvalue=homedir();console.log(`Diff: ${performance.now()-now}ms`);now=performance.now();value=hostname();console.log(`Diff: ${performance.now()-now}ms`);Output: 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. |
Uzlopak
commented
Oct 4, 2023
ah, you mean like that. Maybe programms like npm or pnpm need homedir more excessively. |
mscdex
commented
Oct 4, 2023
Package managers are more likely to have I/O or compression/decompression be their bottleneck rather than something like |
Uzlopak
commented
Oct 4, 2023
@anonrig can you please add the author-ready tag? |
nodejs-github-bot
commented
Oct 4, 2023
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Oct 5, 2023
Uzlopak
commented
Oct 6, 2023
Uzlopak
commented
Oct 10, 2023
@mcollina can i interest you into reviewing this PR? |
Uzlopak
commented
Oct 13, 2023
@anonrig |
anonrig
commented
Oct 13, 2023
The CI is locked. It seems the errors are fixed in main. Can you rebase and force push? |
216f85a to
ed76554CompareUzlopak
commented
Oct 13, 2023
@anonrig |
Uzlopak
commented
Oct 14, 2023
@anonrig |
nodejs-github-bot
commented
Oct 14, 2023
Uzlopak
commented
Oct 15, 2023
@anonrig can you give the CI some love please? :D |
nodejs-github-bot
commented
Oct 15, 2023
Uzlopak
commented
Oct 15, 2023
@anonrig |
nodejs-github-bot
commented
Oct 15, 2023
Landed in 0f0dd1a |
This comment was marked as off-topic.
This comment was marked as off-topic.
PR-URL: #50037 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This PR improves the performance of the homedir and hostname.