Commit 23c09ad4 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[ptr-compr, heap] Fix --huge_max_old_generation_size

This restores ~4GB limit for 64-bit devices with 16GB physical memory
running with pointer compression.

Bug: chromium:1049816,chromium:1045034
Change-Id: I7946a4510f8aac2c71fb427776574adba5127cbd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2043797
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66176}
parent 4300eec7
...@@ -280,18 +280,28 @@ size_t Heap::MinOldGenerationSize() { ...@@ -280,18 +280,28 @@ size_t Heap::MinOldGenerationSize() {
return paged_space_count * Page::kPageSize; return paged_space_count * Page::kPageSize;
} }
size_t Heap::AllocatorLimitOnMaxOldGenerationSize() {
#ifdef V8_COMPRESS_POINTERS
// Isolate and the young generation are also allocated on the heap.
return kPtrComprHeapReservationSize -
YoungGenerationSizeFromSemiSpaceSize(kMaxSemiSpaceSize) -
RoundUp(sizeof(Isolate), size_t{1} << kPageSizeBits);
#endif
return std::numeric_limits<size_t>::max();
}
size_t Heap::MaxOldGenerationSize(uint64_t physical_memory) { size_t Heap::MaxOldGenerationSize(uint64_t physical_memory) {
size_t max_size = V8HeapTrait::kMaxSize; size_t max_size = V8HeapTrait::kMaxSize;
// Finch experiment: Increase the heap size from 2GB to 4GB for 64-bit // Finch experiment: Increase the heap size from 2GB to 4GB for 64-bit
// systems with physical memory bigger than 16GB. The physical memory // systems with physical memory bigger than 16GB. The physical memory
// is rounded up to GB. // is rounded up to GB.
constexpr bool x64_bit = Heap::kPointerMultiplier >= 2; constexpr bool x64_bit = Heap::kHeapLimitMultiplier >= 2;
if (FLAG_huge_max_old_generation_size && x64_bit && if (FLAG_huge_max_old_generation_size && x64_bit &&
(physical_memory + 512 * MB) / GB >= 16) { (physical_memory + 512 * MB) / GB >= 16) {
DCHECK_EQ(max_size / GB, 2); DCHECK_EQ(max_size / GB, 2);
max_size *= 2; max_size *= 2;
} }
return max_size; return Min(max_size, AllocatorLimitOnMaxOldGenerationSize());
} }
size_t Heap::YoungGenerationSizeFromSemiSpaceSize(size_t semi_space_size) { size_t Heap::YoungGenerationSizeFromSemiSpaceSize(size_t semi_space_size) {
...@@ -3831,7 +3841,8 @@ bool Heap::InvokeNearHeapLimitCallback() { ...@@ -3831,7 +3841,8 @@ bool Heap::InvokeNearHeapLimitCallback() {
size_t heap_limit = callback(data, max_old_generation_size_, size_t heap_limit = callback(data, max_old_generation_size_,
initial_max_old_generation_size_); initial_max_old_generation_size_);
if (heap_limit > max_old_generation_size_) { if (heap_limit > max_old_generation_size_) {
max_old_generation_size_ = heap_limit; max_old_generation_size_ =
Min(heap_limit, AllocatorLimitOnMaxOldGenerationSize());
return true; return true;
} }
} }
...@@ -4565,6 +4576,8 @@ void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) { ...@@ -4565,6 +4576,8 @@ void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) {
} }
max_old_generation_size_ = max_old_generation_size_ =
Max(max_old_generation_size_, MinOldGenerationSize()); Max(max_old_generation_size_, MinOldGenerationSize());
max_old_generation_size_ =
Min(max_old_generation_size_, AllocatorLimitOnMaxOldGenerationSize());
max_old_generation_size_ = max_old_generation_size_ =
RoundDown<Page::kPageSize>(max_old_generation_size_); RoundDown<Page::kPageSize>(max_old_generation_size_);
......
...@@ -1105,6 +1105,9 @@ class Heap { ...@@ -1105,6 +1105,9 @@ class Heap {
size_t InitialSemiSpaceSize() { return initial_semispace_size_; } size_t InitialSemiSpaceSize() { return initial_semispace_size_; }
size_t MaxOldGenerationSize() { return max_old_generation_size_; } size_t MaxOldGenerationSize() { return max_old_generation_size_; }
// Limit on the max old generation size imposed by the underlying allocator.
V8_EXPORT_PRIVATE static size_t AllocatorLimitOnMaxOldGenerationSize();
V8_EXPORT_PRIVATE static size_t HeapSizeFromPhysicalMemory( V8_EXPORT_PRIVATE static size_t HeapSizeFromPhysicalMemory(
uint64_t physical_memory); uint64_t physical_memory);
V8_EXPORT_PRIVATE static void GenerationSizesFromHeapSize( V8_EXPORT_PRIVATE static void GenerationSizesFromHeapSize(
......
...@@ -6900,12 +6900,12 @@ UNINITIALIZED_TEST(HugeHeapLimit) { ...@@ -6900,12 +6900,12 @@ UNINITIALIZED_TEST(HugeHeapLimit) {
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
#ifdef V8_COMPRESS_POINTERS #ifdef V8_COMPRESS_POINTERS
// Fix this once the fix for crbug.com/1049816 lands. size_t kExpectedHeapLimit = Heap::AllocatorLimitOnMaxOldGenerationSize();
size_t kExpectedHeapLimit = size_t{2} * GB;
#else #else
size_t kExpectedHeapLimit = size_t{4} * GB; size_t kExpectedHeapLimit = size_t{4} * GB;
#endif #endif
CHECK_EQ(kExpectedHeapLimit, i_isolate->heap()->MaxOldGenerationSize()); CHECK_EQ(kExpectedHeapLimit, i_isolate->heap()->MaxOldGenerationSize());
CHECK_LT(size_t{3} * GB, i_isolate->heap()->MaxOldGenerationSize());
isolate->Dispose(); isolate->Dispose();
} }
#endif #endif
......
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