Chromium Code Reviews| Index: src/heap/gc-idle-time-handler.h |
| diff --git a/src/heap/gc-idle-time-handler.h b/src/heap/gc-idle-time-handler.h |
| index ed89b8bc770a07aac81313ddc21ce8487c67565d..ed77be050a45f4bbfdc094c5e08821e892a533a3 100644 |
| --- a/src/heap/gc-idle-time-handler.h |
| +++ b/src/heap/gc-idle-time-handler.h |
| @@ -27,6 +27,7 @@ class GCIdleTimeAction { |
| result.type = DONE; |
| result.parameter = 0; |
| result.additional_work = false; |
| + result.reduce_memory = false; |
| return result; |
| } |
| @@ -35,14 +36,17 @@ class GCIdleTimeAction { |
| result.type = DO_NOTHING; |
| result.parameter = 0; |
| result.additional_work = false; |
| + result.reduce_memory = false; |
| return result; |
| } |
| - static GCIdleTimeAction IncrementalMarking(intptr_t step_size) { |
| + static GCIdleTimeAction IncrementalMarking(intptr_t step_size, |
| + bool reduce_memory) { |
| GCIdleTimeAction result; |
| result.type = DO_INCREMENTAL_MARKING; |
| result.parameter = step_size; |
| result.additional_work = false; |
| + result.reduce_memory = reduce_memory; |
| return result; |
| } |
| @@ -51,14 +55,16 @@ class GCIdleTimeAction { |
| result.type = DO_SCAVENGE; |
| result.parameter = 0; |
| result.additional_work = false; |
| + result.reduce_memory = false; |
| return result; |
| } |
| - static GCIdleTimeAction FullGC() { |
| + static GCIdleTimeAction FullGC(bool reduce_memory) { |
| GCIdleTimeAction result; |
| result.type = DO_FULL_GC; |
| result.parameter = 0; |
| result.additional_work = false; |
| + result.reduce_memory = reduce_memory; |
| return result; |
| } |
| @@ -67,6 +73,7 @@ class GCIdleTimeAction { |
| result.type = DO_FINALIZE_SWEEPING; |
| result.parameter = 0; |
| result.additional_work = false; |
| + result.reduce_memory = false; |
| return result; |
| } |
| @@ -75,6 +82,7 @@ class GCIdleTimeAction { |
| GCIdleTimeActionType type; |
| intptr_t parameter; |
| bool additional_work; |
| + bool reduce_memory; |
| }; |
| @@ -111,13 +119,6 @@ class GCIdleTimeHandler { |
| // EstimateFinalIncrementalMarkCompactTime. |
| static const size_t kMaxFinalIncrementalMarkCompactTimeInMs; |
| - // Number of idle mark-compact events, after which idle handler will finish |
| - // idle round. |
| - static const int kMaxMarkCompactsInIdleRound; |
| - |
| - // Number of scavenges that will trigger start of new idle round. |
| - static const int kIdleScavengeThreshold; |
| - |
| // This is the maximum scheduled idle time. Note that it can be more than |
| // 16.66 ms when there is currently no rendering going on. |
| static const size_t kMaxScheduledIdleTime = 50; |
| @@ -141,10 +142,22 @@ class GCIdleTimeHandler { |
| static const size_t kMinTimeForOverApproximatingWeakClosureInMs; |
| - // Number of times we will return a Nothing action per Idle round despite |
| - // having idle time available before we returning a Done action to ensure we |
| - // don't keep scheduling idle tasks and making no progress. |
| - static const int kMaxNoProgressIdleTimesPerIdleRound = 10; |
| + // The number of idle MarkCompact GCs to perform before transitioning to |
| + // the kDone mode. |
| + static const int kMaxIdleMarkCompacts = 3; |
| + |
| + // The number of mutator GCs before transitioning from the kDone mode. |
|
Hannes Payer (out of office)
2015/05/04 11:20:36
to kReduceLatency
ulan
2015/05/05 12:10:13
Done.
|
| + static const int kGCsBeforeMutatorIsActive = 7; |
| + |
| + // Mutator is considered idle if |
| + // 1) there is an idle notification with time >= kMaxLongIdleTime, |
| + // 2) or there are kLongIdleNotificationsBeforeMutatorIsIdle idle |
| + // notifications |
| + // with time >= kMinLongIdleTime and without any mutator GC in between. |
| + static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1; |
| + static const int kMaxLongIdleTime = 1000; |
| + static const int kLongIdleNotificationsBeforeMutatorIsIdle = 20; |
| + |
| class HeapState { |
| public: |
| @@ -167,23 +180,19 @@ class GCIdleTimeHandler { |
| }; |
| GCIdleTimeHandler() |
| - : mark_compacts_since_idle_round_started_(0), |
| - scavenges_since_last_idle_round_(0), |
| - idle_times_which_made_no_progress_since_last_idle_round_(0) {} |
| + : idle_mark_compacts_(0), |
| + mark_compacts_(0), |
| + scavenges_(0), |
| + long_idle_notifications_(0), |
| + mode_(kReduceLatency) {} |
| GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); |
| - void NotifyIdleMarkCompact() { |
| - if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { |
| - ++mark_compacts_since_idle_round_started_; |
| - if (mark_compacts_since_idle_round_started_ == |
| - kMaxMarkCompactsInIdleRound) { |
| - scavenges_since_last_idle_round_ = 0; |
| - } |
| - } |
| - } |
| + void NotifyIdleMarkCompact() { ++idle_mark_compacts_; } |
| - void NotifyScavenge() { ++scavenges_since_last_idle_round_; } |
| + void NotifyMarkCompact() { ++mark_compacts_; } |
| + |
| + void NotifyScavenge() { ++scavenges_; } |
| static size_t EstimateMarkingStepSize(size_t idle_time_in_ms, |
| size_t marking_speed_in_bytes_per_ms); |
| @@ -213,23 +222,22 @@ class GCIdleTimeHandler { |
| size_t new_space_allocation_throughput_in_bytes_per_ms); |
| private: |
| - GCIdleTimeAction NothingOrDone(); |
| - |
| - void StartIdleRound() { |
| - mark_compacts_since_idle_round_started_ = 0; |
| - idle_times_which_made_no_progress_since_last_idle_round_ = 0; |
| - } |
| - bool IsMarkCompactIdleRoundFinished() { |
| - return mark_compacts_since_idle_round_started_ == |
| - kMaxMarkCompactsInIdleRound; |
| - } |
| - bool EnoughGarbageSinceLastIdleRound() { |
| - return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; |
| - } |
| - |
| - int mark_compacts_since_idle_round_started_; |
| - int scavenges_since_last_idle_round_; |
| - int idle_times_which_made_no_progress_since_last_idle_round_; |
| + enum Mode { kReduceLatency, kReduceMemory, kDone }; |
| + |
| + bool IsMutatorActive(int contexts_disposed, int gcs); |
| + bool IsMutatorIdle(int long_idle_notifications, int gcs); |
| + void UpdateCounters(double idle_time_in_ms); |
| + void ResetCounters(); |
| + Mode NextMode(const HeapState& heap_state); |
| + GCIdleTimeAction Step(double idle_time_in_ms, const HeapState& heap_state, |
| + bool reduce_memory); |
| + |
| + int idle_mark_compacts_; |
| + int mark_compacts_; |
| + int scavenges_; |
| + int long_idle_notifications_; |
| + |
| + Mode mode_; |
| DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
| }; |