Skip to content

perf_hooks: reuse buffer for uv metrics - #65985

Open
HoonDongKang wants to merge 1 commit into
nodejs:mainfrom
HoonDongKang:perf-hooks-reuse-buffer-for-uv-metrics
Open

perf_hooks: reuse buffer for uv metrics#65985
HoonDongKang wants to merge 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 113 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants