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

Side by Side Diff: src/heap/gc-tracer.cc

Issue 2269093002: [heap] GCTracer: Record details for incremental marking (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tracer-reland
Patch Set: Fix regression in ::Stop and inline ::AddScopeSample Created 4 years, 3 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-tracer.h ('k') | src/heap/incremental-marking.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-tracer.h" 5 #include "src/heap/gc-tracer.h"
6 6
7 #include "src/counters.h" 7 #include "src/counters.h"
8 #include "src/heap/heap-inl.h" 8 #include "src/heap/heap-inl.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 GCTracer::Scope::~Scope() { 34 GCTracer::Scope::~Scope() {
35 tracer_->AddScopeSample( 35 tracer_->AddScopeSample(
36 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); 36 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_);
37 // TODO(cbruni): remove once we fully moved to a trace-based system. 37 // TODO(cbruni): remove once we fully moved to a trace-based system.
38 if (FLAG_runtime_call_stats) { 38 if (FLAG_runtime_call_stats) {
39 RuntimeCallStats::Leave(tracer_->heap_->isolate(), &timer_); 39 RuntimeCallStats::Leave(tracer_->heap_->isolate(), &timer_);
40 } 40 }
41 } 41 }
42 42
43 void GCTracer::AddScopeSample(Scope::ScopeId scope, double duration) {
44 DCHECK(scope < Scope::NUMBER_OF_SCOPES);
45 if (scope >= Scope::FIRST_INCREMENTAL_SCOPE &&
46 scope <= Scope::LAST_INCREMENTAL_SCOPE) {
47 cumulative_incremental_scopes_[scope] += duration;
48 } else {
49 current_.scopes[scope] += duration;
50 }
51 }
52
53 const char* GCTracer::Scope::Name(ScopeId id) { 43 const char* GCTracer::Scope::Name(ScopeId id) {
54 #define CASE(scope) \ 44 #define CASE(scope) \
55 case Scope::scope: \ 45 case Scope::scope: \
56 return "V8.GC_" #scope; 46 return "V8.GC_" #scope;
57 switch (id) { 47 switch (id) {
58 TRACER_SCOPES(CASE) 48 TRACER_SCOPES(CASE)
59 case Scope::NUMBER_OF_SCOPES: 49 case Scope::NUMBER_OF_SCOPES:
60 break; 50 break;
61 } 51 }
62 #undef CASE 52 #undef CASE
63 return "(unknown)"; 53 return "(unknown)";
64 } 54 }
65 55
66 GCTracer::Event::Event(Type type, const char* gc_reason, 56 GCTracer::Event::Event(Type type, const char* gc_reason,
67 const char* collector_reason) 57 const char* collector_reason)
68 : type(type), 58 : type(type),
69 gc_reason(gc_reason), 59 gc_reason(gc_reason),
70 collector_reason(collector_reason), 60 collector_reason(collector_reason),
71 start_time(0.0), 61 start_time(0.0),
72 end_time(0.0), 62 end_time(0.0),
73 reduce_memory(false), 63 reduce_memory(false),
74 start_object_size(0), 64 start_object_size(0),
75 end_object_size(0), 65 end_object_size(0),
76 start_memory_size(0), 66 start_memory_size(0),
77 end_memory_size(0), 67 end_memory_size(0),
78 start_holes_size(0), 68 start_holes_size(0),
79 end_holes_size(0), 69 end_holes_size(0),
80 new_space_object_size(0), 70 new_space_object_size(0),
81 survived_new_space_object_size(0), 71 survived_new_space_object_size(0),
82 cumulative_incremental_marking_steps(0),
83 incremental_marking_steps(0),
84 cumulative_incremental_marking_bytes(0), 72 cumulative_incremental_marking_bytes(0),
85 incremental_marking_bytes(0), 73 incremental_marking_bytes(0),
86 cumulative_incremental_marking_duration(0.0),
87 incremental_marking_duration(0.0),
88 cumulative_pure_incremental_marking_duration(0.0), 74 cumulative_pure_incremental_marking_duration(0.0),
89 pure_incremental_marking_duration(0.0), 75 pure_incremental_marking_duration(0.0) {
90 longest_incremental_marking_step(0.0),
91 cumulative_incremental_marking_finalization_steps(0),
92 cumulative_incremental_marking_finalizaton_duration(0),
93 longest_incremental_marking_finalization_step(0),
94 incremental_marking_finalizaton_steps(0),
95 incremental_marking_finalization_duration(0) {
96 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
97 cumulative_incremental_scopes[i] = 0;
98 }
99 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { 76 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
100 scopes[i] = 0; 77 scopes[i] = 0;
101 } 78 }
102 } 79 }
103 80
104 81
105 const char* GCTracer::Event::TypeName(bool short_name) const { 82 const char* GCTracer::Event::TypeName(bool short_name) const {
106 switch (type) { 83 switch (type) {
107 case SCAVENGER: 84 case SCAVENGER:
108 if (short_name) { 85 if (short_name) {
(...skipping 11 matching lines...) Expand all
120 case START: 97 case START:
121 if (short_name) { 98 if (short_name) {
122 return "st"; 99 return "st";
123 } else { 100 } else {
124 return "Start"; 101 return "Start";
125 } 102 }
126 } 103 }
127 return "Unknown Event Type"; 104 return "Unknown Event Type";
128 } 105 }
129 106
130
131 GCTracer::GCTracer(Heap* heap) 107 GCTracer::GCTracer(Heap* heap)
132 : heap_(heap), 108 : heap_(heap),
133 cumulative_incremental_marking_steps_(0), 109 current_(Event::START, nullptr, nullptr),
110 previous_(current_),
111 previous_incremental_mark_compactor_event_(current_),
134 cumulative_incremental_marking_bytes_(0), 112 cumulative_incremental_marking_bytes_(0),
135 cumulative_incremental_marking_duration_(0.0), 113 cumulative_incremental_marking_duration_(0.0),
136 cumulative_pure_incremental_marking_duration_(0.0), 114 cumulative_pure_incremental_marking_duration_(0.0),
137 longest_incremental_marking_step_(0.0),
138 cumulative_incremental_marking_finalization_steps_(0),
139 cumulative_incremental_marking_finalization_duration_(0.0),
140 longest_incremental_marking_finalization_step_(0.0),
141 cumulative_marking_duration_(0.0), 115 cumulative_marking_duration_(0.0),
142 cumulative_sweeping_duration_(0.0), 116 cumulative_sweeping_duration_(0.0),
143 allocation_time_ms_(0.0), 117 allocation_time_ms_(0.0),
144 new_space_allocation_counter_bytes_(0), 118 new_space_allocation_counter_bytes_(0),
145 old_generation_allocation_counter_bytes_(0), 119 old_generation_allocation_counter_bytes_(0),
146 allocation_duration_since_gc_(0.0), 120 allocation_duration_since_gc_(0.0),
147 new_space_allocation_in_bytes_since_gc_(0), 121 new_space_allocation_in_bytes_since_gc_(0),
148 old_generation_allocation_in_bytes_since_gc_(0), 122 old_generation_allocation_in_bytes_since_gc_(0),
149 combined_mark_compact_speed_cache_(0.0), 123 combined_mark_compact_speed_cache_(0.0),
150 start_counter_(0) { 124 start_counter_(0) {
151 current_ = Event(Event::START, NULL, NULL);
152 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); 125 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
153 previous_ = previous_incremental_mark_compactor_event_ = current_;
154 } 126 }
155 127
156 void GCTracer::ResetForTesting() { 128 void GCTracer::ResetForTesting() {
157 cumulative_incremental_marking_steps_ = 0.0;
158 cumulative_incremental_marking_bytes_ = 0.0; 129 cumulative_incremental_marking_bytes_ = 0.0;
159 cumulative_incremental_marking_duration_ = 0.0; 130 cumulative_incremental_marking_duration_ = 0.0;
160 cumulative_pure_incremental_marking_duration_ = 0.0; 131 cumulative_pure_incremental_marking_duration_ = 0.0;
161 longest_incremental_marking_step_ = 0.0;
162 cumulative_incremental_marking_finalization_steps_ = 0.0;
163 cumulative_incremental_marking_finalization_duration_ = 0.0;
164 longest_incremental_marking_finalization_step_ = 0.0;
165 cumulative_marking_duration_ = 0.0; 132 cumulative_marking_duration_ = 0.0;
166 cumulative_sweeping_duration_ = 0.0; 133 cumulative_sweeping_duration_ = 0.0;
167 allocation_time_ms_ = 0.0; 134 allocation_time_ms_ = 0.0;
168 new_space_allocation_counter_bytes_ = 0.0; 135 new_space_allocation_counter_bytes_ = 0.0;
169 old_generation_allocation_counter_bytes_ = 0.0; 136 old_generation_allocation_counter_bytes_ = 0.0;
170 allocation_duration_since_gc_ = 0.0; 137 allocation_duration_since_gc_ = 0.0;
171 new_space_allocation_in_bytes_since_gc_ = 0.0; 138 new_space_allocation_in_bytes_since_gc_ = 0.0;
172 old_generation_allocation_in_bytes_since_gc_ = 0.0; 139 old_generation_allocation_in_bytes_since_gc_ = 0.0;
173 combined_mark_compact_speed_cache_ = 0.0; 140 combined_mark_compact_speed_cache_ = 0.0;
174 start_counter_ = 0; 141 start_counter_ = 0;
175 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { 142 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
176 cumulative_incremental_scopes_[i] = 0; 143 incremental_marking_scopes_[i].cumulative_duration = 0.0;
144 incremental_marking_scopes_[i].steps = 0;
145 incremental_marking_scopes_[i].longest_step = 0.0;
177 } 146 }
178 current_ = Event(Event::START, NULL, NULL); 147 current_ = Event(Event::START, NULL, NULL);
179 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); 148 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
180 previous_ = previous_incremental_mark_compactor_event_ = current_; 149 previous_ = previous_incremental_mark_compactor_event_ = current_;
181 } 150 }
182 151
183 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, 152 void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
184 const char* collector_reason) { 153 const char* collector_reason) {
185 start_counter_++; 154 start_counter_++;
186 if (start_counter_ != 1) return; 155 if (start_counter_ != 1) return;
(...skipping 17 matching lines...) Expand all
204 } 173 }
205 174
206 current_.reduce_memory = heap_->ShouldReduceMemory(); 175 current_.reduce_memory = heap_->ShouldReduceMemory();
207 current_.start_time = start_time; 176 current_.start_time = start_time;
208 current_.start_object_size = heap_->SizeOfObjects(); 177 current_.start_object_size = heap_->SizeOfObjects();
209 current_.start_memory_size = heap_->memory_allocator()->Size(); 178 current_.start_memory_size = heap_->memory_allocator()->Size();
210 current_.start_holes_size = CountTotalHolesSize(heap_); 179 current_.start_holes_size = CountTotalHolesSize(heap_);
211 current_.new_space_object_size = 180 current_.new_space_object_size =
212 heap_->new_space()->top() - heap_->new_space()->bottom(); 181 heap_->new_space()->top() - heap_->new_space()->bottom();
213 182
214 current_.cumulative_incremental_marking_steps =
215 cumulative_incremental_marking_steps_;
216 current_.cumulative_incremental_marking_bytes = 183 current_.cumulative_incremental_marking_bytes =
217 cumulative_incremental_marking_bytes_; 184 cumulative_incremental_marking_bytes_;
218 current_.cumulative_incremental_marking_duration =
219 cumulative_incremental_marking_duration_;
220 current_.cumulative_pure_incremental_marking_duration = 185 current_.cumulative_pure_incremental_marking_duration =
221 cumulative_pure_incremental_marking_duration_; 186 cumulative_pure_incremental_marking_duration_;
222 current_.longest_incremental_marking_step = longest_incremental_marking_step_;
223 current_.cumulative_incremental_marking_finalization_steps =
224 cumulative_incremental_marking_finalization_steps_;
225 current_.cumulative_incremental_marking_finalizaton_duration =
226 cumulative_incremental_marking_finalization_duration_;
227 current_.longest_incremental_marking_finalization_step =
228 longest_incremental_marking_finalization_step_;
229 187
230 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { 188 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
231 current_.scopes[i] = 0; 189 current_.scopes[i] = 0;
232 } 190 }
233 191
234 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); 192 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
235 int used_memory = static_cast<int>(current_.start_object_size / KB); 193 int used_memory = static_cast<int>(current_.start_object_size / KB);
236 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( 194 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
237 start_time, committed_memory); 195 start_time, committed_memory);
238 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( 196 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
239 start_time, used_memory); 197 start_time, used_memory);
240 // TODO(cbruni): remove once we fully moved to a trace-based system. 198 // TODO(cbruni): remove once we fully moved to a trace-based system.
241 if (FLAG_runtime_call_stats) { 199 if (FLAG_runtime_call_stats) {
242 RuntimeCallStats::Enter(heap_->isolate(), &timer_, &RuntimeCallStats::GC); 200 RuntimeCallStats::Enter(heap_->isolate(), &timer_, &RuntimeCallStats::GC);
243 } 201 }
244 } 202 }
245 203
204 void GCTracer::MergeBaseline(const Event& baseline) {
205 current_.incremental_marking_bytes =
206 current_.cumulative_incremental_marking_bytes -
207 baseline.cumulative_incremental_marking_bytes;
208 current_.pure_incremental_marking_duration =
209 current_.cumulative_pure_incremental_marking_duration -
210 baseline.cumulative_pure_incremental_marking_duration;
211 for (int i = Scope::FIRST_INCREMENTAL_SCOPE;
212 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) {
213 current_.scopes[i] =
214 current_.incremental_marking_scopes[i].cumulative_duration -
215 baseline.incremental_marking_scopes[i].cumulative_duration;
216 }
217 }
218
246 void GCTracer::Stop(GarbageCollector collector) { 219 void GCTracer::Stop(GarbageCollector collector) {
247 start_counter_--; 220 start_counter_--;
248 if (start_counter_ != 0) { 221 if (start_counter_ != 0) {
249 Output("[Finished reentrant %s during %s.]\n", 222 PrintIsolate(heap_->isolate(), "[Finished reentrant %s during %s.]\n",
250 collector == SCAVENGER ? "Scavenge" : "Mark-sweep", 223 collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
251 current_.TypeName(false)); 224 current_.TypeName(false));
252 return; 225 return;
253 } 226 }
254 227
255 DCHECK(start_counter_ >= 0); 228 DCHECK(start_counter_ >= 0);
256 DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) || 229 DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) ||
257 (collector == MARK_COMPACTOR && 230 (collector == MARK_COMPACTOR &&
258 (current_.type == Event::MARK_COMPACTOR || 231 (current_.type == Event::MARK_COMPACTOR ||
259 current_.type == Event::INCREMENTAL_MARK_COMPACTOR))); 232 current_.type == Event::INCREMENTAL_MARK_COMPACTOR)));
260 233
261 for (int i = Scope::FIRST_INCREMENTAL_SCOPE; 234 for (int i = Scope::FIRST_INCREMENTAL_SCOPE;
262 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) { 235 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) {
263 current_.cumulative_incremental_scopes[i] = 236 current_.incremental_marking_scopes[i] = incremental_marking_scopes_[i];
264 cumulative_incremental_scopes_[i];
265 } 237 }
266 238
267 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); 239 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
268 current_.end_object_size = heap_->SizeOfObjects(); 240 current_.end_object_size = heap_->SizeOfObjects();
269 current_.end_memory_size = heap_->memory_allocator()->Size(); 241 current_.end_memory_size = heap_->memory_allocator()->Size();
270 current_.end_holes_size = CountTotalHolesSize(heap_); 242 current_.end_holes_size = CountTotalHolesSize(heap_);
271 current_.survived_new_space_object_size = heap_->SurvivedNewSpaceObjectSize(); 243 current_.survived_new_space_object_size = heap_->SurvivedNewSpaceObjectSize();
272 244
273 AddAllocation(current_.end_time); 245 AddAllocation(current_.end_time);
274 246
275 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); 247 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
276 int used_memory = static_cast<int>(current_.end_object_size / KB); 248 int used_memory = static_cast<int>(current_.end_object_size / KB);
277 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( 249 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
278 current_.end_time, committed_memory); 250 current_.end_time, committed_memory);
279 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( 251 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
280 current_.end_time, used_memory); 252 current_.end_time, used_memory);
281 253
282 double duration = current_.end_time - current_.start_time; 254 double duration = current_.end_time - current_.start_time;
283 255
284 const Event* baseline = nullptr;
285 if (current_.type == Event::SCAVENGER) { 256 if (current_.type == Event::SCAVENGER) {
286 baseline = &previous_; 257 MergeBaseline(previous_);
287 recorded_scavenges_total_.Push( 258 recorded_scavenges_total_.Push(
288 MakeBytesAndDuration(current_.new_space_object_size, duration)); 259 MakeBytesAndDuration(current_.new_space_object_size, duration));
289 recorded_scavenges_survived_.Push(MakeBytesAndDuration( 260 recorded_scavenges_survived_.Push(MakeBytesAndDuration(
290 current_.survived_new_space_object_size, duration)); 261 current_.survived_new_space_object_size, duration));
291 } else if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) { 262 } else if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) {
292 baseline = &previous_incremental_mark_compactor_event_; 263 MergeBaseline(previous_incremental_mark_compactor_event_);
293 longest_incremental_marking_step_ = 0.0;
294 longest_incremental_marking_finalization_step_ = 0.0;
295 recorded_incremental_marking_steps_.Push( 264 recorded_incremental_marking_steps_.Push(
296 MakeBytesAndDuration(current_.incremental_marking_bytes, 265 MakeBytesAndDuration(current_.incremental_marking_bytes,
297 current_.pure_incremental_marking_duration)); 266 current_.pure_incremental_marking_duration));
298 recorded_incremental_mark_compacts_.Push( 267 recorded_incremental_mark_compacts_.Push(
299 MakeBytesAndDuration(current_.start_object_size, duration)); 268 MakeBytesAndDuration(current_.start_object_size, duration));
300 combined_mark_compact_speed_cache_ = 0.0; 269 combined_mark_compact_speed_cache_ = 0.0;
270 for (int i = 0; i <= Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
271 incremental_marking_scopes_[i].ResetCurrentCycle();
272 }
301 } else { 273 } else {
302 DCHECK(current_.incremental_marking_bytes == 0); 274 DCHECK(current_.incremental_marking_bytes == 0);
303 DCHECK(current_.incremental_marking_duration == 0);
304 DCHECK(current_.pure_incremental_marking_duration == 0); 275 DCHECK(current_.pure_incremental_marking_duration == 0);
305 longest_incremental_marking_step_ = 0.0;
306 longest_incremental_marking_finalization_step_ = 0.0;
307 recorded_mark_compacts_.Push( 276 recorded_mark_compacts_.Push(
308 MakeBytesAndDuration(current_.start_object_size, duration)); 277 MakeBytesAndDuration(current_.start_object_size, duration));
309 combined_mark_compact_speed_cache_ = 0.0; 278 combined_mark_compact_speed_cache_ = 0.0;
310 } 279 for (int i = 0; i <= Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
311 280 incremental_marking_scopes_[i].ResetCurrentCycle();
312 if (baseline != nullptr) {
313 current_.incremental_marking_steps =
314 current_.cumulative_incremental_marking_steps -
315 baseline->cumulative_incremental_marking_steps;
316 current_.incremental_marking_bytes =
317 current_.cumulative_incremental_marking_bytes -
318 baseline->cumulative_incremental_marking_bytes;
319 current_.incremental_marking_duration =
320 current_.cumulative_incremental_marking_duration -
321 baseline->cumulative_incremental_marking_duration;
322 current_.pure_incremental_marking_duration =
323 current_.cumulative_pure_incremental_marking_duration -
324 baseline->cumulative_pure_incremental_marking_duration;
325 current_.incremental_marking_finalizaton_steps =
326 current_.cumulative_incremental_marking_finalization_steps -
327 baseline->cumulative_incremental_marking_finalization_steps;
328 current_.incremental_marking_finalization_duration =
329 current_.cumulative_incremental_marking_finalizaton_duration -
330 baseline->cumulative_incremental_marking_finalizaton_duration;
331 for (int i = Scope::FIRST_INCREMENTAL_SCOPE;
332 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) {
333 current_.scopes[i] = current_.cumulative_incremental_scopes[i] -
334 baseline->cumulative_incremental_scopes[i];
335 } 281 }
336 } 282 }
337 283
338 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); 284 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0);
339 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator, 285 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator,
340 current_.scopes[Scope::MC_MARK]); 286 current_.scopes[Scope::MC_MARK]);
341 287
342 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) 288 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger)
343 return; 289 return;
344 290
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 MakeBytesAndDuration(live_bytes_compacted, duration)); 359 MakeBytesAndDuration(live_bytes_compacted, duration));
414 } 360 }
415 361
416 362
417 void GCTracer::AddSurvivalRatio(double promotion_ratio) { 363 void GCTracer::AddSurvivalRatio(double promotion_ratio) {
418 recorded_survival_ratios_.Push(promotion_ratio); 364 recorded_survival_ratios_.Push(promotion_ratio);
419 } 365 }
420 366
421 367
422 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { 368 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) {
423 cumulative_incremental_marking_steps_++;
424 cumulative_incremental_marking_bytes_ += bytes; 369 cumulative_incremental_marking_bytes_ += bytes;
425 cumulative_incremental_marking_duration_ += duration; 370 cumulative_incremental_marking_duration_ += duration;
426 longest_incremental_marking_step_ =
427 Max(longest_incremental_marking_step_, duration);
428 cumulative_marking_duration_ += duration; 371 cumulative_marking_duration_ += duration;
429 if (bytes > 0) { 372 if (bytes > 0) {
430 cumulative_pure_incremental_marking_duration_ += duration; 373 cumulative_pure_incremental_marking_duration_ += duration;
431 } 374 }
432 } 375 }
433 376
434
435 void GCTracer::AddIncrementalMarkingFinalizationStep(double duration) {
436 cumulative_incremental_marking_finalization_steps_++;
437 cumulative_incremental_marking_finalization_duration_ += duration;
438 longest_incremental_marking_finalization_step_ =
439 Max(longest_incremental_marking_finalization_step_, duration);
440 }
441
442
443 void GCTracer::Output(const char* format, ...) const { 377 void GCTracer::Output(const char* format, ...) const {
444 if (FLAG_trace_gc) { 378 if (FLAG_trace_gc) {
445 va_list arguments; 379 va_list arguments;
446 va_start(arguments, format); 380 va_start(arguments, format);
447 base::OS::VPrint(format, arguments); 381 base::OS::VPrint(format, arguments);
448 va_end(arguments); 382 va_end(arguments);
449 } 383 }
450 384
451 const int kBufferSize = 256; 385 const int kBufferSize = 256;
452 char raw_buffer[kBufferSize]; 386 char raw_buffer[kBufferSize];
453 Vector<char> buffer(raw_buffer, kBufferSize); 387 Vector<char> buffer(raw_buffer, kBufferSize);
454 va_list arguments2; 388 va_list arguments2;
455 va_start(arguments2, format); 389 va_start(arguments2, format);
456 VSNPrintF(buffer, format, arguments2); 390 VSNPrintF(buffer, format, arguments2);
457 va_end(arguments2); 391 va_end(arguments2);
458 392
459 heap_->AddToRingBuffer(buffer.start()); 393 heap_->AddToRingBuffer(buffer.start());
460 } 394 }
461 395
462 396
463 void GCTracer::Print() const { 397 void GCTracer::Print() const {
464 if (FLAG_trace_gc) { 398 double duration = current_.end_time - current_.start_time;
465 PrintIsolate(heap_->isolate(), "%s", ""); 399 const size_t kIncrementalStatsSize = 128;
466 } 400 char incremental_buffer[kIncrementalStatsSize] = {0};
467 Output("%8.0f ms: ", heap_->isolate()->time_millis_since_init());
468 401
469 Output("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", current_.TypeName(false), 402 if (current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps > 0) {
470 static_cast<double>(current_.start_object_size) / MB, 403 if (current_.type == Event::SCAVENGER) {
471 static_cast<double>(current_.start_memory_size) / MB, 404 base::OS::SNPrintF(
472 static_cast<double>(current_.end_object_size) / MB, 405 incremental_buffer, kIncrementalStatsSize,
473 static_cast<double>(current_.end_memory_size) / MB); 406 " (+ %.1f ms in %d steps since last GC)",
474 407 current_.scopes[Scope::MC_INCREMENTAL],
475 double duration = current_.end_time - current_.start_time; 408 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps);
476 Output("%.1f / %.1f ms", duration, TotalExternalTime()); 409 } else {
477 410 base::OS::SNPrintF(
478 if (current_.type == Event::SCAVENGER) { 411 incremental_buffer, kIncrementalStatsSize,
479 if (current_.incremental_marking_steps > 0) {
480 Output(" (+ %.1f ms in %d steps since last GC)",
481 current_.incremental_marking_duration,
482 current_.incremental_marking_steps);
483 }
484 } else {
485 if (current_.incremental_marking_steps > 0) {
486 Output(
487 " (+ %.1f ms in %d steps since start of marking, " 412 " (+ %.1f ms in %d steps since start of marking, "
488 "biggest step %.1f ms)", 413 "biggest step %.1f ms)",
489 current_.incremental_marking_duration, 414 current_.scopes[Scope::MC_INCREMENTAL],
490 current_.incremental_marking_steps, 415 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
491 current_.longest_incremental_marking_step); 416 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL]
417 .longest_step);
492 } 418 }
493 } 419 }
494 420
495 if (current_.gc_reason != NULL) { 421 // Avoid PrintF as Output also appends the string to the tracing ring buffer
496 Output(" [%s]", current_.gc_reason); 422 // that gets printed on OOM failures.
497 } 423 Output(
498 424 "[%d:%p] "
499 if (current_.collector_reason != NULL) { 425 "%8.0f ms: "
500 Output(" [%s]", current_.collector_reason); 426 "%s %.1f (%.1f) -> %.1f (%.1f) MB, "
501 } 427 "%.1f / %.1f ms %s %s %s\n",
502 428 base::OS::GetCurrentProcessId(),
503 Output(".\n"); 429 reinterpret_cast<void*>(heap_->isolate()),
430 heap_->isolate()->time_millis_since_init(), current_.TypeName(false),
431 static_cast<double>(current_.start_object_size) / MB,
432 static_cast<double>(current_.start_memory_size) / MB,
433 static_cast<double>(current_.end_object_size) / MB,
434 static_cast<double>(current_.end_memory_size) / MB, duration,
435 TotalExternalTime(), incremental_buffer,
436 current_.gc_reason != nullptr ? current_.gc_reason : "",
437 current_.collector_reason != nullptr ? current_.collector_reason : "");
504 } 438 }
505 439
506 440
507 void GCTracer::PrintNVP() const { 441 void GCTracer::PrintNVP() const {
508 double duration = current_.end_time - current_.start_time; 442 double duration = current_.end_time - current_.start_time;
509 double spent_in_mutator = current_.start_time - previous_.end_time; 443 double spent_in_mutator = current_.start_time - previous_.end_time;
510 intptr_t allocated_since_last_gc = 444 intptr_t allocated_since_last_gc =
511 current_.start_object_size - previous_.end_object_size; 445 current_.start_object_size - previous_.end_object_size;
512 446
513 switch (current_.type) { 447 switch (current_.type) {
514 case Event::SCAVENGER: 448 case Event::SCAVENGER:
515 PrintIsolate(heap_->isolate(), 449 PrintIsolate(
516 "%8.0f ms: " 450 heap_->isolate(),
517 "pause=%.1f " 451 "%8.0f ms: "
518 "mutator=%.1f " 452 "pause=%.1f "
519 "gc=%s " 453 "mutator=%.1f "
520 "reduce_memory=%d " 454 "gc=%s "
521 "scavenge=%.2f " 455 "reduce_memory=%d "
522 "old_new=%.2f " 456 "scavenge=%.2f "
523 "weak=%.2f " 457 "old_new=%.2f "
524 "roots=%.2f " 458 "weak=%.2f "
525 "code=%.2f " 459 "roots=%.2f "
526 "semispace=%.2f " 460 "code=%.2f "
527 "object_groups=%.2f " 461 "semispace=%.2f "
528 "external_prologue=%.2f " 462 "object_groups=%.2f "
529 "external_epilogue=%.2f " 463 "external_prologue=%.2f "
530 "external_weak_global_handles=%.2f " 464 "external_epilogue=%.2f "
531 "steps_count=%d " 465 "external_weak_global_handles=%.2f "
532 "steps_took=%.1f " 466 "steps_count=%d "
533 "scavenge_throughput=%.f " 467 "steps_took=%.1f "
534 "total_size_before=%" V8PRIdPTR 468 "scavenge_throughput=%.f "
535 " " 469 "total_size_before=%" V8PRIdPTR
536 "total_size_after=%" V8PRIdPTR 470 " "
537 " " 471 "total_size_after=%" V8PRIdPTR
538 "holes_size_before=%" V8PRIdPTR 472 " "
539 " " 473 "holes_size_before=%" V8PRIdPTR
540 "holes_size_after=%" V8PRIdPTR 474 " "
541 " " 475 "holes_size_after=%" V8PRIdPTR
542 "allocated=%" V8PRIdPTR 476 " "
543 " " 477 "allocated=%" V8PRIdPTR
544 "promoted=%" V8PRIdPTR 478 " "
545 " " 479 "promoted=%" V8PRIdPTR
546 "semi_space_copied=%" V8PRIdPTR 480 " "
547 " " 481 "semi_space_copied=%" V8PRIdPTR
548 "nodes_died_in_new=%d " 482 " "
549 "nodes_copied_in_new=%d " 483 "nodes_died_in_new=%d "
550 "nodes_promoted=%d " 484 "nodes_copied_in_new=%d "
551 "promotion_ratio=%.1f%% " 485 "nodes_promoted=%d "
552 "average_survival_ratio=%.1f%% " 486 "promotion_ratio=%.1f%% "
553 "promotion_rate=%.1f%% " 487 "average_survival_ratio=%.1f%% "
554 "semi_space_copy_rate=%.1f%% " 488 "promotion_rate=%.1f%% "
555 "new_space_allocation_throughput=%.1f " 489 "semi_space_copy_rate=%.1f%% "
556 "context_disposal_rate=%.1f\n", 490 "new_space_allocation_throughput=%.1f "
557 heap_->isolate()->time_millis_since_init(), duration, 491 "context_disposal_rate=%.1f\n",
558 spent_in_mutator, current_.TypeName(true), 492 heap_->isolate()->time_millis_since_init(), duration,
559 current_.reduce_memory, 493 spent_in_mutator, current_.TypeName(true), current_.reduce_memory,
560 current_.scopes[Scope::SCAVENGER_SCAVENGE], 494 current_.scopes[Scope::SCAVENGER_SCAVENGE],
561 current_.scopes[Scope::SCAVENGER_OLD_TO_NEW_POINTERS], 495 current_.scopes[Scope::SCAVENGER_OLD_TO_NEW_POINTERS],
562 current_.scopes[Scope::SCAVENGER_WEAK], 496 current_.scopes[Scope::SCAVENGER_WEAK],
563 current_.scopes[Scope::SCAVENGER_ROOTS], 497 current_.scopes[Scope::SCAVENGER_ROOTS],
564 current_.scopes[Scope::SCAVENGER_CODE_FLUSH_CANDIDATES], 498 current_.scopes[Scope::SCAVENGER_CODE_FLUSH_CANDIDATES],
565 current_.scopes[Scope::SCAVENGER_SEMISPACE], 499 current_.scopes[Scope::SCAVENGER_SEMISPACE],
566 current_.scopes[Scope::SCAVENGER_OBJECT_GROUPS], 500 current_.scopes[Scope::SCAVENGER_OBJECT_GROUPS],
567 current_.scopes[Scope::SCAVENGER_EXTERNAL_PROLOGUE], 501 current_.scopes[Scope::SCAVENGER_EXTERNAL_PROLOGUE],
568 current_.scopes[Scope::SCAVENGER_EXTERNAL_EPILOGUE], 502 current_.scopes[Scope::SCAVENGER_EXTERNAL_EPILOGUE],
569 current_.scopes[Scope::EXTERNAL_WEAK_GLOBAL_HANDLES], 503 current_.scopes[Scope::EXTERNAL_WEAK_GLOBAL_HANDLES],
570 current_.incremental_marking_steps, 504 current_.incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL]
571 current_.incremental_marking_duration, 505 .steps,
572 ScavengeSpeedInBytesPerMillisecond(), 506 current_.scopes[Scope::MC_INCREMENTAL],
573 current_.start_object_size, current_.end_object_size, 507 ScavengeSpeedInBytesPerMillisecond(), current_.start_object_size,
574 current_.start_holes_size, current_.end_holes_size, 508 current_.end_object_size, current_.start_holes_size,
575 allocated_since_last_gc, heap_->promoted_objects_size(), 509 current_.end_holes_size, allocated_since_last_gc,
576 heap_->semi_space_copied_object_size(), 510 heap_->promoted_objects_size(),
577 heap_->nodes_died_in_new_space_, 511 heap_->semi_space_copied_object_size(),
578 heap_->nodes_copied_in_new_space_, heap_->nodes_promoted_, 512 heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_,
579 heap_->promotion_ratio_, AverageSurvivalRatio(), 513 heap_->nodes_promoted_, heap_->promotion_ratio_,
580 heap_->promotion_rate_, heap_->semi_space_copied_rate_, 514 AverageSurvivalRatio(), heap_->promotion_rate_,
581 NewSpaceAllocationThroughputInBytesPerMillisecond(), 515 heap_->semi_space_copied_rate_,
582 ContextDisposalRateInMilliseconds()); 516 NewSpaceAllocationThroughputInBytesPerMillisecond(),
517 ContextDisposalRateInMilliseconds());
583 break; 518 break;
584 case Event::MARK_COMPACTOR: 519 case Event::MARK_COMPACTOR:
585 case Event::INCREMENTAL_MARK_COMPACTOR: 520 case Event::INCREMENTAL_MARK_COMPACTOR:
586 PrintIsolate( 521 PrintIsolate(
587 heap_->isolate(), 522 heap_->isolate(),
588 "%8.0f ms: " 523 "%8.0f ms: "
589 "pause=%.1f " 524 "pause=%.1f "
590 "mutator=%.1f " 525 "mutator=%.1f "
591 "gc=%s " 526 "gc=%s "
592 "reduce_memory=%d " 527 "reduce_memory=%d "
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 "mark.weak_closure.harmony=%.1f " 560 "mark.weak_closure.harmony=%.1f "
626 "mark.wrapper_prologue=%.1f " 561 "mark.wrapper_prologue=%.1f "
627 "mark.wrapper_epilogue=%.1f " 562 "mark.wrapper_epilogue=%.1f "
628 "mark.wrapper_tracing=%.1f " 563 "mark.wrapper_tracing=%.1f "
629 "sweep=%.1f " 564 "sweep=%.1f "
630 "sweep.code=%.1f " 565 "sweep.code=%.1f "
631 "sweep.map=%.1f " 566 "sweep.map=%.1f "
632 "sweep.old=%.1f " 567 "sweep.old=%.1f "
633 "incremental=%.1f " 568 "incremental=%.1f "
634 "incremental.finalize=%.1f " 569 "incremental.finalize=%.1f "
570 "incremental.finalize.body=%.1f "
635 "incremental.finalize.external.prologue=%.1f " 571 "incremental.finalize.external.prologue=%.1f "
636 "incremental.finalize.external.epilogue=%.1f " 572 "incremental.finalize.external.epilogue=%.1f "
637 "incremental.finalize.object_grouping=%.1f " 573 "incremental.finalize.object_grouping=%.1f "
638 "incremental.wrapper_prologue=%.1f " 574 "incremental.wrapper_prologue=%.1f "
639 "incremental.wrapper_tracing=%.1f " 575 "incremental.wrapper_tracing=%.1f "
576 "incremental_wrapper_tracing_longest_step=%.1f "
640 "incremental_finalize_longest_step=%.1f " 577 "incremental_finalize_longest_step=%.1f "
641 "incremental_finalize_steps_count=%d " 578 "incremental_finalize_steps_count=%d "
579 "incremental_longest_step=%.1f "
642 "incremental_steps_count=%d " 580 "incremental_steps_count=%d "
643 "incremental_longest_step=%.1f "
644 "incremental_marking_throughput=%.f " 581 "incremental_marking_throughput=%.f "
645 "total_size_before=%" V8PRIdPTR 582 "total_size_before=%" V8PRIdPTR
646 " " 583 " "
647 "total_size_after=%" V8PRIdPTR 584 "total_size_after=%" V8PRIdPTR
648 " " 585 " "
649 "holes_size_before=%" V8PRIdPTR 586 "holes_size_before=%" V8PRIdPTR
650 " " 587 " "
651 "holes_size_after=%" V8PRIdPTR 588 "holes_size_after=%" V8PRIdPTR
652 " " 589 " "
653 "allocated=%" V8PRIdPTR 590 "allocated=%" V8PRIdPTR
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_HANDLES], 637 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_HANDLES],
701 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS], 638 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS],
702 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_HARMONY], 639 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_HARMONY],
703 current_.scopes[Scope::MC_MARK_WRAPPER_PROLOGUE], 640 current_.scopes[Scope::MC_MARK_WRAPPER_PROLOGUE],
704 current_.scopes[Scope::MC_MARK_WRAPPER_EPILOGUE], 641 current_.scopes[Scope::MC_MARK_WRAPPER_EPILOGUE],
705 current_.scopes[Scope::MC_MARK_WRAPPER_TRACING], 642 current_.scopes[Scope::MC_MARK_WRAPPER_TRACING],
706 current_.scopes[Scope::MC_SWEEP], 643 current_.scopes[Scope::MC_SWEEP],
707 current_.scopes[Scope::MC_SWEEP_CODE], 644 current_.scopes[Scope::MC_SWEEP_CODE],
708 current_.scopes[Scope::MC_SWEEP_MAP], 645 current_.scopes[Scope::MC_SWEEP_MAP],
709 current_.scopes[Scope::MC_SWEEP_OLD], 646 current_.scopes[Scope::MC_SWEEP_OLD],
710 current_.incremental_marking_duration, 647 current_.scopes[Scope::MC_INCREMENTAL],
711 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE], 648 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE],
649 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY],
712 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE], 650 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE],
713 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE], 651 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE],
714 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING], 652 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING],
715 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE], 653 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE],
716 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING], 654 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING],
717 current_.longest_incremental_marking_finalization_step, 655 current_
718 current_.incremental_marking_finalizaton_steps, 656 .incremental_marking_scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING]
719 current_.incremental_marking_steps, 657 .longest_step,
720 current_.longest_incremental_marking_step, 658 current_
659 .incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY]
660 .longest_step,
661 current_
662 .incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY]
663 .steps,
664 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL]
665 .longest_step,
666 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
721 IncrementalMarkingSpeedInBytesPerMillisecond(), 667 IncrementalMarkingSpeedInBytesPerMillisecond(),
722 current_.start_object_size, current_.end_object_size, 668 current_.start_object_size, current_.end_object_size,
723 current_.start_holes_size, current_.end_holes_size, 669 current_.start_holes_size, current_.end_holes_size,
724 allocated_since_last_gc, heap_->promoted_objects_size(), 670 allocated_since_last_gc, heap_->promoted_objects_size(),
725 heap_->semi_space_copied_object_size(), 671 heap_->semi_space_copied_object_size(),
726 heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_, 672 heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_,
727 heap_->nodes_promoted_, heap_->promotion_ratio_, 673 heap_->nodes_promoted_, heap_->promotion_ratio_,
728 AverageSurvivalRatio(), heap_->promotion_rate_, 674 AverageSurvivalRatio(), heap_->promotion_rate_,
729 heap_->semi_space_copied_rate_, 675 heap_->semi_space_copied_rate_,
730 NewSpaceAllocationThroughputInBytesPerMillisecond(), 676 NewSpaceAllocationThroughputInBytesPerMillisecond(),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return sum / recorded_survival_ratios_.Count(); 807 return sum / recorded_survival_ratios_.Count();
862 } 808 }
863 809
864 bool GCTracer::SurvivalEventsRecorded() const { 810 bool GCTracer::SurvivalEventsRecorded() const {
865 return recorded_survival_ratios_.Count() > 0; 811 return recorded_survival_ratios_.Count() > 0;
866 } 812 }
867 813
868 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } 814 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); }
869 } // namespace internal 815 } // namespace internal
870 } // namespace v8 816 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-tracer.h ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698