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 #include "src/heap/gc-idle-time-handler.h" | 5 #include "src/heap/gc-idle-time-handler.h" |
6 #include "src/heap/gc-tracer.h" | 6 #include "src/heap/gc-tracer.h" |
7 #include "src/utils.h" | 7 #include "src/utils.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; | 12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; |
13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000; | 13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000; |
14 const size_t GCIdleTimeHandler::kMaxFinalIncrementalMarkCompactTimeInMs = 1000; | 14 const size_t GCIdleTimeHandler::kMaxFinalIncrementalMarkCompactTimeInMs = 1000; |
15 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100; | 15 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100; |
16 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7; | 16 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 2; |
17 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; | 17 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; |
18 const double GCIdleTimeHandler::kHighContextDisposalRate = 100; | 18 const double GCIdleTimeHandler::kHighContextDisposalRate = 100; |
19 const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1; | 19 const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1; |
20 | 20 |
21 | 21 |
22 void GCIdleTimeAction::Print() { | 22 void GCIdleTimeAction::Print() { |
23 switch (type) { | 23 switch (type) { |
24 case DONE: | 24 case DONE: |
25 PrintF("done"); | 25 PrintF("done"); |
26 break; | 26 break; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return true; | 146 return true; |
147 } | 147 } |
148 } | 148 } |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 bool GCIdleTimeHandler::ShouldDoMarkCompact( | 153 bool GCIdleTimeHandler::ShouldDoMarkCompact( |
154 size_t idle_time_in_ms, size_t size_of_objects, | 154 size_t idle_time_in_ms, size_t size_of_objects, |
155 size_t mark_compact_speed_in_bytes_per_ms) { | 155 size_t mark_compact_speed_in_bytes_per_ms) { |
156 return idle_time_in_ms >= | 156 return idle_time_in_ms >= kMaxScheduledIdleTime && |
157 EstimateMarkCompactTime(size_of_objects, | 157 idle_time_in_ms >= |
158 mark_compact_speed_in_bytes_per_ms); | 158 EstimateMarkCompactTime(size_of_objects, |
| 159 mark_compact_speed_in_bytes_per_ms); |
159 } | 160 } |
160 | 161 |
161 | 162 |
162 bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact( | 163 bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact( |
163 int contexts_disposed, double contexts_disposal_rate) { | 164 int contexts_disposed, double contexts_disposal_rate) { |
164 return contexts_disposed > 0 && contexts_disposal_rate > 0 && | 165 return contexts_disposed > 0 && contexts_disposal_rate > 0 && |
165 contexts_disposal_rate < kHighContextDisposalRate; | 166 contexts_disposal_rate < kHighContextDisposalRate; |
166 } | 167 } |
167 | 168 |
168 | 169 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 StartIdleRound(); | 230 StartIdleRound(); |
230 } else { | 231 } else { |
231 return GCIdleTimeAction::Done(); | 232 return GCIdleTimeAction::Done(); |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
235 if (heap_state.incremental_marking_stopped) { | 236 if (heap_state.incremental_marking_stopped) { |
236 if (ShouldDoMarkCompact(static_cast<size_t>(idle_time_in_ms), | 237 if (ShouldDoMarkCompact(static_cast<size_t>(idle_time_in_ms), |
237 heap_state.size_of_objects, | 238 heap_state.size_of_objects, |
238 heap_state.mark_compact_speed_in_bytes_per_ms)) { | 239 heap_state.mark_compact_speed_in_bytes_per_ms)) { |
239 // If there are no more than two GCs left in this idle round and we are | 240 return GCIdleTimeAction::FullGC(); |
240 // allowed to do a full GC, then make those GCs full in order to compact | |
241 // the code space. | |
242 // TODO(ulan): Once we enable code compaction for incremental marking, we | |
243 // can get rid of this special case and always start incremental marking. | |
244 int remaining_mark_sweeps = | |
245 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; | |
246 if (static_cast<size_t>(idle_time_in_ms) > kMaxScheduledIdleTime && | |
247 (remaining_mark_sweeps <= 2 || | |
248 !heap_state.can_start_incremental_marking)) { | |
249 return GCIdleTimeAction::FullGC(); | |
250 } | |
251 } | |
252 if (!heap_state.can_start_incremental_marking) { | |
253 return GCIdleTimeAction::Nothing(); | |
254 } | 241 } |
255 } | 242 } |
| 243 |
256 // TODO(hpayer): Estimate finalize sweeping time. | 244 // TODO(hpayer): Estimate finalize sweeping time. |
257 if (heap_state.sweeping_in_progress && | 245 if (heap_state.sweeping_in_progress && |
258 static_cast<size_t>(idle_time_in_ms) >= kMinTimeForFinalizeSweeping) { | 246 static_cast<size_t>(idle_time_in_ms) >= kMinTimeForFinalizeSweeping) { |
259 return GCIdleTimeAction::FinalizeSweeping(); | 247 return GCIdleTimeAction::FinalizeSweeping(); |
260 } | 248 } |
261 | 249 |
262 if (heap_state.incremental_marking_stopped && | 250 if (heap_state.incremental_marking_stopped && |
263 !heap_state.can_start_incremental_marking) { | 251 !heap_state.can_start_incremental_marking) { |
264 return GCIdleTimeAction::Nothing(); | 252 return GCIdleTimeAction::Nothing(); |
265 } | 253 } |
266 size_t step_size = EstimateMarkingStepSize( | 254 size_t step_size = EstimateMarkingStepSize( |
267 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), | 255 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), |
268 heap_state.incremental_marking_speed_in_bytes_per_ms); | 256 heap_state.incremental_marking_speed_in_bytes_per_ms); |
269 return GCIdleTimeAction::IncrementalMarking(step_size); | 257 return GCIdleTimeAction::IncrementalMarking(step_size); |
270 } | 258 } |
271 } | 259 } |
272 } | 260 } |
OLD | NEW |