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

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

Issue 1138643003: Make sure that idle scavenges are just performed when enough objects are allocated in new space. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | test/unittests/heap/gc-idle-time-handler-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 size_t new_space_allocation_throughput_in_bytes_per_ms) { 115 size_t new_space_allocation_throughput_in_bytes_per_ms) {
116 size_t new_space_allocation_limit = 116 size_t new_space_allocation_limit =
117 kMaxScheduledIdleTime * scavenge_speed_in_bytes_per_ms; 117 kMaxScheduledIdleTime * scavenge_speed_in_bytes_per_ms;
118 118
119 // If the limit is larger than the new space size, then scavenging used to be 119 // If the limit is larger than the new space size, then scavenging used to be
120 // really fast. We can take advantage of the whole new space. 120 // really fast. We can take advantage of the whole new space.
121 if (new_space_allocation_limit > new_space_size) { 121 if (new_space_allocation_limit > new_space_size) {
122 new_space_allocation_limit = new_space_size; 122 new_space_allocation_limit = new_space_size;
123 } 123 }
124 124
125 // We do not know the allocation throughput before the first Scavenge. 125 // We do not know the allocation throughput before the first scavenge.
126 // TODO(hpayer): Estimate allocation throughput before the first Scavenge. 126 // TODO(hpayer): Estimate allocation throughput before the first scavenge.
127 if (new_space_allocation_throughput_in_bytes_per_ms == 0) { 127 if (new_space_allocation_throughput_in_bytes_per_ms == 0) {
128 new_space_allocation_limit = 128 new_space_allocation_limit =
129 static_cast<size_t>(new_space_size * kConservativeTimeRatio); 129 static_cast<size_t>(new_space_size * kConservativeTimeRatio);
130 } else { 130 } else {
131 // We have to trigger scavenge before we reach the end of new space. 131 // We have to trigger scavenge before we reach the end of new space.
132 size_t adjust_limit = new_space_allocation_throughput_in_bytes_per_ms * 132 size_t adjust_limit = new_space_allocation_throughput_in_bytes_per_ms *
133 kTimeUntilNextIdleEvent; 133 kTimeUntilNextIdleEvent;
134 if (adjust_limit > new_space_allocation_limit) 134 if (adjust_limit > new_space_allocation_limit) {
135 new_space_allocation_limit = 0; 135 new_space_allocation_limit = 0;
136 else 136 } else {
137 new_space_allocation_limit -= adjust_limit; 137 new_space_allocation_limit -= adjust_limit;
138 }
139 }
140
141 // The allocated new space limit to trigger a scavange has to be at least
142 // kMinimumNewSpaceSizeToPerformScavenge.
143 if (new_space_allocation_limit < kMinimumNewSpaceSizeToPerformScavenge) {
144 new_space_allocation_limit = kMinimumNewSpaceSizeToPerformScavenge;
138 } 145 }
139 146
140 if (scavenge_speed_in_bytes_per_ms == 0) { 147 if (scavenge_speed_in_bytes_per_ms == 0) {
141 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed; 148 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed;
142 } 149 }
143 150
144 if (new_space_allocation_limit <= used_new_space_size) { 151 if (new_space_allocation_limit <= used_new_space_size) {
145 if (used_new_space_size / scavenge_speed_in_bytes_per_ms <= 152 if (used_new_space_size / scavenge_speed_in_bytes_per_ms <=
146 idle_time_in_ms) { 153 idle_time_in_ms) {
147 return true; 154 return true;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 245 }
239 } 246 }
240 247
241 248
242 // The following logic is implemented by the controller: 249 // The following logic is implemented by the controller:
243 // (1) If we don't have any idle time, do nothing, unless a context was 250 // (1) If we don't have any idle time, do nothing, unless a context was
244 // disposed, incremental marking is stopped, and the heap is small. Then do 251 // disposed, incremental marking is stopped, and the heap is small. Then do
245 // a full GC. 252 // a full GC.
246 // (2) If the context disposal rate is high and we cannot perform a full GC, 253 // (2) If the context disposal rate is high and we cannot perform a full GC,
247 // we do nothing until the context disposal rate becomes lower. 254 // we do nothing until the context disposal rate becomes lower.
248 // (3) If the new space is almost full and we can affort a Scavenge or if the 255 // (3) If the new space is almost full and we can affort a scavenge or if the
249 // next Scavenge will very likely take long, then a Scavenge is performed. 256 // next scavenge will very likely take long, then a scavenge is performed.
250 // (4) If there is currently no MarkCompact idle round going on, we start a 257 // (4) If there is currently no MarkCompact idle round going on, we start a
251 // new idle round if enough garbage was created. Otherwise we do not perform 258 // new idle round if enough garbage was created. Otherwise we do not perform
252 // garbage collection to keep system utilization low. 259 // garbage collection to keep system utilization low.
253 // (5) If incremental marking is done, we perform a full garbage collection 260 // (5) If incremental marking is done, we perform a full garbage collection
254 // if we are allowed to still do full garbage collections during this idle 261 // if we are allowed to still do full garbage collections during this idle
255 // round or if we are not allowed to start incremental marking. Otherwise we 262 // round or if we are not allowed to start incremental marking. Otherwise we
256 // do not perform garbage collection to keep system utilization low. 263 // do not perform garbage collection to keep system utilization low.
257 // (6) If sweeping is in progress and we received a large enough idle time 264 // (6) If sweeping is in progress and we received a large enough idle time
258 // request, we finalize sweeping here. 265 // request, we finalize sweeping here.
259 // (7) If incremental marking is in progress, we perform a marking step. Note, 266 // (7) If incremental marking is in progress, we perform a marking step. Note,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 383 }
377 if (mutator_gcs > idle_mark_compacts_) { 384 if (mutator_gcs > idle_mark_compacts_) {
378 return kReduceLatency; 385 return kReduceLatency;
379 } 386 }
380 break; 387 break;
381 } 388 }
382 return mode_; 389 return mode_;
383 } 390 }
384 } 391 }
385 } 392 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | test/unittests/heap/gc-idle-time-handler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698