Chromium Code Reviews| 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 return idle_time_in_ms >= kMinTimeForOverApproximatingWeakClosureInMs; | |
|
Hannes Payer (out of office)
2015/03/16 12:35:15
Is that also true for slow devices?
jochen (gone - plz use gerrit)
2015/03/16 13:59:30
no idea. I added a TODO and will run some tests lo
| |
| 183 } | |
| 184 | |
| 185 | |
| 179 // The following logic is implemented by the controller: | 186 // The following logic is implemented by the controller: |
| 180 // (1) If we don't have any idle time, do nothing, unless a context was | 187 // (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 | 188 // disposed, incremental marking is stopped, and the heap is small. Then do |
| 182 // a full GC. | 189 // a full GC. |
| 183 // (2) If the new space is almost full and we can affort a Scavenge or if the | 190 // (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. | 191 // 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 | 192 // (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 | 193 // new idle round if enough garbage was created. Otherwise we do not perform |
| 187 // garbage collection to keep system utilization low. | 194 // garbage collection to keep system utilization low. |
| 188 // (4) If incremental marking is done, we perform a full garbage collection | 195 // (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) { | 263 !heap_state.can_start_incremental_marking) { |
| 257 return GCIdleTimeAction::Nothing(); | 264 return GCIdleTimeAction::Nothing(); |
| 258 } | 265 } |
| 259 size_t step_size = EstimateMarkingStepSize( | 266 size_t step_size = EstimateMarkingStepSize( |
| 260 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), | 267 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), |
| 261 heap_state.incremental_marking_speed_in_bytes_per_ms); | 268 heap_state.incremental_marking_speed_in_bytes_per_ms); |
| 262 return GCIdleTimeAction::IncrementalMarking(step_size); | 269 return GCIdleTimeAction::IncrementalMarking(step_size); |
| 263 } | 270 } |
| 264 } | 271 } |
| 265 } | 272 } |
| OLD | NEW |