Skip to content

Conversation

@caiolima
Copy link

The idea is to back port this commit to also expose Total Allocated bytes in V8's HeapStatistics API.

Original commit message:

[api] Adding total allocated bytes in HeapStatistics

This change exposes total allocated bytes in v8::HeapStatistics API by
introducing a new total_allocated_bytes() method that tracks all heap
allocations since an Isolate creation.

The implementation adds:
- uint64_t total_allocated_bytes_ field to HeapStatistics.
- An atomic total allocation counter is stored in the Heap class.
- The counter is incremented whenever a RestLab is called. This approach can overestimate the total allocation for cases where the LAB is not fully used, but the leftover compared to the LAB itself is quite small, so it seems tolerable.

Design doc reference:
https://docs.google.com/document/d/1O4JPsoaxTQsX_7T5Fz4rsGeHMiM16jUrvDuq9FrtbNM

Change-Id: Ic531698aaeb1578f943b7fdd346b9159ffd9b6c9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6996467
Reviewed-by: Dominik Inführ <[email protected]>
Reviewed-by: Michael Lippautz <[email protected]>
Commit-Queue: Dmitry Bezhetskov <[email protected]>
Cr-Commit-Position: refs/heads/main@{#103296}

Refs: v8/v8@fe81545

Original commit message:

    [api] Adding total allocated bytes in HeapStatistics

    This change exposes total allocated bytes in v8::HeapStatistics API by
    introducing a new total_allocated_bytes() method that tracks all heap
    allocations since an Isolate creation.

    The implementation adds:
    - uint64_t total_allocated_bytes_ field to HeapStatistics.
    - An atomic total allocation counter is stored in the Heap class.
    - The counter is incremented whenever a RestLab is called. This approach can overestimate the total allocation for cases where the LAB is not fully used, but the leftover compared to the LAB itself is quite small, so it seems tolerable.

    Design doc reference:
    https://docs.google.com/document/d/1O4JPsoaxTQsX_7T5Fz4rsGeHMiM16jUrvDuq9FrtbNM

    Change-Id: Ic531698aaeb1578f943b7fdd346b9159ffd9b6c9
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6996467
    Reviewed-by: Dominik Inführ <[email protected]>
    Reviewed-by: Michael Lippautz <[email protected]>
    Commit-Queue: Dmitry Bezhetskov <[email protected]>
    Cr-Commit-Position: refs/heads/main@{#103296}

Refs: v8/v8@fe81545
Co-authored-by: Caio Lima <[email protected]>
@nodejs-github-bot
Copy link
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 Oct 27, 2025
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 27, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 27, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

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. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants