| 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 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 enum GCIdleTimeActionType { | 13 enum GCIdleTimeActionType { |
| 14 DONE, | 14 DONE, |
| 15 DO_NOTHING, | 15 DO_NOTHING, |
| 16 DO_INCREMENTAL_MARKING, | 16 DO_INCREMENTAL_MARKING, |
| 17 DO_SCAVENGE, | 17 DO_SCAVENGE, |
| 18 DO_FULL_GC, | 18 DO_FULL_GC, |
| 19 DO_FULL_GC_COMPACT, | |
| 20 DO_FINALIZE_SWEEPING | 19 DO_FINALIZE_SWEEPING |
| 21 }; | 20 }; |
| 22 | 21 |
| 23 | 22 |
| 24 class GCIdleTimeAction { | 23 class GCIdleTimeAction { |
| 25 public: | 24 public: |
| 26 static GCIdleTimeAction Done() { | 25 static GCIdleTimeAction Done() { |
| 27 GCIdleTimeAction result; | 26 GCIdleTimeAction result; |
| 28 result.type = DONE; | 27 result.type = DONE; |
| 29 result.parameter = 0; | 28 result.parameter = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 54 result.additional_work = false; | 53 result.additional_work = false; |
| 55 return result; | 54 return result; |
| 56 } | 55 } |
| 57 | 56 |
| 58 static GCIdleTimeAction FullGC() { | 57 static GCIdleTimeAction FullGC() { |
| 59 GCIdleTimeAction result; | 58 GCIdleTimeAction result; |
| 60 result.type = DO_FULL_GC; | 59 result.type = DO_FULL_GC; |
| 61 result.parameter = 0; | 60 result.parameter = 0; |
| 62 result.additional_work = false; | 61 result.additional_work = false; |
| 63 return result; | 62 return result; |
| 64 } | |
| 65 | |
| 66 static GCIdleTimeAction FullGCCompact() { | |
| 67 GCIdleTimeAction result; | |
| 68 result.type = DO_FULL_GC_COMPACT; | |
| 69 result.parameter = 0; | |
| 70 result.additional_work = false; | |
| 71 return result; | |
| 72 } | 63 } |
| 73 | 64 |
| 74 static GCIdleTimeAction FinalizeSweeping() { | 65 static GCIdleTimeAction FinalizeSweeping() { |
| 75 GCIdleTimeAction result; | 66 GCIdleTimeAction result; |
| 76 result.type = DO_FINALIZE_SWEEPING; | 67 result.type = DO_FINALIZE_SWEEPING; |
| 77 result.parameter = 0; | 68 result.parameter = 0; |
| 78 result.additional_work = false; | 69 result.additional_work = false; |
| 79 return result; | 70 return result; |
| 80 } | 71 } |
| 81 | 72 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // idle round. | 115 // idle round. |
| 125 static const int kMaxMarkCompactsInIdleRound; | 116 static const int kMaxMarkCompactsInIdleRound; |
| 126 | 117 |
| 127 // Number of scavenges that will trigger start of new idle round. | 118 // Number of scavenges that will trigger start of new idle round. |
| 128 static const int kIdleScavengeThreshold; | 119 static const int kIdleScavengeThreshold; |
| 129 | 120 |
| 130 // This is the maximum scheduled idle time. Note that it can be more than | 121 // This is the maximum scheduled idle time. Note that it can be more than |
| 131 // 16 ms when there is currently no rendering going on. | 122 // 16 ms when there is currently no rendering going on. |
| 132 static const size_t kMaxScheduledIdleTime = 50; | 123 static const size_t kMaxScheduledIdleTime = 50; |
| 133 | 124 |
| 134 // This is the minimum time needed to trigger a full garbage collection which | |
| 135 // tries to reduce memory footprint. | |
| 136 static const size_t kMinTimeForReduceMemory = 600; | |
| 137 | |
| 138 // We conservatively assume that in the next kTimeUntilNextIdleEvent ms | 125 // We conservatively assume that in the next kTimeUntilNextIdleEvent ms |
| 139 // no idle notification happens. | 126 // no idle notification happens. |
| 140 static const size_t kTimeUntilNextIdleEvent = 100; | 127 static const size_t kTimeUntilNextIdleEvent = 100; |
| 141 | 128 |
| 142 // If we haven't recorded any scavenger events yet, we use a conservative | 129 // If we haven't recorded any scavenger events yet, we use a conservative |
| 143 // lower bound for the scavenger speed. | 130 // lower bound for the scavenger speed. |
| 144 static const size_t kInitialConservativeScavengeSpeed = 100 * KB; | 131 static const size_t kInitialConservativeScavengeSpeed = 100 * KB; |
| 145 | 132 |
| 146 // 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. |
| 147 static const double kHighContextDisposalRate; | 134 static const double kHighContextDisposalRate; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 static size_t EstimateMarkCompactTime( | 188 static size_t EstimateMarkCompactTime( |
| 202 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | 189 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); |
| 203 | 190 |
| 204 static size_t EstimateFinalIncrementalMarkCompactTime( | 191 static size_t EstimateFinalIncrementalMarkCompactTime( |
| 205 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | 192 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); |
| 206 | 193 |
| 207 static bool ShouldDoMarkCompact(size_t idle_time_in_ms, | 194 static bool ShouldDoMarkCompact(size_t idle_time_in_ms, |
| 208 size_t size_of_objects, | 195 size_t size_of_objects, |
| 209 size_t mark_compact_speed_in_bytes_per_ms); | 196 size_t mark_compact_speed_in_bytes_per_ms); |
| 210 | 197 |
| 211 static bool ShouldDoReduceMemoryMarkCompact(size_t idle_time_in_ms); | |
| 212 | |
| 213 static bool ShouldDoContextDisposalMarkCompact(int context_disposed, | 198 static bool ShouldDoContextDisposalMarkCompact(int context_disposed, |
| 214 double contexts_disposal_rate); | 199 double contexts_disposal_rate); |
| 215 | 200 |
| 216 static bool ShouldDoFinalIncrementalMarkCompact( | 201 static bool ShouldDoFinalIncrementalMarkCompact( |
| 217 size_t idle_time_in_ms, size_t size_of_objects, | 202 size_t idle_time_in_ms, size_t size_of_objects, |
| 218 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); | 203 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); |
| 219 | 204 |
| 220 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); | 205 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); |
| 221 | 206 |
| 222 static bool ShouldDoScavenge( | 207 static bool ShouldDoScavenge( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 243 int scavenges_since_last_idle_round_; | 228 int scavenges_since_last_idle_round_; |
| 244 int idle_times_which_made_no_progress_since_last_idle_round_; | 229 int idle_times_which_made_no_progress_since_last_idle_round_; |
| 245 | 230 |
| 246 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 231 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
| 247 }; | 232 }; |
| 248 | 233 |
| 249 } // namespace internal | 234 } // namespace internal |
| 250 } // namespace v8 | 235 } // namespace v8 |
| 251 | 236 |
| 252 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 237 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| OLD | NEW |