Revision: 20837
Author: [email protected]
Date: Thu Apr 17 11:27:45 2014 UTC
Log: Grow old generation slower on low-memory devices.
BUG=
[email protected], [email protected]
Review URL: https://codereview.chromium.org/236063015
http://code.google.com/p/v8/source/detail?r=20837
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/test/cctest/test-api.cc
/branches/bleeding_edge/test/cctest/test-strings.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Tue Apr 15 07:47:33 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Thu Apr 17 11:27:45 2014 UTC
@@ -3894,8 +3894,8 @@
uint64_t virtual_memory_limit,
uint32_t number_of_processors);
- int max_young_space_size() const { return max_young_space_size_; }
- void set_max_young_space_size(int value) { max_young_space_size_ =
value; }
+ int max_new_space_size() const { return max_new_space_size_; }
+ void set_max_new_space_size(int value) { max_new_space_size_ = value; }
int max_old_space_size() const { return max_old_space_size_; }
void set_max_old_space_size(int value) { max_old_space_size_ = value; }
int max_executable_size() const { return max_executable_size_; }
@@ -3914,7 +3914,7 @@
}
private:
- int max_young_space_size_;
+ int max_new_space_size_;
int max_old_space_size_;
int max_executable_size_;
uint32_t* stack_limit_;
=======================================
--- /branches/bleeding_edge/src/api.cc Thu Apr 17 08:33:18 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Thu Apr 17 11:27:45 2014 UTC
@@ -442,7 +442,7 @@
ResourceConstraints::ResourceConstraints()
- : max_young_space_size_(0),
+ : max_new_space_size_(0),
max_old_space_size_(0),
max_executable_size_(0),
stack_limit_(NULL),
@@ -452,7 +452,6 @@
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit,
uint32_t number_of_processors)
{
- const int lump_of_memory = (i::kPointerSize / 4) * i::MB;
#if V8_OS_ANDROID
// Android has higher physical memory requirements before raising the
maximum
// heap size limits since it has no swap space.
@@ -465,24 +464,22 @@
const uint64_t high_limit = 1ul * i::GB;
#endif
- // The young_space_size should be a power of 2 and old_generation_size
should
- // be a multiple of Page::kPageSize.
if (physical_memory <= low_limit) {
- set_max_young_space_size(2 * lump_of_memory);
- set_max_old_space_size(128 * lump_of_memory);
- set_max_executable_size(96 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeLowMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice);
} else if (physical_memory <= medium_limit) {
- set_max_young_space_size(8 * lump_of_memory);
- set_max_old_space_size(256 * lump_of_memory);
- set_max_executable_size(192 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeMediumMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice);
} else if (physical_memory <= high_limit) {
- set_max_young_space_size(16 * lump_of_memory);
- set_max_old_space_size(512 * lump_of_memory);
- set_max_executable_size(256 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHighMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice);
} else {
- set_max_young_space_size(16 * lump_of_memory);
- set_max_old_space_size(700 * lump_of_memory);
- set_max_executable_size(256 * lump_of_memory);
+ set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHugeMemoryDevice);
+ set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice);
+ set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice);
}
set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
@@ -499,15 +496,15 @@
bool SetResourceConstraints(Isolate* v8_isolate,
ResourceConstraints* constraints) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
- int young_space_size = constraints->max_young_space_size();
+ int new_space_size = constraints->max_new_space_size();
int old_gen_size = constraints->max_old_space_size();
int max_executable_size = constraints->max_executable_size();
int code_range_size = constraints->code_range_size();
- if (young_space_size != 0 || old_gen_size != 0 || max_executable_size !=
0 ||
+ if (new_space_size != 0 || old_gen_size != 0 || max_executable_size != 0
||
code_range_size != 0) {
// After initialization it's too late to change Heap constraints.
ASSERT(!isolate->IsInitialized());
- bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
+ bool result = isolate->heap()->ConfigureHeap(new_space_size / 2,
old_gen_size,
max_executable_size,
code_range_size);
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Apr 16 14:15:32 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Thu Apr 17 11:27:45 2014 UTC
@@ -81,6 +81,7 @@
// Will be 4 * reserved_semispace_size_ to ensure that young
// generation can be aligned to its size.
maximum_committed_(0),
+ old_space_growing_factor_(4),
survived_since_last_expansion_(0),
sweep_generation_(0),
always_allocate_scope_depth_(0),
@@ -5308,6 +5309,12 @@
AllocationMemento::kSize));
code_range_size_ = code_range_size;
+
+ // We set the old generation growing factor to 2 to grow the heap slower
on
+ // memory-constrained devices.
+ if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice) {
+ old_space_growing_factor_ = 2;
+ }
configured_ = true;
return true;
=======================================
--- /branches/bleeding_edge/src/heap.h Wed Apr 16 18:28:03 2014 UTC
+++ /branches/bleeding_edge/src/heap.h Thu Apr 17 11:27:45 2014 UTC
@@ -1381,9 +1381,30 @@
static const intptr_t kMinimumOldGenerationAllocationLimit =
8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
+ static const int kLumpOfMemory = (i::kPointerSize / 4) * i::MB;
+
+ // The new space size has to be a power of 2.
+ static const int kMaxNewSpaceSizeLowMemoryDevice = 2 * kLumpOfMemory;
+ static const int kMaxNewSpaceSizeMediumMemoryDevice = 8 * kLumpOfMemory;
+ static const int kMaxNewSpaceSizeHighMemoryDevice = 16 * kLumpOfMemory;
+ static const int kMaxNewSpaceSizeHugeMemoryDevice = 16 * kLumpOfMemory;
+
+ // The old space size has to be a multiple of Page::kPageSize.
+ static const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kLumpOfMemory;
+ static const int kMaxOldSpaceSizeMediumMemoryDevice = 256 *
kLumpOfMemory;
+ static const int kMaxOldSpaceSizeHighMemoryDevice = 512 * kLumpOfMemory;
+ static const int kMaxOldSpaceSizeHugeMemoryDevice = 700 * kLumpOfMemory;
+
+ // The executable size has to be a multiple of Page::kPageSize.
+ static const int kMaxExecutableSizeLowMemoryDevice = 128 * kLumpOfMemory;
+ static const int kMaxExecutableSizeMediumMemoryDevice = 256 *
kLumpOfMemory;
+ static const int kMaxExecutableSizeHighMemoryDevice = 512 *
kLumpOfMemory;
+ static const int kMaxExecutableSizeHugeMemoryDevice = 700 *
kLumpOfMemory;
+
intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) {
- intptr_t limit = FLAG_stress_compaction ?
- old_gen_size + old_gen_size / 10 : old_gen_size * 4;
+ intptr_t limit = FLAG_stress_compaction
+ ? old_gen_size + old_gen_size / 10
+ : old_gen_size * old_space_growing_factor_;
limit = Max(limit, kMinimumOldGenerationAllocationLimit);
limit += new_space_.Capacity();
intptr_t halfway_to_the_max = (old_gen_size +
max_old_generation_size_) / 2;
@@ -1744,6 +1765,11 @@
intptr_t max_executable_size_;
intptr_t maximum_committed_;
+ // The old space growing factor is used in the old space heap growing
+ // strategy. The new old space size is the current old space size times
+ // old_space_growing_factor_.
+ int old_space_growing_factor_;
+
// For keeping track of how much data has survived
// scavenge since last new space expansion.
int survived_since_last_expansion_;
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon Apr 14 14:03:20
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Thu Apr 17 11:27:45
2014 UTC
@@ -19523,7 +19523,7 @@
case SetResourceConstraints: {
static const int K = 1024;
v8::ResourceConstraints constraints;
- constraints.set_max_young_space_size(256 * K);
+ constraints.set_max_new_space_size(256 * K);
constraints.set_max_old_space_size(4 * K * K);
v8::SetResourceConstraints(CcTest::isolate(), &constraints);
break;
=======================================
--- /branches/bleeding_edge/test/cctest/test-strings.cc Wed Apr 16 07:26:34
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-strings.cc Thu Apr 17 11:27:45
2014 UTC
@@ -1212,7 +1212,7 @@
// Set heap limits.
static const int K = 1024;
v8::ResourceConstraints constraints;
- constraints.set_max_young_space_size(256 * K);
+ constraints.set_max_new_space_size(256 * K);
constraints.set_max_old_space_size(4 * K * K);
v8::SetResourceConstraints(CcTest::isolate(), &constraints);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.