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:
parent
869ab06ea5
commit
d8ad147944
@ -5581,7 +5581,7 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
|
||||
double mutator_speed,
|
||||
int freed_global_handles) {
|
||||
const int kFreedGlobalHandlesThreshold = 700;
|
||||
const double kMaxHeapGrowingFactorForManyFreedGlobalHandles = 1.3;
|
||||
const double kConservativeHeapGrowingFactor = 1.3;
|
||||
|
||||
double factor = HeapGrowingFactor(gc_speed, mutator_speed);
|
||||
|
||||
@ -5600,8 +5600,9 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
|
||||
factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained);
|
||||
}
|
||||
|
||||
if (freed_global_handles >= kFreedGlobalHandlesThreshold) {
|
||||
factor = Min(factor, kMaxHeapGrowingFactorForManyFreedGlobalHandles);
|
||||
if (freed_global_handles >= kFreedGlobalHandlesThreshold ||
|
||||
memory_reducer_.ShouldGrowHeapSlowly()) {
|
||||
factor = Min(factor, kConservativeHeapGrowingFactor);
|
||||
}
|
||||
|
||||
if (FLAG_stress_compaction ||
|
||||
|
@ -135,7 +135,7 @@ MemoryReducer::State MemoryReducer::Step(const State& state,
|
||||
return state;
|
||||
case kTimer:
|
||||
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 &&
|
||||
(event.low_allocation_rate || WatchdogGC(state, event))) {
|
||||
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,
|
||||
event.time_ms);
|
||||
} else {
|
||||
return State(kDone, 0, 0.0, event.time_ms);
|
||||
return State(kDone, kMaxNumberOfGCs, 0.0, event.time_ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +130,10 @@ class MemoryReducer {
|
||||
|
||||
Heap* heap() { return heap_; }
|
||||
|
||||
bool ShouldGrowHeapSlowly() {
|
||||
return state_.action == kDone && state_.started_gcs > 0;
|
||||
}
|
||||
|
||||
private:
|
||||
class TimerTask : public v8::internal::CancelableTask {
|
||||
public:
|
||||
|
@ -239,19 +239,19 @@ TEST(MemoryReducer, FromWaitToDone) {
|
||||
state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000));
|
||||
EXPECT_EQ(MemoryReducer::kDone, state1.action);
|
||||
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);
|
||||
|
||||
state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000));
|
||||
EXPECT_EQ(MemoryReducer::kDone, state1.action);
|
||||
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);
|
||||
|
||||
state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000));
|
||||
EXPECT_EQ(MemoryReducer::kDone, state1.action);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ TEST(MemoryReducer, FromRunToDone) {
|
||||
state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000));
|
||||
EXPECT_EQ(MemoryReducer::kDone, state1.action);
|
||||
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);
|
||||
|
||||
state0.started_gcs = MemoryReducer::kMaxNumberOfGCs;
|
||||
|
Loading…
Reference in New Issue
Block a user