Skip to content

perf_hooks: reuse buffer for uv metrics - #65985

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
HoonDongKang:perf-hooks-reuse-buffer-for-uv-metrics
Sep 14, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
HoonDongKang:perf-hooks-reuse-buffer-for-uv-metrics

Conversation

@HoonDongKang

Copy link
Copy Markdown
Contributor

Summary

Previously, each access to performance.nodeTiming.uvMetricsInfo allocated a new V8 array. This change reuses an AliasedInt32Array shared between C++ and JavaScript while preserving the existing public API behavior.

The shared buffer is cleared before snapshot serialization and restored during deserialization so both sides continue to reference the same memory.

Benchmark

                                                                confidence   improvement   accuracy (*)    (**)   (***)
perf_hooks/nodetiming-uvmetricsinfo.js events=1 n=1000000      ***           +158.99 %   ±12.43%  ±16.73%  ±22.15%
perf_hooks/nodetiming-uvmetricsinfo.js events=1000 n=1000000   ***           +167.65 %   ±6.95%  ±9.32%  ±12.29%
perf_hooks/nodetiming-uvmetricsinfo.js events=10000 n=1000000  ***           +162.19 %   ±7.61%  ±10.22%  ±13.51%

                                                                  -174.6%            0%            +174.6%
perf_hooks/nodetiming-uvmetricsinfo.js events=1 n=1000000                          |█████████████████░░  +158.99% ***
perf_hooks/nodetiming-uvmetricsinfo.js events=1000 n=1000000                       |██████████████████░  +167.65% ***
perf_hooks/nodetiming-uvmetricsinfo.js events=10000 n=1000000                      |██████████████████   +162.19% ***

Tests

  • test-performance-nodetiming-uvmetricsinfo
  • test-performance-nodetiming
  • test-perf-hooks-worker-timeorigin
  • test-perf-hooks
  • test-snapshot-api

Assisted-by: Codex

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Sep 11, 2026
Reuse an aliased Int32Array to transfer uv metrics from C++ to
JavaScript instead of allocating a new V8 array on every access.

Assisted-by: Codex
Signed-off-by: HoonDongKang <d159123@naver.com>
@HoonDongKang
HoonDongKang force-pushed the perf-hooks-reuse-buffer-for-uv-metrics branch from 28f8ad5 to 188975e Compare September 11, 2026 15:48
@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.19%. Comparing base (5552a06) to head (188975e).
⚠️ Report is 171 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #65985    +/-   ##
========================================
  Coverage   90.18%   90.19%            
========================================
  Files         771      771            
  Lines      264622   265501   +879     
  Branches    50222    50484   +262     
========================================
+ Hits       238659   239456   +797     
- Misses      16964    16986    +22     
- Partials     8999     9059    +60     
Files with missing lines Coverage Δ
lib/internal/perf/nodetiming.js 94.31% <100.00%> (+0.03%) ⬆️
src/node_perf.cc 87.25% <100.00%> (+0.58%) ⬆️
src/node_snapshotable.cc 73.53% <100.00%> (ø)

... and 111 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.

@daeyeon daeyeon 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 Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Benchmark GHA (perf_hooks / uvmetricsinfo): https://github.com/nodejs/node/actions/runs/34816251477

Results

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

Benchmark results:

                                                              confidence improvement accuracy (*)   (**)  (***)
perf_hooks/nodetiming-uvmetricsinfo.js events=1 n=1000000            ***     17.98 %       ±5.38% ±7.09% ±9.10%
perf_hooks/nodetiming-uvmetricsinfo.js events=1000 n=1000000         ***     16.74 %       ±4.87% ±6.42% ±8.24%
perf_hooks/nodetiming-uvmetricsinfo.js events=10000 n=1000000        ***     18.72 %       ±4.92% ±6.49% ±8.33%

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

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

@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 Sep 14, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@legendecas legendecas added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 14, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 312db1e into nodejs:main Sep 14, 2026
76 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 312db1e

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants