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 = 7; |
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 | 20 |
20 | 21 |
21 void GCIdleTimeAction::Print() { | 22 void GCIdleTimeAction::Print() { |
22 switch (type) { | 23 switch (type) { |
23 case DONE: | 24 case DONE: |
24 PrintF("done"); | 25 PrintF("done"); |
25 break; | 26 break; |
26 case DO_NOTHING: | 27 case DO_NOTHING: |
27 PrintF("no action"); | 28 PrintF("no action"); |
28 break; | 29 break; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 bool GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( | 170 bool GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( |
170 size_t idle_time_in_ms, size_t size_of_objects, | 171 size_t idle_time_in_ms, size_t size_of_objects, |
171 size_t final_incremental_mark_compact_speed_in_bytes_per_ms) { | 172 size_t final_incremental_mark_compact_speed_in_bytes_per_ms) { |
172 return idle_time_in_ms >= | 173 return idle_time_in_ms >= |
173 EstimateFinalIncrementalMarkCompactTime( | 174 EstimateFinalIncrementalMarkCompactTime( |
174 size_of_objects, | 175 size_of_objects, |
175 final_incremental_mark_compact_speed_in_bytes_per_ms); | 176 final_incremental_mark_compact_speed_in_bytes_per_ms); |
176 } | 177 } |
177 | 178 |
178 | 179 |
| 180 bool GCIdleTimeHandler::ShouldDoOverApproximateWeakClosure( |
| 181 size_t idle_time_in_ms) { |
| 182 // TODO(jochen): Estimate the time it will take to build the object groups. |
| 183 return idle_time_in_ms >= kMinTimeForOverApproximatingWeakClosureInMs; |
| 184 } |
| 185 |
| 186 |
179 // The following logic is implemented by the controller: | 187 // The following logic is implemented by the controller: |
180 // (1) If we don't have any idle time, do nothing, unless a context was | 188 // (1) If we don't have any idle time, do nothing, unless a context was |
181 // disposed, incremental marking is stopped, and the heap is small. Then do | 189 // disposed, incremental marking is stopped, and the heap is small. Then do |
182 // a full GC. | 190 // a full GC. |
183 // (2) If the new space is almost full and we can affort a Scavenge or if the | 191 // (2) If the new space is almost full and we can affort a Scavenge or if the |
184 // next Scavenge will very likely take long, then a Scavenge is performed. | 192 // next Scavenge will very likely take long, then a Scavenge is performed. |
185 // (3) If there is currently no MarkCompact idle round going on, we start a | 193 // (3) If there is currently no MarkCompact idle round going on, we start a |
186 // new idle round if enough garbage was created. Otherwise we do not perform | 194 // new idle round if enough garbage was created. Otherwise we do not perform |
187 // garbage collection to keep system utilization low. | 195 // garbage collection to keep system utilization low. |
188 // (4) If incremental marking is done, we perform a full garbage collection | 196 // (4) If incremental marking is done, we perform a full garbage collection |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 !heap_state.can_start_incremental_marking) { | 264 !heap_state.can_start_incremental_marking) { |
257 return GCIdleTimeAction::Nothing(); | 265 return GCIdleTimeAction::Nothing(); |
258 } | 266 } |
259 size_t step_size = EstimateMarkingStepSize( | 267 size_t step_size = EstimateMarkingStepSize( |
260 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), | 268 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), |
261 heap_state.incremental_marking_speed_in_bytes_per_ms); | 269 heap_state.incremental_marking_speed_in_bytes_per_ms); |
262 return GCIdleTimeAction::IncrementalMarking(step_size); | 270 return GCIdleTimeAction::IncrementalMarking(step_size); |
263 } | 271 } |
264 } | 272 } |
265 } | 273 } |
OLD | NEW |