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

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

Issue 750963002: Reduce context disposal gc overhead. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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') | src/heap/gc-tracer.h » ('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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 bool GCIdleTimeHandler::ShouldDoMarkCompact( 136 bool GCIdleTimeHandler::ShouldDoMarkCompact(
137 size_t idle_time_in_ms, size_t size_of_objects, 137 size_t idle_time_in_ms, size_t size_of_objects,
138 size_t mark_compact_speed_in_bytes_per_ms) { 138 size_t mark_compact_speed_in_bytes_per_ms) {
139 return idle_time_in_ms >= 139 return idle_time_in_ms >=
140 EstimateMarkCompactTime(size_of_objects, 140 EstimateMarkCompactTime(size_of_objects,
141 mark_compact_speed_in_bytes_per_ms); 141 mark_compact_speed_in_bytes_per_ms);
142 } 142 }
143 143
144 144
145 bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact(
146 bool context_disposed, double contexts_disposal_rate) {
147 return context_disposed && contexts_disposal_rate > 0 &&
148 contexts_disposal_rate < kHighContextDisposalRate;
149 }
150
151
145 // The following logic is implemented by the controller: 152 // The following logic is implemented by the controller:
146 // (1) If we don't have any idle time, do nothing, unless a context was 153 // (1) If we don't have any idle time, do nothing, unless a context was
147 // disposed, incremental marking is stopped, and the heap is small. Then do 154 // disposed, incremental marking is stopped, and the heap is small. Then do
148 // a full GC. 155 // a full GC.
149 // (2) If the new space is almost full and we can affort a Scavenge or if the 156 // (2) If the new space is almost full and we can affort a Scavenge or if the
150 // next Scavenge will very likely take long, then a Scavenge is performed. 157 // next Scavenge will very likely take long, then a Scavenge is performed.
151 // (3) If there is currently no MarkCompact idle round going on, we start a 158 // (3) If there is currently no MarkCompact idle round going on, we start a
152 // new idle round if enough garbage was created. Otherwise we do not perform 159 // new idle round if enough garbage was created. Otherwise we do not perform
153 // garbage collection to keep system utilization low. 160 // garbage collection to keep system utilization low.
154 // (4) If incremental marking is done, we perform a full garbage collection 161 // (4) If incremental marking is done, we perform a full garbage collection
155 // if we are allowed to still do full garbage collections during this idle 162 // if we are allowed to still do full garbage collections during this idle
156 // round or if we are not allowed to start incremental marking. Otherwise we 163 // round or if we are not allowed to start incremental marking. Otherwise we
157 // do not perform garbage collection to keep system utilization low. 164 // do not perform garbage collection to keep system utilization low.
158 // (5) If sweeping is in progress and we received a large enough idle time 165 // (5) If sweeping is in progress and we received a large enough idle time
159 // request, we finalize sweeping here. 166 // request, we finalize sweeping here.
160 // (6) If incremental marking is in progress, we perform a marking step. Note, 167 // (6) If incremental marking is in progress, we perform a marking step. Note,
161 // that this currently may trigger a full garbage collection. 168 // that this currently may trigger a full garbage collection.
162 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, 169 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
163 HeapState heap_state) { 170 HeapState heap_state) {
164 if (idle_time_in_ms == 0) { 171 if (idle_time_in_ms == 0) {
165 if (heap_state.incremental_marking_stopped) { 172 if (heap_state.incremental_marking_stopped) {
166 if (heap_state.contexts_disposed > 0 && 173 if (ShouldDoContextDisposalMarkCompact(
167 heap_state.contexts_disposal_rate < kHighContextDisposalRate) { 174 heap_state.contexts_disposed,
175 heap_state.contexts_disposal_rate)) {
168 return GCIdleTimeAction::FullGC(); 176 return GCIdleTimeAction::FullGC();
169 } 177 }
170 } 178 }
171 return GCIdleTimeAction::Nothing(); 179 return GCIdleTimeAction::Nothing();
172 } 180 }
173 181
174 if (ShouldDoScavenge( 182 if (ShouldDoScavenge(
175 idle_time_in_ms, heap_state.new_space_capacity, 183 idle_time_in_ms, heap_state.new_space_capacity,
176 heap_state.used_new_space_size, 184 heap_state.used_new_space_size,
177 heap_state.scavenge_speed_in_bytes_per_ms, 185 heap_state.scavenge_speed_in_bytes_per_ms,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (heap_state.incremental_marking_stopped && 224 if (heap_state.incremental_marking_stopped &&
217 !heap_state.can_start_incremental_marking) { 225 !heap_state.can_start_incremental_marking) {
218 return GCIdleTimeAction::Nothing(); 226 return GCIdleTimeAction::Nothing();
219 } 227 }
220 size_t step_size = EstimateMarkingStepSize( 228 size_t step_size = EstimateMarkingStepSize(
221 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); 229 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms);
222 return GCIdleTimeAction::IncrementalMarking(step_size); 230 return GCIdleTimeAction::IncrementalMarking(step_size);
223 } 231 }
224 } 232 }
225 } 233 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/gc-tracer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698