Grow heap slowly after running memory reducer.

BUG=

Review URL: https://codereview.chromium.org/1261373006

Cr-Commit-Position: refs/heads/master@{#29987}
This commit is contained in:
ulan 2015-08-03 11:45:41 -07:00 committed by Commit bot
parent 869ab06ea5
commit d8ad147944
4 changed files with 14 additions and 9 deletions

View File

@ -5581,7 +5581,7 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
double mutator_speed, double mutator_speed,
int freed_global_handles) { int freed_global_handles) {
const int kFreedGlobalHandlesThreshold = 700; const int kFreedGlobalHandlesThreshold = 700;
const double kMaxHeapGrowingFactorForManyFreedGlobalHandles = 1.3; const double kConservativeHeapGrowingFactor = 1.3;
double factor = HeapGrowingFactor(gc_speed, mutator_speed); double factor = HeapGrowingFactor(gc_speed, mutator_speed);
@ -5600,8 +5600,9 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained);
} }
if (freed_global_handles >= kFreedGlobalHandlesThreshold) { if (freed_global_handles >= kFreedGlobalHandlesThreshold ||
factor = Min(factor, kMaxHeapGrowingFactorForManyFreedGlobalHandles); memory_reducer_.ShouldGrowHeapSlowly()) {
factor = Min(factor, kConservativeHeapGrowingFactor);
} }
if (FLAG_stress_compaction || if (FLAG_stress_compaction ||

View File

@ -135,7 +135,7 @@ MemoryReducer::State MemoryReducer::Step(const State& state,
return state; return state;
case kTimer: case kTimer:
if (state.started_gcs >= kMaxNumberOfGCs) { if (state.started_gcs >= kMaxNumberOfGCs) {
return State(kDone, 0, 0.0, state.last_gc_time_ms); return State(kDone, kMaxNumberOfGCs, 0.0, state.last_gc_time_ms);
} else if (event.can_start_incremental_gc && } else if (event.can_start_incremental_gc &&
(event.low_allocation_rate || WatchdogGC(state, event))) { (event.low_allocation_rate || WatchdogGC(state, event))) {
if (state.next_gc_start_ms <= event.time_ms) { if (state.next_gc_start_ms <= event.time_ms) {
@ -169,7 +169,7 @@ MemoryReducer::State MemoryReducer::Step(const State& state,
return State(kWait, state.started_gcs, event.time_ms + kShortDelayMs, return State(kWait, state.started_gcs, event.time_ms + kShortDelayMs,
event.time_ms); event.time_ms);
} else { } else {
return State(kDone, 0, 0.0, event.time_ms); return State(kDone, kMaxNumberOfGCs, 0.0, event.time_ms);
} }
} }
} }

View File

@ -130,6 +130,10 @@ class MemoryReducer {
Heap* heap() { return heap_; } Heap* heap() { return heap_; }
bool ShouldGrowHeapSlowly() {
return state_.action == kDone && state_.started_gcs > 0;
}
private: private:
class TimerTask : public v8::internal::CancelableTask { class TimerTask : public v8::internal::CancelableTask {
public: public:

View File

@ -239,19 +239,19 @@ TEST(MemoryReducer, FromWaitToDone) {
state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000)); state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action); EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms); EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs);
EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000)); state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action); EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms); EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs);
EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000)); state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action); EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms); EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs);
EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
} }
@ -295,7 +295,7 @@ TEST(MemoryReducer, FromRunToDone) {
state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000)); state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action); EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms); EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs);
EXPECT_EQ(2000, state1.last_gc_time_ms); EXPECT_EQ(2000, state1.last_gc_time_ms);
state0.started_gcs = MemoryReducer::kMaxNumberOfGCs; state0.started_gcs = MemoryReducer::kMaxNumberOfGCs;