Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: src/heap/gc-idle-time-handler.cc

Issue 1023153002: Limit rate of full garbage collections triggered by idle notification. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 idle_time_in_ms) { 145 idle_time_in_ms) {
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 size_t last_mark_compact_time_in_ms, size_t current_time_in_ms) {
157 EstimateMarkCompactTime(size_of_objects, 157 bool mark_compact_rate_high =
158 mark_compact_speed_in_bytes_per_ms); 158 current_time_in_ms <
159 last_mark_compact_time_in_ms + kMinTimeInBetweenMarkCompactsInMs;
160 return (!mark_compact_rate_high || idle_time_in_ms > kMaxScheduledIdleTime) &&
161 idle_time_in_ms >=
162 EstimateMarkCompactTime(size_of_objects,
rmcilroy 2015/03/20 14:56:08 this is looking pretty complex condition now - cou
163 mark_compact_speed_in_bytes_per_ms);
159 } 164 }
160 165
161 166
162 bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact( 167 bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact(
163 int contexts_disposed, double contexts_disposal_rate) { 168 int contexts_disposed, double contexts_disposal_rate) {
164 return contexts_disposed > 0 && contexts_disposal_rate > 0 && 169 return contexts_disposed > 0 && contexts_disposal_rate > 0 &&
165 contexts_disposal_rate < kHighContextDisposalRate; 170 contexts_disposal_rate < kHighContextDisposalRate;
166 } 171 }
167 172
168 173
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 230 }
226 231
227 if (IsMarkCompactIdleRoundFinished()) { 232 if (IsMarkCompactIdleRoundFinished()) {
228 if (EnoughGarbageSinceLastIdleRound()) { 233 if (EnoughGarbageSinceLastIdleRound()) {
229 StartIdleRound(); 234 StartIdleRound();
230 } else { 235 } else {
231 return GCIdleTimeAction::Done(); 236 return GCIdleTimeAction::Done();
232 } 237 }
233 } 238 }
234 239
235 if (heap_state.incremental_marking_stopped) { 240 if (heap_state.incremental_marking_stopped) {
Erik Corry 2015/03/20 15:21:27 It feels like we are piling more and more heuristi
236 if (ShouldDoMarkCompact(static_cast<size_t>(idle_time_in_ms), 241 if (ShouldDoMarkCompact(
237 heap_state.size_of_objects, 242 static_cast<size_t>(idle_time_in_ms), heap_state.size_of_objects,
238 heap_state.mark_compact_speed_in_bytes_per_ms)) { 243 heap_state.mark_compact_speed_in_bytes_per_ms,
244 heap_state.last_mark_compact_time, heap_state.current_time)) {
239 // If there are no more than two GCs left in this idle round and we are 245 // If there are no more than two GCs left in this idle round and we are
240 // allowed to do a full GC, then make those GCs full in order to compact 246 // allowed to do a full GC, then make those GCs full in order to compact
241 // the code space. 247 // the code space.
242 // TODO(ulan): Once we enable code compaction for incremental marking, we 248 // TODO(ulan): Once we enable code compaction for incremental marking, we
243 // can get rid of this special case and always start incremental marking. 249 // can get rid of this special case and always start incremental marking.
244 int remaining_mark_sweeps = 250 int remaining_mark_sweeps =
245 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; 251 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_;
246 if (static_cast<size_t>(idle_time_in_ms) > kMaxScheduledIdleTime && 252 if (static_cast<size_t>(idle_time_in_ms) > kMaxScheduledIdleTime &&
247 (remaining_mark_sweeps <= 2 || 253 (remaining_mark_sweeps <= 2 ||
248 !heap_state.can_start_incremental_marking)) { 254 !heap_state.can_start_incremental_marking)) {
(...skipping 14 matching lines...) Expand all
263 !heap_state.can_start_incremental_marking) { 269 !heap_state.can_start_incremental_marking) {
264 return GCIdleTimeAction::Nothing(); 270 return GCIdleTimeAction::Nothing();
265 } 271 }
266 size_t step_size = EstimateMarkingStepSize( 272 size_t step_size = EstimateMarkingStepSize(
267 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), 273 static_cast<size_t>(kIncrementalMarkingStepTimeInMs),
268 heap_state.incremental_marking_speed_in_bytes_per_ms); 274 heap_state.incremental_marking_speed_in_bytes_per_ms);
269 return GCIdleTimeAction::IncrementalMarking(step_size); 275 return GCIdleTimeAction::IncrementalMarking(step_size);
270 } 276 }
271 } 277 }
272 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698