Skip to content

v8: add heap profiling setSampleInterval - #67626

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

IlyasShabi wants to merge 2 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
Signed-off-by: ishabi <ilyasshabi94@gmail.com>
@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 84.66258% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.71%. Comparing base (d3c4048) to head (2e03724).
⚠️ Report is 112 commits behind head on main.

Files with missing lines Patch % Lines
src/node_worker.cc 78.26% 3 Missing and 12 partials ⚠️
lib/internal/worker.js 87.50% 4 Missing ⚠️
src/node_v8.cc 80.95% 1 Missing and 3 partials ⚠️
src/node_profiling.cc 90.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67626      +/-   ##
==========================================
+ Coverage   90.66%   90.71%   +0.05%     
==========================================
  Files         799      801       +2     
  Lines      280252   281071     +819     
  Branches    54121    54286     +165     
==========================================
+ Hits       254088   254980     +892     
+ Misses      16285    16260      -25     
+ Partials     9879     9831      -48     
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% <90.47%> (+1.65%) ⬆️
lib/internal/worker.js 96.76% <87.50%> (-0.14%) ⬇️
src/node_v8.cc 87.03% <80.95%> (-0.33%) ⬇️
src/node_worker.cc 81.79% <78.26%> (-0.05%) ⬇️

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

2 participants