Skip to content

Conversation

@LiviaMedeiros
Copy link
Member

The internal hideStackFrames() returns wrapper function with .name === 'wrappedFn' (and .length === 0 which aligns with desired value), and these wrappers are exported directly to userspace. Let's give them more meaningful names.

@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 May 4, 2025
Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let's run benchmarks before these changes, so we know there aren't any regressions.

const getHostname = getCheckedFunction(_getHostname);
const getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses);
const getUptime = getCheckedFunction(_getUptime);
const getHomeDirectory = getCheckedFunction(_getHomeDirectory, 'getHomeDirectory');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we run benchmarks on these changes?

@anonrig anonrig added the needs-benchmark-ci PR that need a benchmark CI run. label May 4, 2025
@codecov
Copy link

codecov bot commented May 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.17%. Comparing base (a44ccac) to head (d1f1996).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58159      +/-   ##
==========================================
- Coverage   90.17%   90.17%   -0.01%     
==========================================
  Files         630      630              
  Lines      186503   186506       +3     
  Branches    36618    36615       -3     
==========================================
- Hits       168188   168179       -9     
- Misses      11120    11125       +5     
- Partials     7195     7202       +7     
Files with missing lines Coverage Δ
lib/os.js 98.60% <100.00%> (+0.01%) ⬆️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aduh95
Copy link
Contributor

aduh95 commented Sep 6, 2025

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1729/console

Cross-platform benchmark: https://github.com/aduh95/node/actions/runs/17515746884/job/49757490320

Shows no significant perf change
                                                                                      confidence improvement   accuracy (*)           (**)          (***)
