Skip to content

deps: V8: cherry-pick 0f024d4e66e0#62408

Closed
IlyasShabi wants to merge 1 commit intonodejs:mainfrom
IlyasShabi:ishabi/v8-islive-sample
Closed

deps: V8: cherry-pick 0f024d4e66e0#62408
IlyasShabi wants to merge 1 commit intonodejs:mainfrom
IlyasShabi:ishabi/v8-islive-sample

Conversation

@IlyasShabi
Copy link
Copy Markdown
Member

Original commit message:

[heap profiler] Add is_live field to AllocationProfile::Sample

When using kSamplingIncludeObjectsCollectedByMajorGC/MinorGC flag, samples for collected objects are retained but callers had no way to distinguish live from dead objects.
Add is_live to expose this information.

Change-Id: I2e930644348ff942caa4b192a127c5baa05bbfef
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7603535
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#105698}

Refs: v8/v8@0f024d4

Motivation and changes

Continues the heap profiler improvements started in #62201 and #62273.

V8's StartSamplingHeapProfiler accepts GC flags that retain samples even after the objects are GC'd. However, there was no way to distinguish whether a sampled allocation was still alive or had already been freed.

With this commit, we can:

  • Compute allocated vs freed memory
  • Identify functions causing GC pressure due to high allocation and more..

As a follow-up, SerializeHeapProfile will be updated to include per-node freed object size based on is_live field from GetSamples().

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. labels Mar 23, 2026
@IlyasShabi IlyasShabi requested a review from Qard March 23, 2026 14:14
@IlyasShabi IlyasShabi marked this pull request as ready for review March 23, 2026 14:15
@IlyasShabi IlyasShabi added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 23, 2026
@targos
Copy link
Copy Markdown
Member

targos commented Mar 24, 2026

Is this ABI-compatible?

@IlyasShabi
Copy link
Copy Markdown
Member Author

Is this ABI-compatible?

This is ABI compatible since the commit adds a new field bool is_live at the end of the AllocationProfile::Sample struct. Node.js already consumes GetSamples() in src/node_worker.cc

@panva panva removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 25, 2026
@IlyasShabi IlyasShabi added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Mar 25, 2026
@IlyasShabi IlyasShabi requested review from Qard and targos March 25, 2026 15:32
@IlyasShabi
Copy link
Copy Markdown
Member Author

@Qard @targos could you please check this PR again?

@targos
Copy link
Copy Markdown
Member

targos commented Mar 26, 2026

My understanding of structs is that adding fields cannot be ABI-compatible because it changes the size of the object. @nodejs/cpp-reviewers

@IlyasShabi
Copy link
Copy Markdown
Member Author

Yes the struct size does matter for ABI compatibility. But AllocationProfile::Sample is never constructed by Node.js, V8 creates and owns them internally. we only reads fields from the returned samples in src/node_worker.cc so adding a field here is safe.

@joyeecheung
Copy link
Copy Markdown
Member

joyeecheung commented Mar 26, 2026

Our V8 header and all the symbols are exposed, so regardless of whether Node.js uses them internally, user land addons can already rely on them (and I think there are probably a long tail of addons or libraries that do, e.g. #61102, note that we don't use the default platform internally)

@IlyasShabi
Copy link
Copy Markdown
Member Author

IlyasShabi commented Mar 26, 2026

That's clear! I understand now how backporting in a patch release could break addons.
Would it make sense to include this commit in #61898 where ABI changes are already expected maybe?

@aduh95 aduh95 added semver-major PRs that contain breaking changes and should be released in the next major version. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Mar 27, 2026
@IlyasShabi
Copy link
Copy Markdown
Member Author

Keep this PR open until #61898 is merged, then ask the release team to land it in v26.

@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 force-pushed the ishabi/v8-islive-sample branch from 2806f85 to 83e86e3 Compare April 23, 2026 08:41
@richardlau richardlau added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 27, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 27, 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. label Apr 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 28, 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. label Apr 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 28, 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

@BridgeAR
Copy link
Copy Markdown
Member

The CI seems very flaky and the V8 CI is green. Is anyone against landing this as is manually?

@RafaelGSS
Copy link
Copy Markdown
Member

The CI seems very flaky and the V8 CI is green. Is anyone against landing this as is manually?

I looked at CI failures, and most of them seem flaky indeed. I'm just not sure about https://ci.nodejs.org/job/node-test-commit-arm-debug/23124/#showFailuresLink - I'd defer to @joyeecheung or someone else more experienced with this group of tests.

@BridgeAR
Copy link
Copy Markdown
Member

@RafaelGSS those were green in a former run: https://ci.nodejs.org/job/node-test-commit-arm-debug/23142/

@IlyasShabi
Copy link
Copy Markdown
Member Author

Linux contained was green before https://ci.nodejs.org/job/node-test-commit-linux-containered/56015/

bengl pushed a commit that referenced this pull request Apr 28, 2026
Original commit message:

    [heap profiler] Add is_live field to AllocationProfile::Sample

    When using kSamplingIncludeObjectsCollectedByMajorGC/MinorGC flag, samples for collected objects are retained but callers had no way to distinguish live from dead objects.
    Add is_live to expose this information.

    Change-Id: I2e930644348ff942caa4b192a127c5baa05bbfef
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7603535
    Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
    Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
    Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105698}

Refs: v8/v8@0f024d4
Signed-off-by: ishabi <ilyasshabi94@gmail.com>
PR-URL: #62408
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR
Copy link
Copy Markdown
Member

Landed in 8385efc

@BridgeAR BridgeAR closed this Apr 28, 2026
@joyeecheung
Copy link
Copy Markdown
Member

From the reliability reports it seems the flakes only started to appear in the report from April 28 nodejs/reliability#1524 but not on 27 nodejs/reliability#1523 and it's limited to arm64 containers.

It's likely either a regression in the code or in the build. From the code it's not obvious to me which one can trigger it. @nodejs/build any recent changes to the arm64 containers?

@richardlau
Copy link
Copy Markdown
Member

richardlau commented Apr 28, 2026

It's likely either a regression in the code or in the build. From the code it's not obvious to me which one can trigger it. @nodejs/build any recent changes to the arm64 containers?

Not within the last three weeks (azure)/two weeks (osuosl) (according to docker ps output).

@IlyasShabi
Copy link
Copy Markdown
Member Author

According to the April 28 reliability report nodejs/reliability#1524, the arm64 failures started before this PR’s CI run it was around 72902 / 72903

@IlyasShabi IlyasShabi deleted the ishabi/v8-islive-sample branch April 28, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants