Commit 8732596c authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[ptr-compr, heap] Use system pointer size for heap limit computation

A pointer-compressed heap has the same heap limit heuristics as a 32-bit
heap. Specifically, the heap limit is restricted to 1GB due to scarce
virtual addresses space on 32-bit platforms. That limitation does not
apply for pointer-compressed heaps which can use 4GB.

This CL changes the heap limit computation to use system the pointer
size instead of the tagged pointer size. Note that the young generation
limit continues to use the tagged pointer size.

Bug: chromium:1045034
Change-Id: I9d5bb818c32a82322476e9c97feee331400ebe0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2042102Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66159}
parent 6cfba48b
...@@ -14,8 +14,8 @@ namespace v8 { ...@@ -14,8 +14,8 @@ namespace v8 {
namespace internal { namespace internal {
struct BaseControllerTrait { struct BaseControllerTrait {
static constexpr size_t kMinSize = 128u * Heap::kPointerMultiplier * MB; static constexpr size_t kMinSize = 128u * Heap::kHeapLimitMultiplier * MB;
static constexpr size_t kMaxSize = 1024u * Heap::kPointerMultiplier * MB; static constexpr size_t kMaxSize = 1024u * Heap::kHeapLimitMultiplier * MB;
static constexpr double kMinGrowingFactor = 1.1; static constexpr double kMinGrowingFactor = 1.1;
static constexpr double kMaxGrowingFactor = 4.0; static constexpr double kMaxGrowingFactor = 4.0;
......
...@@ -235,7 +235,7 @@ size_t Heap::HeapSizeFromPhysicalMemory(uint64_t physical_memory) { ...@@ -235,7 +235,7 @@ size_t Heap::HeapSizeFromPhysicalMemory(uint64_t physical_memory) {
// Compute the old generation size and cap it. // Compute the old generation size and cap it.
uint64_t old_generation = physical_memory / uint64_t old_generation = physical_memory /
kPhysicalMemoryToOldGenerationRatio * kPhysicalMemoryToOldGenerationRatio *
kPointerMultiplier; kHeapLimitMultiplier;
old_generation = old_generation =
Min<uint64_t>(old_generation, MaxOldGenerationSize(physical_memory)); Min<uint64_t>(old_generation, MaxOldGenerationSize(physical_memory));
old_generation = Max<uint64_t>(old_generation, V8HeapTrait::kMinSize); old_generation = Max<uint64_t>(old_generation, V8HeapTrait::kMinSize);
......
...@@ -263,19 +263,27 @@ class Heap { ...@@ -263,19 +263,27 @@ class Heap {
// Don't apply pointer multiplier on Android since it has no swap space and // Don't apply pointer multiplier on Android since it has no swap space and
// should instead adapt it's heap size based on available physical memory. // should instead adapt it's heap size based on available physical memory.
static const int kPointerMultiplier = 1; static const int kPointerMultiplier = 1;
static const int kHeapLimitMultiplier = 1;
#else #else
static const int kPointerMultiplier = i::kTaggedSize / 4; static const int kPointerMultiplier = kTaggedSize / 4;
// The heap limit needs to be computed based on the system pointer size
// because we want a pointer-compressed heap to have larger limit than
// an orinary 32-bit which that is contrained by 2GB virtual address space.
static const int kHeapLimitMultiplier = kSystemPointerSize / 4;
#endif #endif
static const size_t kMaxInitialOldGenerationSize = static const size_t kMaxInitialOldGenerationSize =
256 * MB * kPointerMultiplier; 256 * MB * kHeapLimitMultiplier;
// These constants control heap configuration based on the physical memory. // These constants control heap configuration based on the physical memory.
static constexpr size_t kPhysicalMemoryToOldGenerationRatio = 4; static constexpr size_t kPhysicalMemoryToOldGenerationRatio = 4;
static constexpr size_t kOldGenerationToSemiSpaceRatio = 128; // Young generation size is the same for compressed heaps and 32-bit heaps.
static constexpr size_t kOldGenerationToSemiSpaceRatioLowMemory = 256; static constexpr size_t kOldGenerationToSemiSpaceRatio =
128 * kHeapLimitMultiplier / kPointerMultiplier;
static constexpr size_t kOldGenerationToSemiSpaceRatioLowMemory =
256 * kHeapLimitMultiplier / kPointerMultiplier;
static constexpr size_t kOldGenerationLowMemory = static constexpr size_t kOldGenerationLowMemory =
128 * MB * kPointerMultiplier; 128 * MB * kHeapLimitMultiplier;
static constexpr size_t kNewLargeObjectSpaceToSemiSpaceRatio = 1; static constexpr size_t kNewLargeObjectSpaceToSemiSpaceRatio = 1;
static constexpr size_t kMinSemiSpaceSize = 512 * KB * kPointerMultiplier; static constexpr size_t kMinSemiSpaceSize = 512 * KB * kPointerMultiplier;
static constexpr size_t kMaxSemiSpaceSize = 8192 * KB * kPointerMultiplier; static constexpr size_t kMaxSemiSpaceSize = 8192 * KB * kPointerMultiplier;
......
...@@ -44,9 +44,10 @@ TEST(ResourceConstraints, ConfigureDefaults) { ...@@ -44,9 +44,10 @@ TEST(ResourceConstraints, ConfigureDefaults) {
const size_t KB = static_cast<size_t>(i::KB); const size_t KB = static_cast<size_t>(i::KB);
const size_t MB = static_cast<size_t>(i::MB); const size_t MB = static_cast<size_t>(i::MB);
const size_t pm = i::Heap::kPointerMultiplier; const size_t pm = i::Heap::kPointerMultiplier;
const size_t hlm = i::Heap::kHeapLimitMultiplier;
v8::ResourceConstraints constraints; v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(2048u * MB, 0u); constraints.ConfigureDefaults(2048u * MB, 0u);
ASSERT_EQ(512u * pm * MB, constraints.max_old_generation_size_in_bytes()); ASSERT_EQ(512u * hlm * MB, constraints.max_old_generation_size_in_bytes());
ASSERT_EQ(3 * 4096 * pm * KB, ASSERT_EQ(3 * 4096 * pm * KB,
constraints.max_young_generation_size_in_bytes()); constraints.max_young_generation_size_in_bytes());
ASSERT_EQ(0u, constraints.initial_old_generation_size_in_bytes()); ASSERT_EQ(0u, constraints.initial_old_generation_size_in_bytes());
......
...@@ -23,20 +23,23 @@ TEST(Heap, YoungGenerationSizeFromOldGenerationSize) { ...@@ -23,20 +23,23 @@ TEST(Heap, YoungGenerationSizeFromOldGenerationSize) {
const size_t MB = static_cast<size_t>(i::MB); const size_t MB = static_cast<size_t>(i::MB);
const size_t KB = static_cast<size_t>(i::KB); const size_t KB = static_cast<size_t>(i::KB);
const size_t pm = i::Heap::kPointerMultiplier; const size_t pm = i::Heap::kPointerMultiplier;
const size_t hlm = i::Heap::kHeapLimitMultiplier;
ASSERT_EQ(3 * 512u * pm * KB, ASSERT_EQ(3 * 512u * pm * KB,
i::Heap::YoungGenerationSizeFromOldGenerationSize(128u * pm * MB)); i::Heap::YoungGenerationSizeFromOldGenerationSize(128u * hlm * MB));
ASSERT_EQ(3 * 2048u * pm * KB, ASSERT_EQ(3 * 2048u * pm * KB,
i::Heap::YoungGenerationSizeFromOldGenerationSize(256u * pm * MB)); i::Heap::YoungGenerationSizeFromOldGenerationSize(256u * hlm * MB));
ASSERT_EQ(3 * 4096u * pm * KB, ASSERT_EQ(3 * 4096u * pm * KB,
i::Heap::YoungGenerationSizeFromOldGenerationSize(512u * pm * MB)); i::Heap::YoungGenerationSizeFromOldGenerationSize(512u * hlm * MB));
ASSERT_EQ(3 * 8192u * pm * KB, ASSERT_EQ(
i::Heap::YoungGenerationSizeFromOldGenerationSize(1024u * pm * MB)); 3 * 8192u * pm * KB,
i::Heap::YoungGenerationSizeFromOldGenerationSize(1024u * hlm * MB));
} }
TEST(Heap, GenerationSizesFromHeapSize) { TEST(Heap, GenerationSizesFromHeapSize) {
const size_t MB = static_cast<size_t>(i::MB); const size_t MB = static_cast<size_t>(i::MB);
const size_t KB = static_cast<size_t>(i::KB); const size_t KB = static_cast<size_t>(i::KB);
const size_t pm = i::Heap::kPointerMultiplier; const size_t pm = i::Heap::kPointerMultiplier;
const size_t hlm = i::Heap::kHeapLimitMultiplier;
size_t old, young; size_t old, young;
i::Heap::GenerationSizesFromHeapSize(1 * KB, &young, &old); i::Heap::GenerationSizesFromHeapSize(1 * KB, &young, &old);
...@@ -48,45 +51,46 @@ TEST(Heap, GenerationSizesFromHeapSize) { ...@@ -48,45 +51,46 @@ TEST(Heap, GenerationSizesFromHeapSize) {
ASSERT_EQ(1 * KB, old); ASSERT_EQ(1 * KB, old);
ASSERT_EQ(3 * 512u * pm * KB, young); ASSERT_EQ(3 * 512u * pm * KB, young);
i::Heap::GenerationSizesFromHeapSize(128 * pm * MB + 3 * 512 * pm * KB, i::Heap::GenerationSizesFromHeapSize(128 * hlm * MB + 3 * 512 * pm * KB,
&young, &old); &young, &old);
ASSERT_EQ(128u * pm * MB, old); ASSERT_EQ(128u * hlm * MB, old);
ASSERT_EQ(3 * 512u * pm * KB, young); ASSERT_EQ(3 * 512u * pm * KB, young);
i::Heap::GenerationSizesFromHeapSize(256u * pm * MB + 3 * 2048 * pm * KB, i::Heap::GenerationSizesFromHeapSize(256u * hlm * MB + 3 * 2048 * pm * KB,
&young, &old); &young, &old);
ASSERT_EQ(256u * pm * MB, old); ASSERT_EQ(256u * hlm * MB, old);
ASSERT_EQ(3 * 2048u * pm * KB, young); ASSERT_EQ(3 * 2048u * pm * KB, young);
i::Heap::GenerationSizesFromHeapSize(512u * pm * MB + 3 * 4096 * pm * KB, i::Heap::GenerationSizesFromHeapSize(512u * hlm * MB + 3 * 4096 * pm * KB,
&young, &old); &young, &old);
ASSERT_EQ(512u * pm * MB, old); ASSERT_EQ(512u * hlm * MB, old);
ASSERT_EQ(3 * 4096u * pm * KB, young); ASSERT_EQ(3 * 4096u * pm * KB, young);
i::Heap::GenerationSizesFromHeapSize(1024u * pm * MB + 3 * 8192 * pm * KB, i::Heap::GenerationSizesFromHeapSize(1024u * hlm * MB + 3 * 8192 * pm * KB,
&young, &old); &young, &old);
ASSERT_EQ(1024u * pm * MB, old); ASSERT_EQ(1024u * hlm * MB, old);
ASSERT_EQ(3 * 8192u * pm * KB, young); ASSERT_EQ(3 * 8192u * pm * KB, young);
} }
TEST(Heap, HeapSizeFromPhysicalMemory) { TEST(Heap, HeapSizeFromPhysicalMemory) {
const size_t MB = static_cast<size_t>(i::MB); const size_t MB = static_cast<size_t>(i::MB);
const size_t pm = i::Heap::kPointerMultiplier; const size_t pm = i::Heap::kPointerMultiplier;
const size_t hlm = i::Heap::kHeapLimitMultiplier;
// The expected value is old_generation_size + 3 * semi_space_size. // The expected value is old_generation_size + 3 * semi_space_size.
ASSERT_EQ(128 * pm * MB + 3 * 512 * pm * KB, ASSERT_EQ(128 * hlm * MB + 3 * 512 * pm * KB,
i::Heap::HeapSizeFromPhysicalMemory(0u)); i::Heap::HeapSizeFromPhysicalMemory(0u));
ASSERT_EQ(128 * pm * MB + 3 * 512 * pm * KB, ASSERT_EQ(128 * hlm * MB + 3 * 512 * pm * KB,
i::Heap::HeapSizeFromPhysicalMemory(512u * MB)); i::Heap::HeapSizeFromPhysicalMemory(512u * MB));
ASSERT_EQ(256 * pm * MB + 3 * 2048 * pm * KB, ASSERT_EQ(256 * hlm * MB + 3 * 2048 * pm * KB,
i::Heap::HeapSizeFromPhysicalMemory(1024u * MB)); i::Heap::HeapSizeFromPhysicalMemory(1024u * MB));
ASSERT_EQ(512 * pm * MB + 3 * 4096 * pm * KB, ASSERT_EQ(512 * hlm * MB + 3 * 4096 * pm * KB,
i::Heap::HeapSizeFromPhysicalMemory(2048u * MB)); i::Heap::HeapSizeFromPhysicalMemory(2048u * MB));
ASSERT_EQ( ASSERT_EQ(
1024 * pm * MB + 3 * 8192 * pm * KB, 1024 * hlm * MB + 3 * 8192 * pm * KB,
i::Heap::HeapSizeFromPhysicalMemory(static_cast<uint64_t>(4096u) * MB)); i::Heap::HeapSizeFromPhysicalMemory(static_cast<uint64_t>(4096u) * MB));
ASSERT_EQ( ASSERT_EQ(
1024 * pm * MB + 3 * 8192 * pm * KB, 1024 * hlm * MB + 3 * 8192 * pm * KB,
i::Heap::HeapSizeFromPhysicalMemory(static_cast<uint64_t>(8192u) * MB)); i::Heap::HeapSizeFromPhysicalMemory(static_cast<uint64_t>(8192u) * MB));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment