| 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 are N idle notification with time >= kMinBackgroundIdleTime, | 
| 159   // 2) or there are kLongIdleNotificationsBeforeMutatorIsIdle idle | 160   // 2) or there are M idle notifications with time >= kMinLongIdleTime | 
| 160   // notifications | 161   // without any mutator GC in between. | 
| 161   //    with time >= kMinLongIdleTime and without any mutator GC in between. | 162   // Where N = kBackgroundIdleNotificationsBeforeMutatorIsIdle, | 
|  | 163   //       M = kLongIdleNotificationsBeforeMutatorIsIdle | 
| 162   static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1; | 164   static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1; | 
| 163   static const int kLargeLongIdleTime = 900; | 165   static const int kMinBackgroundIdleTime = 900; | 
| 164   static const int kLongIdleNotificationsBeforeMutatorIsIdle = 600; | 166   static const int kBackgroundIdleNotificationsBeforeMutatorIsIdle = 2; | 
| 165 | 167   static const int kLongIdleNotificationsBeforeMutatorIsIdle = 50; | 
|  | 168   // Number of times we will return a Nothing action in the current mode | 
|  | 169   // despite having idle time available before we returning a Done action to | 
|  | 170   // ensure we don't keep scheduling idle tasks and making no progress. | 
|  | 171   static const int kMaxNoProgressIdleTimesPerMode = 10; | 
| 166 | 172 | 
| 167   class HeapState { | 173   class HeapState { | 
| 168    public: | 174    public: | 
| 169     void Print(); | 175     void Print(); | 
| 170 | 176 | 
| 171     int contexts_disposed; | 177     int contexts_disposed; | 
| 172     double contexts_disposal_rate; | 178     double contexts_disposal_rate; | 
| 173     size_t size_of_objects; | 179     size_t size_of_objects; | 
| 174     bool incremental_marking_stopped; | 180     bool incremental_marking_stopped; | 
| 175     bool can_start_incremental_marking; | 181     bool can_start_incremental_marking; | 
| 176     bool sweeping_in_progress; | 182     bool sweeping_in_progress; | 
| 177     bool sweeping_completed; | 183     bool sweeping_completed; | 
| 178     size_t mark_compact_speed_in_bytes_per_ms; | 184     size_t mark_compact_speed_in_bytes_per_ms; | 
| 179     size_t incremental_marking_speed_in_bytes_per_ms; | 185     size_t incremental_marking_speed_in_bytes_per_ms; | 
| 180     size_t final_incremental_mark_compact_speed_in_bytes_per_ms; | 186     size_t final_incremental_mark_compact_speed_in_bytes_per_ms; | 
| 181     size_t scavenge_speed_in_bytes_per_ms; | 187     size_t scavenge_speed_in_bytes_per_ms; | 
| 182     size_t used_new_space_size; | 188     size_t used_new_space_size; | 
| 183     size_t new_space_capacity; | 189     size_t new_space_capacity; | 
| 184     size_t new_space_allocation_throughput_in_bytes_per_ms; | 190     size_t new_space_allocation_throughput_in_bytes_per_ms; | 
| 185   }; | 191   }; | 
| 186 | 192 | 
| 187   GCIdleTimeHandler() | 193   GCIdleTimeHandler() | 
| 188       : idle_mark_compacts_(0), | 194       : idle_mark_compacts_(0), | 
| 189         mark_compacts_(0), | 195         mark_compacts_(0), | 
| 190         scavenges_(0), | 196         scavenges_(0), | 
| 191         long_idle_notifications_(0), | 197         long_idle_notifications_(0), | 
|  | 198         background_idle_notifications_(0), | 
|  | 199         idle_times_which_made_no_progress_per_mode_(0), | 
| 192         mode_(kReduceLatency) {} | 200         mode_(kReduceLatency) {} | 
| 193 | 201 | 
| 194   GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); | 202   GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); | 
| 195 | 203 | 
| 196   void NotifyIdleMarkCompact() { ++idle_mark_compacts_; } | 204   void NotifyIdleMarkCompact() { ++idle_mark_compacts_; } | 
| 197 | 205 | 
| 198   void NotifyMarkCompact() { ++mark_compacts_; } | 206   void NotifyMarkCompact() { ++mark_compacts_; } | 
| 199 | 207 | 
| 200   void NotifyScavenge() { ++scavenges_; } | 208   void NotifyScavenge() { ++scavenges_; } | 
| 201 | 209 | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 225       size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, | 233       size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, | 
| 226       size_t scavenger_speed_in_bytes_per_ms, | 234       size_t scavenger_speed_in_bytes_per_ms, | 
| 227       size_t new_space_allocation_throughput_in_bytes_per_ms); | 235       size_t new_space_allocation_throughput_in_bytes_per_ms); | 
| 228 | 236 | 
| 229   enum Mode { kReduceLatency, kReduceMemory, kDone }; | 237   enum Mode { kReduceLatency, kReduceMemory, kDone }; | 
| 230 | 238 | 
| 231   Mode mode() { return mode_; } | 239   Mode mode() { return mode_; } | 
| 232 | 240 | 
| 233  private: | 241  private: | 
| 234   bool IsMutatorActive(int contexts_disposed, int gcs); | 242   bool IsMutatorActive(int contexts_disposed, int gcs); | 
| 235   bool IsMutatorIdle(int long_idle_notifications, int gcs); | 243   bool IsMutatorIdle(int long_idle_notifications, | 
|  | 244                      int background_idle_notifications, int gcs); | 
| 236   void UpdateCounters(double idle_time_in_ms); | 245   void UpdateCounters(double idle_time_in_ms); | 
| 237   void ResetCounters(); | 246   void ResetCounters(); | 
| 238   Mode NextMode(const HeapState& heap_state); | 247   Mode NextMode(const HeapState& heap_state); | 
| 239   GCIdleTimeAction Action(double idle_time_in_ms, const HeapState& heap_state, | 248   GCIdleTimeAction Action(double idle_time_in_ms, const HeapState& heap_state, | 
| 240                           bool reduce_memory); | 249                           bool reduce_memory); | 
|  | 250   GCIdleTimeAction NothingOrDone(); | 
| 241 | 251 | 
| 242   int idle_mark_compacts_; | 252   int idle_mark_compacts_; | 
| 243   int mark_compacts_; | 253   int mark_compacts_; | 
| 244   int scavenges_; | 254   int scavenges_; | 
| 245   // The number of long idle notifications with no mutator GC happening | 255   // The number of long idle notifications with no GC happening | 
| 246   // between the notifications. | 256   // between the notifications. | 
| 247   int long_idle_notifications_; | 257   int long_idle_notifications_; | 
|  | 258   // The number of background idle notifications with no GC happening | 
|  | 259   // between the notifications. | 
|  | 260   int background_idle_notifications_; | 
|  | 261   // Idle notifications with no progress in the current mode. | 
|  | 262   int idle_times_which_made_no_progress_per_mode_; | 
| 248 | 263 | 
| 249   Mode mode_; | 264   Mode mode_; | 
| 250 | 265 | 
| 251   DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 266   DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 
| 252 }; | 267 }; | 
| 253 | 268 | 
| 254 }  // namespace internal | 269 }  // namespace internal | 
| 255 }  // namespace v8 | 270 }  // namespace v8 | 
| 256 | 271 | 
| 257 #endif  // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 272 #endif  // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 
| OLD | NEW | 
|---|