Reviewers: Hannes Payer,
Description:
Introduce an option to do regular new space growing for a while
After a given number of scavenges, we switch to growing to the target
size instead
BUG=none
[email protected]
LOG=n
Please review this at https://codereview.chromium.org/734363002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+28, -2 lines):
M src/flag-definitions.h
M src/heap/heap.h
M src/heap/heap.cc
M src/heap/spaces.h
M src/heap/spaces.cc
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
df24ea2a9ea1c3658730ed276cf6a1696d7760d7..a1722a70fb6f2a46b6afe45d017a78e4261c3246
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -533,6 +533,9 @@ DEFINE_INT(max_old_space_size, 0, "max size of the old
space (in Mbytes)")
DEFINE_INT(max_executable_size, 0, "max size of executable memory (in
Mbytes)")
DEFINE_BOOL(gc_global, false, "always perform global GCs")
DEFINE_INT(gc_interval, -1, "garbage collect after <n> allocations")
+DEFINE_INT(scavenges_before_grow, -1,
+ "Number of scavenges after which to change the allocation
strategy "
+ "to growing to the target size.")
DEFINE_BOOL(trace_gc, false,
"print one trace line following each garbage collection")
DEFINE_BOOL(trace_gc_nvp, false,
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
9785be0b91d59785a5b38a6da7ac38006ed8bfa2..8c76cfb8d1f1f21a6bfaea0e07c0d29845aac678
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -62,6 +62,7 @@ Heap::Heap()
max_semi_space_size_(8 * (kPointerSize / 4) * MB),
initial_semispace_size_(Page::kPageSize),
target_semispace_size_(Page::kPageSize),
+ scavenges_before_grow_(0),
max_old_generation_size_(700ul * (kPointerSize / 4) * MB),
max_executable_size_(256ul * (kPointerSize / 4) * MB),
// Variables set based on semispace_size_ and old_generation_size_ in
@@ -1570,6 +1571,12 @@ void Heap::Scavenge() {
IncrementYoungSurvivorsCounter(static_cast<int>(
(PromotedSpaceSizeOfObjects() - survived_watermark) +
new_space_.Size()));
+ if (scavenges_before_grow_ > 0) {
+ if (--scavenges_before_grow_ == 0) {
+ new_space()->set_grow_to_target_capacity(true);
+ }
+ }
+
LOG(isolate_, ResourceEvent("scavenge", "end"));
gc_state_ = NOT_IN_GC;
@@ -5059,6 +5066,8 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int
max_old_space_size,
target_semispace_size_ = Max(initial_semispace_size_,
target_semispace_size_);
+ scavenges_before_grow_ = Max(FLAG_scavenges_before_grow, 0);
+
// The old generation is paged and needs at least one page for each
space.
int paged_space_count = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1;
max_old_generation_size_ =
@@ -5241,6 +5250,9 @@ bool Heap::SetUp() {
return false;
}
new_space_top_after_last_gc_ = new_space()->top();
+ if (scavenges_before_grow_ <= 0) {
+ new_space()->set_grow_to_target_capacity(true);
+ }
// Initialize old pointer space.
old_pointer_space_ = new OldSpace(this, max_old_generation_size_,
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
eeb83228610870b1aed5d041ebf2171b65615a5d..f0cbc347ae54340149b845eaaaa56b88e93b2beb
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1498,6 +1498,7 @@ class Heap {
int max_semi_space_size_;
int initial_semispace_size_;
int target_semispace_size_;
+ int scavenges_before_grow_;
intptr_t max_old_generation_size_;
intptr_t max_executable_size_;
intptr_t maximum_committed_;
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index
30b141fcd32965637bd6ed1a2cc29284dff33750..ea6d662fa0706ee09a9199e354f24c89c2b2c11e
100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1398,7 +1398,8 @@ bool NewSpace::AddFreshPage() {
if (!to_space_.AdvancePage()) {
// Check if we reached the target capacity yet. If not, try to commit
a page
// and continue.
- if ((to_space_.TotalCapacity() < to_space_.TargetCapacity()) &&
+ if (grow_to_target_capacity_ &&
+ (to_space_.TotalCapacity() < to_space_.TargetCapacity()) &&
GrowOnePage()) {
if (!to_space_.AdvancePage()) {
// It doesn't make sense that we managed to commit a page, but
can't use
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index
ef294b243948b3cd4bbdc5101385baf295cb8a73..ee4116a2ee79f825cbb8ef5e2a742ed484e33e0c
100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -2339,7 +2339,8 @@ class NewSpace : public Space {
to_space_(heap, kToSpace),
from_space_(heap, kFromSpace),
reservation_(),
- inline_allocation_limit_step_(0) {}
+ inline_allocation_limit_step_(0),
+ grow_to_target_capacity_(false) {}
// Sets up the new space using the given chunk.
bool SetUp(int reserved_semispace_size_, int max_semi_space_size);
@@ -2569,6 +2570,10 @@ class NewSpace : public Space {
SemiSpace* active_space() { return &to_space_; }
+ void set_grow_to_target_capacity(bool grow_to_target_capacity) {
+ grow_to_target_capacity_ = grow_to_target_capacity;
+ }
+
private:
// Update allocation info to match the current to-space page.
void UpdateAllocationInfo();
@@ -2600,6 +2605,10 @@ class NewSpace : public Space {
Address top_on_previous_step_;
+ // True if the new space should be expanded up to the target capacity
+ // when the current page is full.
+ bool grow_to_target_capacity_;
+
HistogramInfo* allocated_histogram_;
HistogramInfo* promoted_histogram_;
--
--
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.