misc/arguments.js n=1000000 method='argumentsAndApply'                                               -0.03 %  ±4.78%  ±6.30%  ±8.08%
misc/arguments.js n=1000000 method='predefined'                                                       0.23 %  ±4.69%  ±6.18%  ±7.93%
misc/arguments.js n=1000000 method='restAndApply'                                                     0.70 %  ±4.67%  ±6.16%  ±7.90%
misc/arguments.js n=1000000 method='restAndSpread'                                                    0.36 %  ±4.71%  ±6.21%  ±7.96%
misc/freelist.js n=100000                                                                            -0.17 %  ±3.35%  ±4.42%  ±5.67%
misc/getstringwidth.js n=100000 type='ascii'                                                          0.04 %  ±5.09%  ±6.71%  ±8.61%
misc/getstringwidth.js n=100000 type='emojiseq'                                                       0.56 %  ±6.41%  ±8.45% ±10.85%
misc/getstringwidth.js n=100000 type='fullwidth'                                                     -0.05 %  ±3.33%  ±4.39%  ±5.64%
misc/getstringwidth.js n=100000 type='mixed'                                                          0.40 %  ±3.81%  ±5.02%  ±6.44%
misc/object-property-bench.js n=1000000000 method='property'                                          0.33 %  ±7.28%  ±9.60% ±12.32%
misc/object-property-bench.js n=1000000000 method='string'                                            0.34 %  ±7.23%  ±9.53% ±12.23%
misc/object-property-bench.js n=1000000000 method='symbol'                                           -0.02 %  ±7.01%  ±9.24% ±11.85%
misc/object-property-bench.js n=1000000000 method='variable'                                          0.20 %  ±6.96%  ±9.17% ±11.77%
misc/print.js code='"string"' dur=1                                                                   0.31 % ±13.45% ±17.73% ±22.75%
misc/print.js code='1' dur=1                                                                         -0.30 % ±13.42% ±17.69% ±22.69%
misc/print.js code='process' dur=1                                                                    0.57 % ±13.48% ±17.77% ±22.81%
misc/print.js code='process.versions' dur=1                                                           0.37 % ±13.39% ±17.66% ±22.65%
misc/startup-cli-version.js n=30 cli='deps/corepack/dist/corepack.js'                                 0.12 % ±10.31% ±13.59% ±17.43%
misc/startup-cli-version.js n=30 cli='deps/npm/bin/npm-cli.js'                                       -0.24 %  ±8.82% ±11.62% ±14.91%
misc/startup-cli-version.js n=30 cli='deps/npm/bin/npx-cli.js'                                       -0.26 %  ±8.80% ±11.59% ±14.88%
misc/startup-core.js n=30 mode='process' script='benchmark/fixtures/require-builtins'                 0.18 % ±11.14% ±14.69% ±18.85%
misc/startup-core.js n=30 mode='process' script='test/fixtures/semicolon'                             0.27 % ±14.97% ±19.73% ±25.32%
misc/startup-core.js n=30 mode='process' script='test/fixtures/snapshot/typescript'                   0.31 %  ±7.01%  ±9.24% ±11.86%
misc/startup-core.js n=30 mode='worker' script='benchmark/fixtures/require-builtins'                  0.01 %  ±8.31% ±10.95% ±14.05%
misc/startup-core.js n=30 mode='worker' script='test/fixtures/semicolon'                             -0.01 %  ±8.43% ±11.11% ±14.26%
misc/startup-core.js n=30 mode='worker' script='test/fixtures/snapshot/typescript'                    1.00 %  ±7.82% ±10.31% ±13.23%
misc/structured-clone.js n=10000 type='arraybuffer'                                                  -0.19 %  ±8.62% ±11.36% ±14.58%
misc/structured-clone.js n=10000 type='object'                                                        1.55 %  ±8.01% ±10.56% ±13.55%
misc/structured-clone.js n=10000 type='string'                                                        0.04 %  ±5.80%  ±7.64%  ±9.80%
misc/trace.js method='isTraceCategoryEnabled' n=100000                                               -0.46 % ±10.62% ±14.00% ±17.96%
misc/trace.js method='trace' n=100000                                                                 0.59 % ±10.23% ±13.49% ±17.31%
misc/util-extend-vs-object-assign.js n=100000 type='assign'                                          -0.60 %  ±5.76%  ±7.59%  ±9.74%
misc/util-extend-vs-object-assign.js n=100000 type='extend'                                          -0.20 %  ±6.01%  ±7.92% ±10.16%
os/cpus.js n=30000                                                                                    0.65 % ±18.81% ±24.79% ±31.81%
os/homedir.js n=1000000                                                                               1.12 %  ±5.42%  ±7.15%  ±9.17%
os/hostname.js n=1000000                                                                              0.21 % ±10.18% ±13.41% ±17.21%
os/loadavg.js n=5000000                                                                               0.36 % ±20.33% ±26.80% ±34.39%
os/networkInterfaces.js n=10000                                                                       0.95 % ±10.27% ±13.54% ±17.37%
os/tmpdir.js n=1000000                                                                                0.48 %  ±6.71%  ±8.84% ±11.35%
os/uptime.js n=100000                                                                                -0.28 % ±21.15% ±27.88% ±35.78%
Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 40 comparisons, you can thus
expect the following amount of false-positive results:
  2.00 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.40 false positives, when considering a   1% risk acceptance (**, ***),
  0.04 false positives, when considering a 0.1% risk acceptance (***)
                                                                                      confidence improvement accuracy (*)    (**)    (***)
