Skip to content

v8: add heap profiling setSampleInterval - #67626

Open
IlyasShabi wants to merge 4 commits into
nodejs:mainfrom
IlyasShabi:ishabi/profiling-sample-interval
Open

IlyasShabi wants to merge 4 commits into
nodejs:mainfrom
IlyasShabi:ishabi/profiling-sample-interval

Conversation

@IlyasShabi

Copy link
Copy Markdown
Member

The heap profiler’s sampling interval is currently fixed for each session. Changing it requires stopping and restarting profiling, which breaks profile continuity.

This PR exposes the APIs added in the V8 change:

  • setSampleInterval(sampleInterval) updates the interval without restarting profiling or discarding existing samples.
  • getSamples() retrieves retained allocation samples without stopping profiling or building the full profile call tree.
  • Each sample includes sampleInterval, recording the interval used when it was selected.
    Both methods are available on handles returned by v8.startHeapProfile() and worker.startHeapProfile().

@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 Nov 19, 2026
@IlyasShabi
IlyasShabi force-pushed the ishabi/profiling-sample-interval branch from c414e6a to 8d819d6 Compare November 19, 2026 20:11
@IlyasShabi
IlyasShabi marked this pull request as ready for review November 19, 2026 20:12
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.90805% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.54%. Comparing base (a337566) to head (11e2053).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/node_worker.cc 76.05% 3 Missing and 14 partials ⚠️
src/node_v8.cc 79.16% 0 Missing and 5 partials ⚠️
lib/internal/worker.js 87.50% 4 Missing ⚠️
src/node_profiling.cc 92.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #67626    +/-   ##
========================================
  Coverage   90.53%   90.54%            
========================================
  Files         803      803            
  Lines      285110   285278   +168     
  Branches    55032    55068    +36     
========================================
+ Hits       258122   258298   +176     
+ Misses      17133    17099    -34     
- Partials     9855     9881    +26     
Files with missing lines Coverage Δ
lib/internal/errors.js 98.12% <100.00%> (+<0.01%) ⬆️
lib/v8.js 98.77% <100.00%> (+0.35%) ⬆️
src/node_profiling.h 100.00% <ø> (ø)
src/node_worker.h 92.30% <ø> (ø)
src/node_profiling.cc 84.15% <92.59%> (+1.65%) ⬆️
lib/internal/worker.js 96.76% <87.50%> (-0.14%) ⬇️
src/node_v8.cc 86.72% <79.16%> (-0.32%) ⬇️
src/node_worker.cc 81.41% <76.05%> (-0.19%) ⬇️

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

Comment thread src/node_v8.cc Resolved
Comment thread src/node_profiling.cc Resolved
@IlyasShabi
IlyasShabi requested a review from jasnell November 23, 2026 14:23
@IlyasShabi
IlyasShabi force-pushed the ishabi/profiling-sample-interval branch from 14f3a33 to 11e2053 Compare November 24, 2026 09:51
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