| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 5 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| 6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| 7 | 7 |
| 8 #include "src/globals.h" | 8 #include "src/globals.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 static const size_t kInitialConservativeScavengeSpeed = 100 * KB; | 131 static const size_t kInitialConservativeScavengeSpeed = 100 * KB; |
| 132 | 132 |
| 133 // If contexts are disposed at a higher rate a full gc is triggered. | 133 // If contexts are disposed at a higher rate a full gc is triggered. |
| 134 static const double kHighContextDisposalRate; | 134 static const double kHighContextDisposalRate; |
| 135 | 135 |
| 136 // Incremental marking step time. | 136 // Incremental marking step time. |
| 137 static const size_t kIncrementalMarkingStepTimeInMs = 1; | 137 static const size_t kIncrementalMarkingStepTimeInMs = 1; |
| 138 | 138 |
| 139 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; | 139 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; |
| 140 | 140 |
| 141 // Number of times we will return a Nothing action per Idle round despite |
| 142 // having idle time available before we returning a Done action to ensure we |
| 143 // don't keep scheduling idle tasks and making no progress. |
| 144 static const int kMaxNoProgressIdleTimesPerIdleRound = 10; |
| 145 |
| 141 class HeapState { | 146 class HeapState { |
| 142 public: | 147 public: |
| 143 void Print(); | 148 void Print(); |
| 144 | 149 |
| 145 int contexts_disposed; | 150 int contexts_disposed; |
| 146 double contexts_disposal_rate; | 151 double contexts_disposal_rate; |
| 147 size_t size_of_objects; | 152 size_t size_of_objects; |
| 148 bool incremental_marking_stopped; | 153 bool incremental_marking_stopped; |
| 149 bool can_start_incremental_marking; | 154 bool can_start_incremental_marking; |
| 150 bool sweeping_in_progress; | 155 bool sweeping_in_progress; |
| 151 bool sweeping_completed; | 156 bool sweeping_completed; |
| 152 size_t mark_compact_speed_in_bytes_per_ms; | 157 size_t mark_compact_speed_in_bytes_per_ms; |
| 153 size_t incremental_marking_speed_in_bytes_per_ms; | 158 size_t incremental_marking_speed_in_bytes_per_ms; |
| 154 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; | 159 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; |
| 155 size_t scavenge_speed_in_bytes_per_ms; | 160 size_t scavenge_speed_in_bytes_per_ms; |
| 156 size_t used_new_space_size; | 161 size_t used_new_space_size; |
| 157 size_t new_space_capacity; | 162 size_t new_space_capacity; |
| 158 size_t new_space_allocation_throughput_in_bytes_per_ms; | 163 size_t new_space_allocation_throughput_in_bytes_per_ms; |
| 159 }; | 164 }; |
| 160 | 165 |
| 161 GCIdleTimeHandler() | 166 GCIdleTimeHandler() |
| 162 : mark_compacts_since_idle_round_started_(0), | 167 : mark_compacts_since_idle_round_started_(0), |
| 163 scavenges_since_last_idle_round_(0) {} | 168 scavenges_since_last_idle_round_(0), |
| 169 idle_times_which_made_no_progress_since_last_idle_round_(0) {} |
| 164 | 170 |
| 165 GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); | 171 GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); |
| 166 | 172 |
| 167 void NotifyIdleMarkCompact() { | 173 void NotifyIdleMarkCompact() { |
| 168 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { | 174 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { |
| 169 ++mark_compacts_since_idle_round_started_; | 175 ++mark_compacts_since_idle_round_started_; |
| 170 if (mark_compacts_since_idle_round_started_ == | 176 if (mark_compacts_since_idle_round_started_ == |
| 171 kMaxMarkCompactsInIdleRound) { | 177 kMaxMarkCompactsInIdleRound) { |
| 172 scavenges_since_last_idle_round_ = 0; | 178 scavenges_since_last_idle_round_ = 0; |
| 173 } | 179 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 197 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); | 203 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); |
| 198 | 204 |
| 199 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); | 205 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); |
| 200 | 206 |
| 201 static bool ShouldDoScavenge( | 207 static bool ShouldDoScavenge( |
| 202 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, | 208 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, |
| 203 size_t scavenger_speed_in_bytes_per_ms, | 209 size_t scavenger_speed_in_bytes_per_ms, |
| 204 size_t new_space_allocation_throughput_in_bytes_per_ms); | 210 size_t new_space_allocation_throughput_in_bytes_per_ms); |
| 205 | 211 |
| 206 private: | 212 private: |
| 207 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } | 213 GCIdleTimeAction NothingOrDone(); |
| 214 |
| 215 void StartIdleRound() { |
| 216 mark_compacts_since_idle_round_started_ = 0; |
| 217 idle_times_which_made_no_progress_since_last_idle_round_ = 0; |
| 218 } |
| 208 bool IsMarkCompactIdleRoundFinished() { | 219 bool IsMarkCompactIdleRoundFinished() { |
| 209 return mark_compacts_since_idle_round_started_ == | 220 return mark_compacts_since_idle_round_started_ == |
| 210 kMaxMarkCompactsInIdleRound; | 221 kMaxMarkCompactsInIdleRound; |
| 211 } | 222 } |
| 212 bool EnoughGarbageSinceLastIdleRound() { | 223 bool EnoughGarbageSinceLastIdleRound() { |
| 213 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; | 224 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; |
| 214 } | 225 } |
| 215 | 226 |
| 216 int mark_compacts_since_idle_round_started_; | 227 int mark_compacts_since_idle_round_started_; |
| 217 int scavenges_since_last_idle_round_; | 228 int scavenges_since_last_idle_round_; |
| 229 int idle_times_which_made_no_progress_since_last_idle_round_; |
| 218 | 230 |
| 219 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 231 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
| 220 }; | 232 }; |
| 221 | 233 |
| 222 } // namespace internal | 234 } // namespace internal |
| 223 } // namespace v8 | 235 } // namespace v8 |
| 224 | 236 |
| 225 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 237 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| OLD | NEW |