misc/arguments.js n=1000000 method='argumentsAndApply'                                                1.17 %       ±1.69%  ±2.25%   ±2.93%
misc/arguments.js n=1000000 method='predefined'                                                      -0.67 %       ±1.46%  ±1.94%   ±2.53%
misc/arguments.js n=1000000 method='restAndApply'                                                     0.41 %       ±1.22%  ±1.62%   ±2.11%
misc/arguments.js n=1000000 method='restAndSpread'                                                    0.75 %       ±1.37%  ±1.82%   ±2.37%
misc/freelist.js n=100000                                                                             0.01 %       ±0.94%  ±1.26%   ±1.64%
misc/getstringwidth.js n=100000 type='ascii'                                                         -0.01 %       ±0.29%  ±0.39%   ±0.51%
misc/getstringwidth.js n=100000 type='emojiseq'                                                *      1.38 %       ±1.12%  ±1.50%   ±1.96%
misc/getstringwidth.js n=100000 type='fullwidth'                                                      0.45 %       ±0.73%  ±0.98%   ±1.28%
misc/getstringwidth.js n=100000 type='mixed'                                                          0.06 %       ±0.59%  ±0.79%   ±1.03%
misc/object-property-bench.js n=1000000000 method='property'                                         -0.08 %       ±0.13%  ±0.18%   ±0.23%
misc/object-property-bench.js n=1000000000 method='string'                                            0.11 %       ±0.23%  ±0.31%   ±0.41%
misc/object-property-bench.js n=1000000000 method='symbol'                                           -0.06 %       ±0.21%  ±0.28%   ±0.36%
misc/object-property-bench.js n=1000000000 method='variable'                                          0.06 %       ±0.26%  ±0.34%   ±0.45%
misc/print.js code='"string"' dur=1                                                                   0.15 %       ±0.96%  ±1.28%   ±1.66%
misc/print.js code='1' dur=1                                                                          0.35 %       ±0.77%  ±1.02%   ±1.33%
misc/print.js code='process.versions' dur=1                                                           0.84 %       ±0.92%  ±1.22%   ±1.59%
misc/print.js code='process' dur=1                                                                   -0.25 %       ±0.88%  ±1.17%   ±1.53%
misc/startup-cli-version.js n=30 cli='deps/corepack/dist/corepack.js'                                -0.12 %       ±0.55%  ±0.74%   ±0.96%
misc/startup-cli-version.js n=30 cli='deps/npm/bin/npm-cli.js'                                       -0.22 %       ±0.39%  ±0.53%   ±0.69%
misc/startup-cli-version.js n=30 cli='deps/npm/bin/npx-cli.js'                                       -0.12 %       ±0.38%  ±0.51%   ±0.67%
misc/startup-core.js n=30 mode='process' script='benchmark/fixtures/require-builtins'          *      0.79 %       ±0.65%  ±0.86%   ±1.13%
misc/startup-core.js n=30 mode='process' script='test/fixtures/semicolon'                            -1.74 %       ±2.68%  ±3.57%   ±4.66%
misc/startup-core.js n=30 mode='process' script='test/fixtures/snapshot/typescript'                   0.02 %       ±0.14%  ±0.18%   ±0.24%
misc/startup-core.js n=30 mode='worker' script='benchmark/fixtures/require-builtins'                  0.02 %       ±0.22%  ±0.30%   ±0.39%
misc/startup-core.js n=30 mode='worker' script='test/fixtures/semicolon'                              0.15 %       ±0.35%  ±0.46%   ±0.60%
misc/startup-core.js n=30 mode='worker' script='test/fixtures/snapshot/typescript'                    0.02 %       ±0.09%  ±0.12%   ±0.16%
misc/structured-clone.js n=10000 type='arraybuffer'                                                  -1.02 %       ±4.00%  ±5.32%   ±6.93%
misc/structured-clone.js n=10000 type='object'                                                       -0.01 %       ±0.58%  ±0.77%   ±1.00%
misc/structured-clone.js n=10000 type='string'                                                       -0.55 %       ±3.32%  ±4.42%   ±5.75%
misc/trace.js method='isTraceCategoryEnabled' n=100000                                                1.94 %       ±6.86%  ±9.13%  ±11.88%
misc/trace.js method='trace' n=100000                                                                -0.75 %       ±1.88%  ±2.51%   ±3.27%
misc/util-extend-vs-object-assign.js n=100000 type='assign'                                          -0.27 %       ±0.49%  ±0.65%   ±0.85%
misc/util-extend-vs-object-assign.js n=100000 type='extend'                                           0.05 %       ±0.63%  ±0.84%   ±1.11%
os/cpus.js n=30000                                                                                    0.27 %       ±0.50%  ±0.67%   ±0.88%
os/homedir.js n=1000000                                                                              -0.71 %       ±1.55%  ±2.07%   ±2.69%
os/hostname.js n=1000000                                                                             -0.00 %       ±0.57%  ±0.76%   ±0.99%
os/loadavg.js n=5000000                                                                               0.05 %       ±0.43%  ±0.57%   ±0.74%
os/networkInterfaces.js n=10000                                                                       3.76 %      ±62.03% ±82.54% ±107.44%
os/tmpdir.js n=1000000                                                                               -0.04 %       ±0.10%  ±0.13%   ±0.17%
os/uptime.js n=100000                                                                                 0.26 %       ±0.41%  ±0.54%   ±0.71%

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

@aduh95 aduh95 requested a review from anonrig September 6, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants