[heap] Simplify GenerationSizesFromHeapSize [v8/v8 : main]

0 views
Skip to first unread message

Dominik Inführ (Gerrit)

unread,
Nov 6, 2025, 10:08:58 AM (4 days ago) Nov 6
to Etienne Pierre-Doray, Code Review Nudger, V8 LUCI CQ, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com
Attention needed from Etienne Pierre-Doray

Dominik Inführ added 2 comments

File src/heap/heap.h
Line 1400, Patchset 36: uint64_t physical_memory, size_t heap_size);
Dominik Inführ . unresolved

Would it be better to keep size_t here for heap size? I guess it would make sense that one can't use a heap size larger than the address space?

File test/unittests/heap/heap-unittest.cc
Line 60, Patchset 43 (Latest): uint64_t heap_size;
Dominik Inführ . unresolved

Now that we don't test 4GB and 8GB on 32-bit: can we make them size_t?

Open in Gerrit

Related details

Attention is currently required from:
  • Etienne Pierre-Doray
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
Gerrit-Change-Number: 7079327
Gerrit-PatchSet: 43
Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-Attention: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Comment-Date: Thu, 06 Nov 2025 15:08:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Etienne Pierre-Doray (Gerrit)

unread,
Nov 7, 2025, 8:31:46 AM (3 days ago) Nov 7
to Dominik Inführ, Code Review Nudger, V8 LUCI CQ, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com
Attention needed from Dominik Inführ

Etienne Pierre-Doray added 3 comments

Patchset-level comments
File-level comment, Patchset 44 (Latest):
Etienne Pierre-Doray . resolved

PTAnL?

File src/heap/heap.h
Line 1400, Patchset 36: uint64_t physical_memory, size_t heap_size);
Dominik Inführ . unresolved

Would it be better to keep size_t here for heap size? I guess it would make sense that one can't use a heap size larger than the address space?

Etienne Pierre-Doray

This was needed for ExpectedDefaultGenerationLimitsForPhysicalMemory.
I think physical_memory can be bigger than 4Gb on 32bit devices, then we need to make sure `physical_memory / kPhysicalMemoryToOldGenerationRatio` doesn't overflow.
At the end this is capped by DefaultMaxSemiSpaceSize, but if YoungGenerationSizeFromHeapSize takes a size_t, then I need to cap before the conversion (I feel like that's a bit more complicated).

File test/unittests/heap/heap-unittest.cc
Line 60, Patchset 43: uint64_t heap_size;
Dominik Inführ . resolved

Now that we don't test 4GB and 8GB on 32-bit: can we make them size_t?

Etienne Pierre-Doray

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Dominik Inführ
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
Gerrit-Change-Number: 7079327
Gerrit-PatchSet: 44
Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
Gerrit-Comment-Date: Fri, 07 Nov 2025 13:31:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Dominik Inführ <dinf...@chromium.org>
unsatisfied_requirement
open
diffy

Dominik Inführ (Gerrit)

unread,
3:32 AM (16 hours ago) 3:32 AM
to Etienne Pierre-Doray, Code Review Nudger, V8 LUCI CQ, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com
Attention needed from Etienne Pierre-Doray

Dominik Inführ added 1 comment

File src/heap/heap.h
Line 1400, Patchset 36: uint64_t physical_memory, size_t heap_size);
Dominik Inführ . unresolved

Would it be better to keep size_t here for heap size? I guess it would make sense that one can't use a heap size larger than the address space?

Etienne Pierre-Doray

This was needed for ExpectedDefaultGenerationLimitsForPhysicalMemory.
I think physical_memory can be bigger than 4Gb on 32bit devices, then we need to make sure `physical_memory / kPhysicalMemoryToOldGenerationRatio` doesn't overflow.
At the end this is capped by DefaultMaxSemiSpaceSize, but if YoungGenerationSizeFromHeapSize takes a size_t, then I need to cap before the conversion (I feel like that's a bit more complicated).

Dominik Inführ

So when looking at the two ConfigureDefaults methods we have on the API level, we use uint64_t for the physical/virtual memory but then size_t for the heap limits. I think this convention makes sense and we generally stick to these types also internally.

`physical_memory / kPhysicalMemoryToOldGenerationRatio` is certainly a good point though! Since we have to choose one evil here, I would rather have heap_size as size_t to be consistent. Just to see whether this makes sense, I have tested this change on your CL to not postpone landing your CL further.. see [0]. Capping that value is just one line and it keeps the complexity local to `YoungGenerationSizeFromPhysicalMemory`.

0: https://chromium-review.googlesource.com/c/v8/v8/+/7133541

Open in Gerrit

Related details

Attention is currently required from:
  • Etienne Pierre-Doray
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
Gerrit-Change-Number: 7079327
Gerrit-PatchSet: 45
Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-Attention: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Comment-Date: Mon, 10 Nov 2025 08:32:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Etienne Pierre-Doray <etie...@chromium.org>
Comment-In-Reply-To: Dominik Inführ <dinf...@chromium.org>
unsatisfied_requirement
open
diffy

Etienne Pierre-Doray (Gerrit)

unread,
10:33 AM (9 hours ago) 10:33 AM
to Dominik Inführ, Code Review Nudger, V8 LUCI CQ, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com
Attention needed from Dominik Inführ

Etienne Pierre-Doray added 2 comments

Etienne Pierre-Doray . resolved

PTAnL?

File src/heap/heap.h
Line 1400, Patchset 36: uint64_t physical_memory, size_t heap_size);
Dominik Inführ . resolved

