Skip to content

src: speed up heap profile serialization - #67685

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
IlyasShabi:ishabi/fast-heap-profile-serialization
Nov 24, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
IlyasShabi:ishabi/fast-heap-profile-serialization

Conversation

@IlyasShabi

Copy link
Copy Markdown
Member

Heap profile serialization uses formatted stream insertions for each JSON token and number. Stopping a main thread or worker heap profile also copies the completed stream buffer before creating the JS string.

This PR adds a std::string output path to JSONWriter that uses std::to_chars for numeric values. Heap profile serialization now uses this path to avoid stream formatting overhead and the extra output copy.

Local benchmark:

                                 confidence improvement accuracy (*)   (**)   (***)
v8/heap-profile-stop.js n=10000         ***    164.91 %       ±6.99% ±9.39% ±12.38%
v8/heap-profile-stop.js n=100000        ***    153.96 %       ±6.08% ±8.16% ±10.75%

we can use the same JSONWriter functions to improve heap near limit profile, v8.GCProfiler, and probably process.report on followup PRs.

Signed-off-by: ishabi <ilyasshabi94@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. worker Issues and PRs related to the worker_threads module and Worker API. labels Nov 21, 2026
@IlyasShabi
IlyasShabi marked this pull request as ready for review November 21, 2026 23:26

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 22, 2026
@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 Nov 22, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@IlyasShabi IlyasShabi added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 23, 2026
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Failed to start CI

   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79402/
   ✖  Refusing to start a potentially duplicate CI job. Resume CI by adding the "resume-ci" label to the PR, or run: ncu-ci resume https://github.com/nodejs/node/pull/67685
Full Auto Start CI output
�[36m⠋�[39m Getting reviews from nodejs/node/pull/67685
�[36m⠋�[39m Getting commits from nodejs/node/pull/67685
�[36m⠙�[39m Validating Jenkins credentials
�[36m⠙�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠹�[39m Getting comments from nodejs/node/pull/67685
�[36m⠸�[39m Querying data for job/node-test-pull-request/79402/
�[36m⠸�[39m Querying data for job/node-test-pull-request/79402/
�[36m⠸�[39m Querying API for job/node-test-pull-request/79402/
✔  Build data downloaded
   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79402/
   ✖  Refusing to start a potentially duplicate CI job. Resume CI by adding the "resume-ci" label to the PR, or run: ncu-ci resume https://github.com/nodejs/node/pull/67685

View workflow run

@IlyasShabi IlyasShabi added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 23, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@IlyasShabi IlyasShabi added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 24, 2026
@nodejs-github-bot
nodejs-github-bot merged commit e7db489 into nodejs:main Nov 24, 2026
95 of 108 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in e7db489

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 24, 2026
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++. needs-ci PRs that need a full CI run. request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. v8 engine Issues and PRs related to the V8 dependency. worker Issues and PRs related to the worker_threads module and Worker API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants