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

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

Issue 710603003: Perform context disposal garbage collections only if contexts disposals happen at a high rate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« 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 {
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::kMinTimeForFinalizeSweeping = 100; 14 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100;
15 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7; 15 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7;
16 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; 16 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5;
17 const double GCIdleTimeHandler::kHighContextDisposalRate = 100;
17 18
18 19
19 void GCIdleTimeAction::Print() { 20 void GCIdleTimeAction::Print() {
20 switch (type) { 21 switch (type) {
21 case DONE: 22 case DONE:
22 PrintF("done"); 23 PrintF("done");
23 break; 24 break;
24 case DO_NOTHING: 25 case DO_NOTHING:
25 PrintF("no action"); 26 PrintF("no action");
26 break; 27 break;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 124
124 125
125 // The following logic is implemented by the controller: 126 // The following logic is implemented by the controller:
126 // (1) If we don't have any idle time, do nothing, unless a context was 127 // (1) If we don't have any idle time, do nothing, unless a context was
127 // disposed, incremental marking is stopped, and the heap is small. Then do 128 // disposed, incremental marking is stopped, and the heap is small. Then do
128 // a full GC. 129 // a full GC.
129 // (2) If the new space is almost full and we can affort a Scavenge or if the 130 // (2) If the new space is almost full and we can affort a Scavenge or if the
130 // next Scavenge will very likely take long, then a Scavenge is performed. 131 // next Scavenge will very likely take long, then a Scavenge is performed.
131 // (3) If there is currently no MarkCompact idle round going on, we start a 132 // (3) If there is currently no MarkCompact idle round going on, we start a
132 // new idle round if enough garbage was created or we received a context 133 // new idle round if enough garbage was created. Otherwise we do not perform
133 // disposal event. Otherwise we do not perform garbage collection to keep 134 // garbage collection to keep system utilization low.
134 // system utilization low.
135 // (4) If incremental marking is done, we perform a full garbage collection 135 // (4) If incremental marking is done, we perform a full garbage collection
136 // if context was disposed or if we are allowed to still do full garbage 136 // if we are allowed to still do full garbage collections during this idle
137 // collections during this idle round or if we are not allowed to start 137 // round or if we are not allowed to start incremental marking. Otherwise we
138 // incremental marking. Otherwise we do not perform garbage collection to 138 // do not perform garbage collection to keep system utilization low.
139 // keep system utilization low.
140 // (5) If sweeping is in progress and we received a large enough idle time 139 // (5) If sweeping is in progress and we received a large enough idle time
141 // request, we finalize sweeping here. 140 // request, we finalize sweeping here.
142 // (6) If incremental marking is in progress, we perform a marking step. Note, 141 // (6) If incremental marking is in progress, we perform a marking step. Note,
143 // that this currently may trigger a full garbage collection. 142 // that this currently may trigger a full garbage collection.
144 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, 143 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
145 HeapState heap_state) { 144 HeapState heap_state) {
146 if (idle_time_in_ms == 0) { 145 if (idle_time_in_ms == 0) {
147 if (heap_state.incremental_marking_stopped) { 146 if (heap_state.incremental_marking_stopped) {
148 if (heap_state.size_of_objects < kSmallHeapSize && 147 if (heap_state.size_of_objects < kSmallHeapSize &&
149 heap_state.contexts_disposed > 0) { 148 heap_state.contexts_disposed > 0 &&
149 heap_state.contexts_disposal_rate < kHighContextDisposalRate) {
150 return GCIdleTimeAction::FullGC(); 150 return GCIdleTimeAction::FullGC();
151 } 151 }
152 } 152 }
153 return GCIdleTimeAction::Nothing(); 153 return GCIdleTimeAction::Nothing();
154 } 154 }
155 155
156 if (ShouldDoScavenge( 156 if (ShouldDoScavenge(
157 idle_time_in_ms, heap_state.new_space_capacity, 157 idle_time_in_ms, heap_state.new_space_capacity,
158 heap_state.used_new_space_size, 158 heap_state.used_new_space_size,
159 heap_state.scavenge_speed_in_bytes_per_ms, 159 heap_state.scavenge_speed_in_bytes_per_ms,
160 heap_state.new_space_allocation_throughput_in_bytes_per_ms)) { 160 heap_state.new_space_allocation_throughput_in_bytes_per_ms)) {
161 return GCIdleTimeAction::Scavenge(); 161 return GCIdleTimeAction::Scavenge();
162 } 162 }
163 163
164 if (IsMarkCompactIdleRoundFinished()) { 164 if (IsMarkCompactIdleRoundFinished()) {
165 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { 165 if (EnoughGarbageSinceLastIdleRound()) {
166 StartIdleRound(); 166 StartIdleRound();
167 } else { 167 } else {
168 return GCIdleTimeAction::Done(); 168 return GCIdleTimeAction::Done();
169 } 169 }
170 } 170 }
171 171
172 if (heap_state.incremental_marking_stopped) { 172 if (heap_state.incremental_marking_stopped) {
173 // TODO(jochen): Remove context disposal dependant logic.
174 if (ShouldDoMarkCompact(idle_time_in_ms, heap_state.size_of_objects, 173 if (ShouldDoMarkCompact(idle_time_in_ms, heap_state.size_of_objects,
175 heap_state.mark_compact_speed_in_bytes_per_ms) || 174 heap_state.mark_compact_speed_in_bytes_per_ms)) {
176 (heap_state.size_of_objects < kSmallHeapSize &&
177 heap_state.contexts_disposed > 0)) {
178 // If there are no more than two GCs left in this idle round and we are 175 // If there are no more than two GCs left in this idle round and we are
179 // allowed to do a full GC, then make those GCs full in order to compact 176 // allowed to do a full GC, then make those GCs full in order to compact
180 // the code space. 177 // the code space.
181 // TODO(ulan): Once we enable code compaction for incremental marking, we 178 // TODO(ulan): Once we enable code compaction for incremental marking, we
182 // can get rid of this special case and always start incremental marking. 179 // can get rid of this special case and always start incremental marking.
183 int remaining_mark_sweeps = 180 int remaining_mark_sweeps =
184 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; 181 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_;
185 if (heap_state.contexts_disposed > 0 || 182 if (idle_time_in_ms > kMaxFrameRenderingIdleTime &&
186 (idle_time_in_ms > kMaxFrameRenderingIdleTime && 183 (remaining_mark_sweeps <= 2 ||
187 (remaining_mark_sweeps <= 2 || 184 !heap_state.can_start_incremental_marking)) {
188 !heap_state.can_start_incremental_marking))) {
189 return GCIdleTimeAction::FullGC(); 185 return GCIdleTimeAction::FullGC();
190 } 186 }
191 } 187 }
192 if (!heap_state.can_start_incremental_marking) { 188 if (!heap_state.can_start_incremental_marking) {
193 return GCIdleTimeAction::Nothing(); 189 return GCIdleTimeAction::Nothing();
194 } 190 }
195 } 191 }
196 // TODO(hpayer): Estimate finalize sweeping time. 192 // TODO(hpayer): Estimate finalize sweeping time.
197 if (heap_state.sweeping_in_progress && 193 if (heap_state.sweeping_in_progress &&
198 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { 194 idle_time_in_ms >= kMinTimeForFinalizeSweeping) {
199 return GCIdleTimeAction::FinalizeSweeping(); 195 return GCIdleTimeAction::FinalizeSweeping();
200 } 196 }
201 197
202 if (heap_state.incremental_marking_stopped && 198 if (heap_state.incremental_marking_stopped &&
203 !heap_state.can_start_incremental_marking) { 199 !heap_state.can_start_incremental_marking) {
204 return GCIdleTimeAction::Nothing(); 200 return GCIdleTimeAction::Nothing();
205 } 201 }
206 size_t step_size = EstimateMarkingStepSize( 202 size_t step_size = EstimateMarkingStepSize(
207 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); 203 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms);
208 return GCIdleTimeAction::IncrementalMarking(step_size); 204 return GCIdleTimeAction::IncrementalMarking(step_size);
209 } 205 }
210 } 206 }
211 } 207 }
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