-
Notifications
You must be signed in to change notification settings - Fork 30k
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: lazily load getOSInformation
#50526
Conversation
getOSInformation
getOSInformation
I think the overhead you're referring to should disappear once the os module is added to the snapshot. Also, have you tried to measure how much improvement this has when you try to load the os module? |
actually I'm now trying to figure out some performance regression on os, seems there is a regression since 18.x, so I wonder if it's about the overhead from |
39ed97c
to
51aedc2
Compare
Is the regression specifically about the slowness of the |
Good point, I have run the benchmark of node-benchmark-compare ./result_22pre_vs_18.csv
confidence improvement accuracy (*) (**) (***)
os/cpus.js n=30000 *** -27.79 % ±0.49% ±0.66% ±0.87%
os/loadavg.js n=5000000 * 0.76 % ±0.64% ±0.85% ±1.11%
os/networkInterfaces.js n=10000 * 0.46 % ±0.38% ±0.51% ±0.66% and I use 20.0.0 (uv version 1.44.2) vs 18
os/cpus.js n=10000 *** 2.02 % ±0.74% ±0.99% ±1.29%
20.2.0 (uv version 1.44.2) vs 18
os/cpus.js n=10000 *** 2.44 % ±1.14% ±1.53% ±2.01%
20.3.0(uv version 1.45.0) vs 18
os/cpus.js n=10000 *** -29.91 % ±1.18% ±1.59% ±2.11%
20.4.0 (uv version 1.46.0) vs 18
os/cpus.js n=10000 *** -30.17 % ±1.30% ±1.75% ±2.31% |
What's the OS and arch of the system where this regression is reproducible? |
it can be reproduced on an x64 Ubuntu 20.04. |
Could you try to revert libuv/libuv#3861 and check if that fixes the regression? |
It's almost certainly the libuv update. See libuv/libuv#4098. |
I have compared the reverted version of libuv, it shows the similar performance differences to 18.x vs 22.x pre, the libuv PR you mentioned collects CPU information more accurately while introduces some system calls or allocation, which I believe is the main reason for the performance regression. |
Looks like this is working as intended then. Should we go ahead and close this PR and #50525? |
I‘ll close it, thanks for your advice |
changes the strategy for obtaining operating system information
by implementing a lazy loading approach. Instead of immediately
invoking
_getOSInformation()
upon module load.Fixes: #50525