Skip to content

[v26.x] deps: V8: backport 2444c109f4f8 - #66736

Open
acburdine wants to merge 1 commit into
nodejs:v26.x-stagingfrom
acburdine:backport-v8-2444c109f4f8-to-v26.x
Open

acburdine wants to merge 1 commit into
nodejs:v26.x-stagingfrom
acburdine:backport-v8-2444c109f4f8-to-v26.x

Conversation

@acburdine

Copy link
Copy Markdown

Backports v8/v8@2444c10 (https://chromium-review.googlesource.com/c/v8/v8/+/8521518, crbug https://issues.chromium.org/issues/570738027) to v26.x, as suggested in #66692 instead of floating it on main.

Fixes: #66564

Since V8's allocation throughput moved to SmoothedBytesAndDuration, a throughput of exactly 0 made ComputeMutatorUtilizationImpl() report "maximal allocation". Node never allocates on the CppHeap unless node:vm is used, so Heap::HasLowAllocationRate() was never true and the MemoryReducer could only start a GC through its 100 s watchdog. Upstream removed the zero special case, so 0 now counts as the lowest allocation rate.

Changes from the upstream commit:

  • heap.cc, heap.h, gc-tracer.h: applied unchanged.
  • deps/v8/AUTHORS: same line, merged by hand (context drift).
  • test/unittests/heap/gc-tracer-unittest.cc: GCTracer::SampleAllocation() takes 4 counters on V8 14.6 (no external-memory counter), so the two new tests drop that argument; one comment no longer mentions external memory.
  • v8_embedder_string bumped to -node.40.

Verification:

  • make -j8 test on macOS arm64: all pass (3 CA/TLS tests needed NODE_USE_SYSTEM_CA unset in my shell, unrelated to this change).
  • In a linux/amd64 container (V8 14.6's standalone toolchain doesn't build against the current macOS SDK): built deps/v8 and ran unittests/GCTracerTest.* and unittests/MemoryReducer.* (23/23 pass). With the heap.cc change reverted, GCTracerTest.LowAllocationRateWithZeroEmbedderAllocation fails (HasLowAllocationRate() is false); with it, both new tests pass.
  • Same container, the make test-v8 suites (mjsunit, cctest, debugger, inspector, message, preparser): 14,996/14,999 pass. The 3 failures (regress-crbug-1041232, -1104608, -1209152) use --multi-mapped-mock-allocator, whose mremap with old size 0 isn't supported by the x86 emulation the container ran under.

Repro and traces: https://github.com/acburdine/node-memory-reducer-repro. On v24.21.0, time from the end of an allocation burst to the first memory-reducer GC was 100 s / 100 s / 141 s vs 11 s with an earlier, embedder-only version of this fix.

Disclaimer

The investigation, the upstream CL and this backport were prepared with help from an AI coding assistant. The fix was reviewed and approved upstream by the V8 heap team; I reviewed the backport diff, and the verification above was run locally on this branch.

Original commit message:

    [heap] Treat zero allocation throughput as a low allocation rate

    Since https://crrev.com/c/5935313 allocation throughput is tracked with
    SmoothedBytesAndDuration, which has no lower bound. A sampled throughput
    of exactly 0 -- nothing was allocated, or the smoothed value decayed to
    0 after a long idle period -- made ComputeMutatorUtilizationImpl()
    return a mutator utilization of 0 ("maximal allocation"). For an isolate
    that never allocates on the CppHeap, HasLowAllocationRate() is then
    never true and the MemoryReducer cannot start a GC through its
    low-allocation condition; only the 100s watchdog can. Node.js hits this
    for any process that does not use node:vm.

    Remove the special case. A mutator speed of 0 now yields a mutator
    utilization of 1, i.e. the lowest possible allocation rate. gc_speed is
    either the conservative default or at least 1 byte/ms, so the formula
    stays well defined.

    Bug: 570738027
    Change-Id: I84cd51607df3c31c2f1e02bb2fe258e5506131ce
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8521518
    Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
    Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
    Reviewed-by: Omer Katz <omerkatz@chromium.org>
    Commit-Queue: Omer Katz <omerkatz@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#110599}

Refs: v8/v8@2444c10
Fixes: nodejs#66564
Signed-off-by: Austin Burdine <austin@ghost.org>
@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 Node.js builds or CI infrastructure. needs-ci PRs that need a full CI run. v26.x Issues that can be reproduced on v26.x or PRs targeting the v26.x-staging branch. v8 engine Issues and PRs related to the V8 dependency. labels Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

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 Node.js builds or CI infrastructure. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. v26.x Issues that can be reproduced on v26.x or PRs targeting the v26.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants