| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Incremental marking step time. | 145 // Incremental marking step time. |
| 146 static const size_t kIncrementalMarkingStepTimeInMs = 1; | 146 static const size_t kIncrementalMarkingStepTimeInMs = 1; |
| 147 | 147 |
| 148 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; | 148 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; |
| 149 | 149 |
| 150 // The number of idle MarkCompact GCs to perform before transitioning to | 150 // The number of idle MarkCompact GCs to perform before transitioning to |
| 151 // the kDone mode. | 151 // the kDone mode. |
| 152 static const int kMaxIdleMarkCompacts = 3; | 152 static const int kMaxIdleMarkCompacts = 3; |
| 153 | 153 |
| 154 // The number of mutator GCs before transitioning to the kReduceLatency mode. | 154 // The number of mutator MarkCompact GCs before transitioning to the |
| 155 static const int kGCsBeforeMutatorIsActive = 7; | 155 // kReduceLatency mode. |
| 156 static const int kMarkCompactsBeforeMutatorIsActive = 1; |
| 156 | 157 |
| 157 // Mutator is considered idle if | 158 // Mutator is considered idle if |
| 158 // 1) there is an idle notification with time >= kLargeLongIdleTime, | 159 // 1) there is an idle notification with time >= kLargeLongIdleTime, |
| 159 // 2) or there are kLongIdleNotificationsBeforeMutatorIsIdle idle | 160 // 2) or there are kLongIdleNotificationsBeforeMutatorIsIdle idle |
| 160 // notifications | 161 // notifications |
| 161 // with time >= kMinLongIdleTime and without any mutator GC in between. | 162 // with time >= kMinLongIdleTime and without any mutator GC in between. |
| 162 static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1; | 163 static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1; |
| 163 static const int kLargeLongIdleTime = 900; | 164 static const int kLargeLongIdleTime = 900; |
| 164 static const int kLongIdleNotificationsBeforeMutatorIsIdle = 600; | 165 static const int kLongIdleNotificationsBeforeMutatorIsIdle = 50; |
| 165 | 166 // Number of times we will return a Nothing action in the current mode |
| 167 // despite having idle time available before we returning a Done action to |
| 168 // ensure we don't keep scheduling idle tasks and making no progress. |
| 169 static const int kMaxNoProgressIdleTimesPerMode = 10; |
| 166 | 170 |
| 167 class HeapState { | 171 class HeapState { |
| 168 public: | 172 public: |
| 169 void Print(); | 173 void Print(); |
| 170 | 174 |
| 171 int contexts_disposed; | 175 int contexts_disposed; |
| 172 double contexts_disposal_rate; | 176 double contexts_disposal_rate; |
| 173 size_t size_of_objects; | 177 size_t size_of_objects; |
| 174 bool incremental_marking_stopped; | 178 bool incremental_marking_stopped; |
| 175 bool can_start_incremental_marking; | 179 bool can_start_incremental_marking; |
| 176 bool sweeping_in_progress; | 180 bool sweeping_in_progress; |
| 177 bool sweeping_completed; | 181 bool sweeping_completed; |
| 178 size_t mark_compact_speed_in_bytes_per_ms; | 182 size_t mark_compact_speed_in_bytes_per_ms; |
| 179 size_t incremental_marking_speed_in_bytes_per_ms; | 183 size_t incremental_marking_speed_in_bytes_per_ms; |
| 180 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; | 184 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; |
| 181 size_t scavenge_speed_in_bytes_per_ms; | 185 size_t scavenge_speed_in_bytes_per_ms; |
| 182 size_t used_new_space_size; | 186 size_t used_new_space_size; |
| 183 size_t new_space_capacity; | 187 size_t new_space_capacity; |
| 184 size_t new_space_allocation_throughput_in_bytes_per_ms; | 188 size_t new_space_allocation_throughput_in_bytes_per_ms; |
| 185 }; | 189 }; |
| 186 | 190 |
| 187 GCIdleTimeHandler() | 191 GCIdleTimeHandler() |
| 188 : idle_mark_compacts_(0), | 192 : idle_mark_compacts_(0), |
| 189 mark_compacts_(0), | 193 mark_compacts_(0), |
| 190 scavenges_(0), | 194 scavenges_(0), |
| 191 long_idle_notifications_(0), | 195 long_idle_notifications_(0), |
| 196 idle_times_which_made_no_progress_per_mode_(0), |
| 192 mode_(kReduceLatency) {} | 197 mode_(kReduceLatency) {} |
| 193 | 198 |
| 194 GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); | 199 GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); |
| 195 | 200 |
| 196 void NotifyIdleMarkCompact() { ++idle_mark_compacts_; } | 201 void NotifyIdleMarkCompact() { ++idle_mark_compacts_; } |
| 197 | 202 |
| 198 void NotifyMarkCompact() { ++mark_compacts_; } | 203 void NotifyMarkCompact() { ++mark_compacts_; } |
| 199 | 204 |
| 200 void NotifyScavenge() { ++scavenges_; } | 205 void NotifyScavenge() { ++scavenges_; } |
| 201 | 206 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 231 Mode mode() { return mode_; } | 236 Mode mode() { return mode_; } |
| 232 | 237 |
| 233 private: | 238 private: |
| 234 bool IsMutatorActive(int contexts_disposed, int gcs); | 239 bool IsMutatorActive(int contexts_disposed, int gcs); |
| 235 bool IsMutatorIdle(int long_idle_notifications, int gcs); | 240 bool IsMutatorIdle(int long_idle_notifications, int gcs); |
| 236 void UpdateCounters(double idle_time_in_ms); | 241 void UpdateCounters(double idle_time_in_ms); |
| 237 void ResetCounters(); | 242 void ResetCounters(); |
| 238 Mode NextMode(const HeapState& heap_state); | 243 Mode NextMode(const HeapState& heap_state); |
| 239 GCIdleTimeAction Action(double idle_time_in_ms, const HeapState& heap_state, | 244 GCIdleTimeAction Action(double idle_time_in_ms, const HeapState& heap_state, |
| 240 bool reduce_memory); | 245 bool reduce_memory); |
| 246 GCIdleTimeAction NothingOrDone(); |
| 241 | 247 |
| 242 int idle_mark_compacts_; | 248 int idle_mark_compacts_; |
| 243 int mark_compacts_; | 249 int mark_compacts_; |
| 244 int scavenges_; | 250 int scavenges_; |
| 245 // The number of long idle notifications with no mutator GC happening | 251 // The number of long idle notifications with no mutator GC happening |
| 246 // between the notifications. | 252 // between the notifications. |
| 247 int long_idle_notifications_; | 253 int long_idle_notifications_; |
| 254 // Idle notifications with no progress in the current mode. |
| 255 int idle_times_which_made_no_progress_per_mode_; |
| 248 | 256 |
| 249 Mode mode_; | 257 Mode mode_; |
| 250 | 258 |
| 251 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 259 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
| 252 }; | 260 }; |
| 253 | 261 |
| 254 } // namespace internal | 262 } // namespace internal |
| 255 } // namespace v8 | 263 } // namespace v8 |
| 256 | 264 |
| 257 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 265 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| OLD | NEW |