Would it be better to keep size_t here for heap size? I guess it would make sense that one can't use a heap size larger than the address space?

Etienne Pierre-Doray

This was needed for ExpectedDefaultGenerationLimitsForPhysicalMemory.
I think physical_memory can be bigger than 4Gb on 32bit devices, then we need to make sure `physical_memory / kPhysicalMemoryToOldGenerationRatio` doesn't overflow.
At the end this is capped by DefaultMaxSemiSpaceSize, but if YoungGenerationSizeFromHeapSize takes a size_t, then I need to cap before the conversion (I feel like that's a bit more complicated).

Dominik Inführ

So when looking at the two ConfigureDefaults methods we have on the API level, we use uint64_t for the physical/virtual memory but then size_t for the heap limits. I think this convention makes sense and we generally stick to these types also internally.

`physical_memory / kPhysicalMemoryToOldGenerationRatio` is certainly a good point though! Since we have to choose one evil here, I would rather have heap_size as size_t to be consistent. Just to see whether this makes sense, I have tested this change on your CL to not postpone landing your CL further.. see [0]. Capping that value is just one line and it keeps the complexity local to `YoungGenerationSizeFromPhysicalMemory`.

0: https://chromium-review.googlesource.com/c/v8/v8/+/7133541

Etienne Pierre-Doray

Done with saturated_cast()

Open in Gerrit

Related details

Attention is currently required from:
  • Dominik Inführ
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
    Gerrit-Change-Number: 7079327
    Gerrit-PatchSet: 46
    Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Attention: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Comment-Date: Mon, 10 Nov 2025 15:33:22 +0000
    unsatisfied_requirement
    open
    diffy

    Dominik Inführ (Gerrit)

    unread,
    10:39 AM (9 hours ago) 10:39 AM
    to Etienne Pierre-Doray, Code Review Nudger, V8 LUCI CQ, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com
    Attention needed from Etienne Pierre-Doray

    Dominik Inführ voted and added 1 comment

    Votes added by Dominik Inführ

    Code-Review+1

    1 comment

    Patchset-level comments
    Dominik Inführ . resolved

    Very cool, thanks a lot! LGTM

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Etienne Pierre-Doray
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
    Gerrit-Change-Number: 7079327
    Gerrit-PatchSet: 46
    Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Attention: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Comment-Date: Mon, 10 Nov 2025 15:38:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Etienne Pierre-Doray (Gerrit)

    unread,
    12:17 PM (8 hours ago) 12:17 PM
    to Dominik Inführ, Code Review Nudger, V8 LUCI CQ, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com

    Etienne Pierre-Doray voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
    Gerrit-Change-Number: 7079327
    Gerrit-PatchSet: 46
    Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Hannes Payer <hpa...@chromium.org>
    Gerrit-Comment-Date: Mon, 10 Nov 2025 17:17:48 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    V8 LUCI CQ (Gerrit)

    unread,
    1:10 PM (7 hours ago) 1:10 PM
    to Etienne Pierre-Doray, Dominik Inführ, Code Review Nudger, AyeAye, Hannes Payer, jgrube...@chromium.org, v8-mip...@googlegroups.com, dmercadi...@chromium.org, leszek...@chromium.org, victorgo...@chromium.org, was...@google.com, v8-ppc...@googlegroups.com, pthier...@chromium.org, oilpan-r...@chromium.org, verwaes...@chromium.org, cbruni...@chromium.org, devtools-...@chromium.org, v8-risc...@chromium.org, marja...@chromium.org, v8-flag...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com

    V8 LUCI CQ submitted the change

    Change information

    Commit message:
    [heap] Simplify GenerationSizesFromHeapSize

    This CL simplifies GenerationSizesFromHeapSize by using
    YoungGenerationSizeFromHeapSize, directly on heap size instead of old generation.
    This yields very similar young/old generation sizes, but
    avoids binary searching and gives cleaner young/old gen sizes.

    This doesn't affect YoungGenerationSizeFromPhysicalMemory which is what we use in production
    Bug: chromium:454097973
    Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
    Reviewed-by: Dominik Inführ <dinf...@chromium.org>
    Commit-Queue: Etienne Pierre-Doray <etie...@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#103635}
    Files:
    • M src/heap/heap.cc
    • M src/heap/heap.h
    • M test/unittests/api/resource-constraints-unittest.cc
    • M test/unittests/heap/heap-unittest.cc
    Change size: M
    Delta: 4 files changed, 35 insertions(+), 50 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Dominik Inführ
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia7b7bc364c07cd6a7a96586be9137375703f3f9b
    Gerrit-Change-Number: 7079327
    Gerrit-PatchSet: 47
    Gerrit-Owner: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Reviewer: Dominik Inführ <dinf...@chromium.org>
    Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages