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

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

Issue 2324493003: Merged: Squashed multiple commits. (Closed)
Patch Set: 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) {
125 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
126 }
127
128 void GCTracer::ResetForTesting() {
151 current_ = Event(Event::START, NULL, NULL); 129 current_ = Event(Event::START, NULL, NULL);
152 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); 130 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
153 previous_ = previous_incremental_mark_compactor_event_ = current_; 131 previous_ = previous_incremental_mark_compactor_event_ = current_;
154 }
155
156 void GCTracer::ResetForTesting() {
157 cumulative_incremental_marking_steps_ = 0.0;
158 cumulative_incremental_marking_bytes_ = 0.0; 132 cumulative_incremental_marking_bytes_ = 0.0;
159 cumulative_incremental_marking_duration_ = 0.0; 133 cumulative_incremental_marking_duration_ = 0.0;
160 cumulative_pure_incremental_marking_duration_ = 0.0; 134 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; 135 cumulative_marking_duration_ = 0.0;
136 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
137 incremental_marking_scopes_[i].cumulative_duration = 0.0;
138 incremental_marking_scopes_[i].steps = 0;
139 incremental_marking_scopes_[i].longest_step = 0.0;
140 }
166 cumulative_sweeping_duration_ = 0.0; 141 cumulative_sweeping_duration_ = 0.0;
167 allocation_time_ms_ = 0.0; 142 allocation_time_ms_ = 0.0;
168 new_space_allocation_counter_bytes_ = 0.0; 143 new_space_allocation_counter_bytes_ = 0.0;
169 old_generation_allocation_counter_bytes_ = 0.0; 144 old_generation_allocation_counter_bytes_ = 0.0;
170 allocation_duration_since_gc_ = 0.0; 145 allocation_duration_since_gc_ = 0.0;
171 new_space_allocation_in_bytes_since_gc_ = 0.0; 146 new_space_allocation_in_bytes_since_gc_ = 0.0;
172 old_generation_allocation_in_bytes_since_gc_ = 0.0; 147 old_generation_allocation_in_bytes_since_gc_ = 0.0;
173 combined_mark_compact_speed_cache_ = 0.0; 148 combined_mark_compact_speed_cache_ = 0.0;
149 recorded_scavenges_total_.Reset();
150 recorded_scavenges_survived_.Reset();
151 recorded_compactions_.Reset();
152 recorded_mark_compacts_.Reset();
153 recorded_incremental_mark_compacts_.Reset();
154 recorded_new_generation_allocations_.Reset();
155 recorded_old_generation_allocations_.Reset();
156 recorded_context_disposal_times_.Reset();
157 recorded_survival_ratios_.Reset();
174 start_counter_ = 0; 158 start_counter_ = 0;
175 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
176 cumulative_incremental_scopes_[i] = 0;
177 }
178 current_ = Event(Event::START, NULL, NULL);
179 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
180 previous_ = previous_incremental_mark_compactor_event_ = current_;
181 } 159 }
182 160
183 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, 161 void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
184 const char* collector_reason) { 162 const char* collector_reason) {
185 start_counter_++; 163 start_counter_++;
186 if (start_counter_ != 1) return; 164 if (start_counter_ != 1) return;
187 165
188 previous_ = current_; 166 previous_ = current_;
189 double start_time = heap_->MonotonicallyIncreasingTimeInMs(); 167 double start_time = heap_->MonotonicallyIncreasingTimeInMs();
190 SampleAllocation(start_time, heap_->NewSpaceAllocationCounter(), 168 SampleAllocation(start_time, heap_->NewSpaceAllocationCounter(),
(...skipping 13 matching lines...) Expand all
204 } 182 }
205 183
206 current_.reduce_memory = heap_->ShouldReduceMemory(); 184 current_.reduce_memory = heap_->ShouldReduceMemory();
207 current_.start_time = start_time; 185 current_.start_time = start_time;
208 current_.start_object_size = heap_->SizeOfObjects(); 186 current_.start_object_size = heap_->SizeOfObjects();
209 current_.start_memory_size = heap_->memory_allocator()->Size(); 187 current_.start_memory_size = heap_->memory_allocator()->Size();
210 current_.start_holes_size = CountTotalHolesSize(heap_); 188 current_.start_holes_size = CountTotalHolesSize(heap_);
211 current_.new_space_object_size = 189 current_.new_space_object_size =
212 heap_->new_space()->top() - heap_->new_space()->bottom(); 190 heap_->new_space()->top() - heap_->new_space()->bottom();
213 191
214 current_.cumulative_incremental_marking_steps =
215 cumulative_incremental_marking_steps_;
216 current_.cumulative_incremental_marking_bytes = 192 current_.cumulative_incremental_marking_bytes =
217 cumulative_incremental_marking_bytes_; 193 cumulative_incremental_marking_bytes_;
218 current_.cumulative_incremental_marking_duration =
219 cumulative_incremental_marking_duration_;
220 current_.cumulative_pure_incremental_marking_duration = 194 current_.cumulative_pure_incremental_marking_duration =
221 cumulative_pure_incremental_marking_duration_; 195 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 196
230 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { 197 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
231 current_.scopes[i] = 0; 198 current_.scopes[i] = 0;
232 } 199 }
233 200
234 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); 201 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
235 int used_memory = static_cast<int>(current_.start_object_size / KB); 202 int used_memory = static_cast<int>(current_.start_object_size / KB);
236 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( 203 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
237 start_time, committed_memory); 204 start_time, committed_memory);
238 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( 205 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
239 start_time, used_memory); 206 start_time, used_memory);
240 // TODO(cbruni): remove once we fully moved to a trace-based system. 207 // TODO(cbruni): remove once we fully moved to a trace-based system.
241 if (FLAG_runtime_call_stats) { 208 if (FLAG_runtime_call_stats) {
242 RuntimeCallStats::Enter(heap_->isolate(), &timer_, &RuntimeCallStats::GC); 209 RuntimeCallStats::Enter(heap_->isolate(), &timer_, &RuntimeCallStats::GC);
243 } 210 }
244 } 211 }
245 212
213 void GCTracer::MergeBaseline(const Event& baseline) {
214 current_.incremental_marking_bytes =
215 current_.cumulative_incremental_marking_bytes -
216 baseline.cumulative_incremental_marking_bytes;
217 current_.pure_incremental_marking_duration =
218 current_.cumulative_pure_incremental_marking_duration -
219 baseline.cumulative_pure_incremental_marking_duration;
220 for (int i = Scope::FIRST_INCREMENTAL_SCOPE;
221 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) {
222 current_.scopes[i] =
223 current_.incremental_marking_scopes[i].cumulative_duration -
224 baseline.incremental_marking_scopes[i].cumulative_duration;
225 }
226 }
227
246 void GCTracer::Stop(GarbageCollector collector) { 228 void GCTracer::Stop(GarbageCollector collector) {
247 start_counter_--; 229 start_counter_--;
248 if (start_counter_ != 0) { 230 if (start_counter_ != 0) {
249 Output("[Finished reentrant %s during %s.]\n", 231 PrintIsolate(heap_->isolate(), "[Finished reentrant %s during %s.]\n",
250 collector == SCAVENGER ? "Scavenge" : "Mark-sweep", 232 collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
251 current_.TypeName(false)); 233 current_.TypeName(false));
252 return; 234 return;
253 } 235 }
254 236
255 DCHECK(start_counter_ >= 0); 237 DCHECK(start_counter_ >= 0);
256 DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) || 238 DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) ||
257 (collector == MARK_COMPACTOR && 239 (collector == MARK_COMPACTOR &&
258 (current_.type == Event::MARK_COMPACTOR || 240 (current_.type == Event::MARK_COMPACTOR ||
259 current_.type == Event::INCREMENTAL_MARK_COMPACTOR))); 241 current_.type == Event::INCREMENTAL_MARK_COMPACTOR)));
260 242
261 for (int i = Scope::FIRST_INCREMENTAL_SCOPE; 243 for (int i = Scope::FIRST_INCREMENTAL_SCOPE;
262 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) { 244 i <= Scope::LAST_INCREMENTAL_SCOPE; i++) {
263 current_.cumulative_incremental_scopes[i] = 245 current_.incremental_marking_scopes[i] = incremental_marking_scopes_[i];
264 cumulative_incremental_scopes_[i];
265 } 246 }
266 247
267 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); 248 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs();
268 current_.end_object_size = heap_->SizeOfObjects(); 249 current_.end_object_size = heap_->SizeOfObjects();
269 current_.end_memory_size = heap_->memory_allocator()->Size(); 250 current_.end_memory_size = heap_->memory_allocator()->Size();
270 current_.end_holes_size = CountTotalHolesSize(heap_); 251 current_.end_holes_size = CountTotalHolesSize(heap_);
271 current_.survived_new_space_object_size = heap_->SurvivedNewSpaceObjectSize(); 252 current_.survived_new_space_object_size = heap_->SurvivedNewSpaceObjectSize();
272 253
273 AddAllocation(current_.end_time); 254 AddAllocation(current_.end_time);
274 255
275 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); 256 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
276 int used_memory = static_cast<int>(current_.end_object_size / KB); 257 int used_memory = static_cast<int>(current_.end_object_size / KB);
277 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( 258 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
278 current_.end_time, committed_memory); 259 current_.end_time, committed_memory);
279 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( 260 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
280 current_.end_time, used_memory); 261 current_.end_time, used_memory);
281 262
282 double duration = current_.end_time - current_.start_time; 263 double duration = current_.end_time - current_.start_time;
283 264
284 const Event* baseline = nullptr;
285 if (current_.type == Event::SCAVENGER) { 265 if (current_.type == Event::SCAVENGER) {
286 baseline = &previous_; 266 MergeBaseline(previous_);
287 recorded_scavenges_total_.Push( 267 recorded_scavenges_total_.Push(
288 MakeBytesAndDuration(current_.new_space_object_size, duration)); 268 MakeBytesAndDuration(current_.new_space_object_size, duration));
289 recorded_scavenges_survived_.Push(MakeBytesAndDuration( 269 recorded_scavenges_survived_.Push(MakeBytesAndDuration(
290 current_.survived_new_space_object_size, duration)); 270 current_.survived_new_space_object_size, duration));
291 } else if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) { 271 } else if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) {
292 baseline = &previous_incremental_mark_compactor_event_; 272 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( 273 recorded_incremental_marking_steps_.Push(
296 MakeBytesAndDuration(current_.incremental_marking_bytes, 274 MakeBytesAndDuration(current_.incremental_marking_bytes,
297 current_.pure_incremental_marking_duration)); 275 current_.pure_incremental_marking_duration));
298 recorded_incremental_mark_compacts_.Push( 276 recorded_incremental_mark_compacts_.Push(
299 MakeBytesAndDuration(current_.start_object_size, duration)); 277 MakeBytesAndDuration(current_.start_object_size, duration));
300 combined_mark_compact_speed_cache_ = 0.0; 278 combined_mark_compact_speed_cache_ = 0.0;
279 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
280 incremental_marking_scopes_[i].ResetCurrentCycle();
281 }
301 } else { 282 } else {
302 DCHECK(current_.incremental_marking_bytes == 0); 283 DCHECK(current_.incremental_marking_bytes == 0);
303 DCHECK(current_.incremental_marking_duration == 0);
304 DCHECK(current_.pure_incremental_marking_duration == 0); 284 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( 285 recorded_mark_compacts_.Push(
308 MakeBytesAndDuration(current_.start_object_size, duration)); 286 MakeBytesAndDuration(current_.start_object_size, duration));
309 combined_mark_compact_speed_cache_ = 0.0; 287 combined_mark_compact_speed_cache_ = 0.0;
310 } 288 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
311 289 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 } 290 }
336 } 291 }
337 292
338 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); 293 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0);
339 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator, 294 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator,
340 current_.scopes[Scope::MC_MARK]); 295 current_.scopes[Scope::MC_MARK]);
341 296
342 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) 297 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger)
343 return; 298 return;
344 299
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 MakeBytesAndDuration(live_bytes_compacted, duration)); 368 MakeBytesAndDuration(live_bytes_compacted, duration));
414 } 369 }
415 370
416 371
417 void GCTracer::AddSurvivalRatio(double promotion_ratio) { 372 void GCTracer::AddSurvivalRatio(double promotion_ratio) {
418 recorded_survival_ratios_.Push(promotion_ratio); 373 recorded_survival_ratios_.Push(promotion_ratio);
419 } 374 }
420 375
421 376
422 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { 377 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) {
423 cumulative_incremental_marking_steps_++;
424 cumulative_incremental_marking_bytes_ += bytes; 378 cumulative_incremental_marking_bytes_ += bytes;
425 cumulative_incremental_marking_duration_ += duration; 379 cumulative_incremental_marking_duration_ += duration;
426 longest_incremental_marking_step_ =
427 Max(longest_incremental_marking_step_, duration);
428 cumulative_marking_duration_ += duration; 380 cumulative_marking_duration_ += duration;
429 if (bytes > 0) { 381 if (bytes > 0) {
430 cumulative_pure_incremental_marking_duration_ += duration; 382 cumulative_pure_incremental_marking_duration_ += duration;
431 } 383 }
432 } 384 }
433 385
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 { 386 void GCTracer::Output(const char* format, ...) const {
444 if (FLAG_trace_gc) { 387 if (FLAG_trace_gc) {
445 va_list arguments; 388 va_list arguments;
446 va_start(arguments, format); 389 va_start(arguments, format);
447 base::OS::VPrint(format, arguments); 390 base::OS::VPrint(format, arguments);
448 va_end(arguments); 391 va_end(arguments);
449 } 392 }
450 393
451 const int kBufferSize = 256; 394 const int kBufferSize = 256;
452 char raw_buffer[kBufferSize]; 395 char raw_buffer[kBufferSize];
453 Vector<char> buffer(raw_buffer, kBufferSize); 396 Vector<char> buffer(raw_buffer, kBufferSize);
454 va_list arguments2; 397 va_list arguments2;
455 va_start(arguments2, format); 398 va_start(arguments2, format);
456 VSNPrintF(buffer, format, arguments2); 399 VSNPrintF(buffer, format, arguments2);
457 va_end(arguments2); 400 va_end(arguments2);
458 401
459 heap_->AddToRingBuffer(buffer.start()); 402 heap_->AddToRingBuffer(buffer.start());
460 } 403 }
461 404
462 405
463 void GCTracer::Print() const { 406 void GCTracer::Print() const {
464 if (FLAG_trace_gc) { 407 double duration = current_.end_time - current_.start_time;
465 PrintIsolate(heap_->isolate(), "%s", ""); 408 const size_t kIncrementalStatsSize = 128;
466 } 409 char incremental_buffer[kIncrementalStatsSize] = {0};
467 Output("%8.0f ms: ", heap_->isolate()->time_millis_since_init());
468 410
469 Output("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", current_.TypeName(false), 411 if (current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps > 0) {
470 static_cast<double>(current_.start_object_size) / MB, 412 if (current_.type == Event::SCAVENGER) {
471 static_cast<double>(current_.start_memory_size) / MB, 413 base::OS::SNPrintF(
472 static_cast<double>(current_.end_object_size) / MB, 414 incremental_buffer, kIncrementalStatsSize,
473 static_cast<double>(current_.end_memory_size) / MB); 415 " (+ %.1f ms in %d steps since last GC)",
474 416 current_.scopes[Scope::MC_INCREMENTAL],
475 double duration = current_.end_time - current_.start_time; 417 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps);
476 Output("%.1f / %.1f ms", duration, TotalExternalTime()); 418 } else {
477 419 base::OS::SNPrintF(
478 if (current_.type == Event::SCAVENGER) { 420 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, " 421 " (+ %.1f ms in %d steps since start of marking, "
488 "biggest step %.1f ms)", 422 "biggest step %.1f ms)",
489 current_.incremental_marking_duration, 423 current_.scopes[Scope::MC_INCREMENTAL],
490 current_.incremental_marking_steps, 424 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
491 current_.longest_incremental_marking_step); 425 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL]
426 .longest_step);
492 } 427 }
493 } 428 }
494 429
495 if (current_.gc_reason != NULL) { 430 // Avoid PrintF as Output also appends the string to the tracing ring buffer
496 Output(" [%s]", current_.gc_reason); 431 // that gets printed on OOM failures.
497 } 432 Output(
498 433 "[%d:%p] "
499 if (current_.collector_reason != NULL) { 434 "%8.0f ms: "
500 Output(" [%s]", current_.collector_reason); 435 "%s %.1f (%.1f) -> %.1f (%.1f) MB, "
501 } 436 "%.1f / %.1f ms %s %s %s\n",
502 437 base::OS::GetCurrentProcessId(),
503 Output(".\n"); 438 reinterpret_cast<void*>(heap_->isolate()),
439 heap_->isolate()->time_millis_since_init(), current_.TypeName(false),
440 static_cast<double>(current_.start_object_size) / MB,
441 static_cast<double>(current_.start_memory_size) / MB,
442 static_cast<double>(current_.end_object_size) / MB,
443 static_cast<double>(current_.end_memory_size) / MB, duration,
444 TotalExternalTime(), incremental_buffer,
445 current_.gc_reason != nullptr ? current_.gc_reason : "",
446 current_.collector_reason != nullptr ? current_.collector_reason : "");
504 } 447 }
505 448
506 449
507 void GCTracer::PrintNVP() const { 450 void GCTracer::PrintNVP() const {
508 double duration = current_.end_time - current_.start_time; 451 double duration = current_.end_time - current_.start_time;
509 double spent_in_mutator = current_.start_time - previous_.end_time; 452 double spent_in_mutator = current_.start_time - previous_.end_time;
510 intptr_t allocated_since_last_gc = 453 intptr_t allocated_since_last_gc =
511 current_.start_object_size - previous_.end_object_size; 454 current_.start_object_size - previous_.end_object_size;
512 455
513 switch (current_.type) { 456 switch (current_.type) {
514 case Event::SCAVENGER: 457 case Event::SCAVENGER:
515 PrintIsolate(heap_->isolate(), 458 PrintIsolate(
516 "%8.0f ms: " 459 heap_->isolate(),
517 "pause=%.1f " 460 "%8.0f ms: "
518 "mutator=%.1f " 461 "pause=%.1f "
519 "gc=%s " 462 "mutator=%.1f "
520 "reduce_memory=%d " 463 "gc=%s "
521 "scavenge=%.2f " 464 "reduce_memory=%d "
522 "old_new=%.2f " 465 "scavenge=%.2f "
523 "weak=%.2f " 466 "old_new=%.2f "
524 "roots=%.2f " 467 "weak=%.2f "
525 "code=%.2f " 468 "roots=%.2f "
526 "semispace=%.2f " 469 "code=%.2f "
527 "object_groups=%.2f " 470 "semispace=%.2f "
528 "external_prologue=%.2f " 471 "object_groups=%.2f "
529 "external_epilogue=%.2f " 472 "external_prologue=%.2f "
530 "external_weak_global_handles=%.2f " 473 "external_epilogue=%.2f "
531 "steps_count=%d " 474 "external_weak_global_handles=%.2f "
532 "steps_took=%.1f " 475 "steps_count=%d "
533 "scavenge_throughput=%.f " 476 "steps_took=%.1f "
534 "total_size_before=%" V8PRIdPTR 477 "scavenge_throughput=%.f "
535 " " 478 "total_size_before=%" V8PRIdPTR
536 "total_size_after=%" V8PRIdPTR 479 " "
537 " " 480 "total_size_after=%" V8PRIdPTR
538 "holes_size_before=%" V8PRIdPTR 481 " "
539 " " 482 "holes_size_before=%" V8PRIdPTR
540 "holes_size_after=%" V8PRIdPTR 483 " "
541 " " 484 "holes_size_after=%" V8PRIdPTR
542 "allocated=%" V8PRIdPTR 485 " "
543 " " 486 "allocated=%" V8PRIdPTR
544 "promoted=%" V8PRIdPTR 487 " "
545 " " 488 "promoted=%" V8PRIdPTR
546 "semi_space_copied=%" V8PRIdPTR 489 " "
547 " " 490 "semi_space_copied=%" V8PRIdPTR
548 "nodes_died_in_new=%d " 491 " "
549 "nodes_copied_in_new=%d " 492 "nodes_died_in_new=%d "
550 "nodes_promoted=%d " 493 "nodes_copied_in_new=%d "
551 "promotion_ratio=%.1f%% " 494 "nodes_promoted=%d "
552 "average_survival_ratio=%.1f%% " 495 "promotion_ratio=%.1f%% "
553 "promotion_rate=%.1f%% " 496 "average_survival_ratio=%.1f%% "
554 "semi_space_copy_rate=%.1f%% " 497 "promotion_rate=%.1f%% "
555 "new_space_allocation_throughput=%.1f " 498 "semi_space_copy_rate=%.1f%% "
556 "context_disposal_rate=%.1f\n", 499 "new_space_allocation_throughput=%.1f "
557 heap_->isolate()->time_millis_since_init(), duration, 500 "context_disposal_rate=%.1f\n",
558 spent_in_mutator, current_.TypeName(true), 501 heap_->isolate()->time_millis_since_init(), duration,
559 current_.reduce_memory, 502 spent_in_mutator, current_.TypeName(true), current_.reduce_memory,
560 current_.scopes[Scope::SCAVENGER_SCAVENGE], 503 current_.scopes[Scope::SCAVENGER_SCAVENGE],
561 current_.scopes[Scope::SCAVENGER_OLD_TO_NEW_POINTERS], 504 current_.scopes[Scope::SCAVENGER_OLD_TO_NEW_POINTERS],
562 current_.scopes[Scope::SCAVENGER_WEAK], 505 current_.scopes[Scope::SCAVENGER_WEAK],
563 current_.scopes[Scope::SCAVENGER_ROOTS], 506 current_.scopes[Scope::SCAVENGER_ROOTS],
564 current_.scopes[Scope::SCAVENGER_CODE_FLUSH_CANDIDATES], 507 current_.scopes[Scope::SCAVENGER_CODE_FLUSH_CANDIDATES],
565 current_.scopes[Scope::SCAVENGER_SEMISPACE], 508 current_.scopes[Scope::SCAVENGER_SEMISPACE],
566 current_.scopes[Scope::SCAVENGER_OBJECT_GROUPS], 509 current_.scopes[Scope::SCAVENGER_OBJECT_GROUPS],
567 current_.scopes[Scope::SCAVENGER_EXTERNAL_PROLOGUE], 510 current_.scopes[Scope::SCAVENGER_EXTERNAL_PROLOGUE],
568 current_.scopes[Scope::SCAVENGER_EXTERNAL_EPILOGUE], 511 current_.scopes[Scope::SCAVENGER_EXTERNAL_EPILOGUE],
569 current_.scopes[Scope::EXTERNAL_WEAK_GLOBAL_HANDLES], 512 current_.scopes[Scope::EXTERNAL_WEAK_GLOBAL_HANDLES],
570 current_.incremental_marking_steps, 513 current_.incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL]
571 current_.incremental_marking_duration, 514 .steps,
572 ScavengeSpeedInBytesPerMillisecond(), 515 current_.scopes[Scope::MC_INCREMENTAL],
573 current_.start_object_size, current_.end_object_size, 516 ScavengeSpeedInBytesPerMillisecond(), current_.start_object_size,
574 current_.start_holes_size, current_.end_holes_size, 517 current_.end_object_size, current_.start_holes_size,
575 allocated_since_last_gc, heap_->promoted_objects_size(), 518 current_.end_holes_size, allocated_since_last_gc,
576 heap_->semi_space_copied_object_size(), 519 heap_->promoted_objects_size(),
577 heap_->nodes_died_in_new_space_, 520 heap_->semi_space_copied_object_size(),
578 heap_->nodes_copied_in_new_space_, heap_->nodes_promoted_, 521 heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_,
579 heap_->promotion_ratio_, AverageSurvivalRatio(), 522 heap_->nodes_promoted_, heap_->promotion_ratio_,
580 heap_->promotion_rate_, heap_->semi_space_copied_rate_, 523 AverageSurvivalRatio(), heap_->promotion_rate_,
581 NewSpaceAllocationThroughputInBytesPerMillisecond(), 524 heap_->semi_space_copied_rate_,
582 ContextDisposalRateInMilliseconds()); 525 NewSpaceAllocationThroughputInBytesPerMillisecond(),
526 ContextDisposalRateInMilliseconds());
583 break; 527 break;
584 case Event::MARK_COMPACTOR: 528 case Event::MARK_COMPACTOR:
585 case Event::INCREMENTAL_MARK_COMPACTOR: 529 case Event::INCREMENTAL_MARK_COMPACTOR:
586 PrintIsolate( 530 PrintIsolate(
587 heap_->isolate(), 531 heap_->isolate(),
588 "%8.0f ms: " 532 "%8.0f ms: "
589 "pause=%.1f " 533 "pause=%.1f "
590 "mutator=%.1f " 534 "mutator=%.1f "
591 "gc=%s " 535 "gc=%s "
592 "reduce_memory=%d " 536 "reduce_memory=%d "
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 "mark.weak_closure.harmony=%.1f " 569 "mark.weak_closure.harmony=%.1f "
626 "mark.wrapper_prologue=%.1f " 570 "mark.wrapper_prologue=%.1f "
627 "mark.wrapper_epilogue=%.1f " 571 "mark.wrapper_epilogue=%.1f "
628 "mark.wrapper_tracing=%.1f " 572 "mark.wrapper_tracing=%.1f "
629 "sweep=%.1f " 573 "sweep=%.1f "
630 "sweep.code=%.1f " 574 "sweep.code=%.1f "
631 "sweep.map=%.1f " 575 "sweep.map=%.1f "
632 "sweep.old=%.1f " 576 "sweep.old=%.1f "
633 "incremental=%.1f " 577 "incremental=%.1f "
634 "incremental.finalize=%.1f " 578 "incremental.finalize=%.1f "
579 "incremental.finalize.body=%.1f "
635 "incremental.finalize.external.prologue=%.1f " 580 "incremental.finalize.external.prologue=%.1f "
636 "incremental.finalize.external.epilogue=%.1f " 581 "incremental.finalize.external.epilogue=%.1f "
637 "incremental.finalize.object_grouping=%.1f " 582 "incremental.finalize.object_grouping=%.1f "
638 "incremental.wrapper_prologue=%.1f " 583 "incremental.wrapper_prologue=%.1f "
639 "incremental.wrapper_tracing=%.1f " 584 "incremental.wrapper_tracing=%.1f "
585 "incremental_wrapper_tracing_longest_step=%.1f "
640 "incremental_finalize_longest_step=%.1f " 586 "incremental_finalize_longest_step=%.1f "
641 "incremental_finalize_steps_count=%d " 587 "incremental_finalize_steps_count=%d "
588 "incremental_longest_step=%.1f "
642 "incremental_steps_count=%d " 589 "incremental_steps_count=%d "
643 "incremental_longest_step=%.1f "
644 "incremental_marking_throughput=%.f " 590 "incremental_marking_throughput=%.f "
645 "total_size_before=%" V8PRIdPTR 591 "total_size_before=%" V8PRIdPTR
646 " " 592 " "
647 "total_size_after=%" V8PRIdPTR 593 "total_size_after=%" V8PRIdPTR
648 " " 594 " "
649 "holes_size_before=%" V8PRIdPTR 595 "holes_size_before=%" V8PRIdPTR
650 " " 596 " "
651 "holes_size_after=%" V8PRIdPTR 597 "holes_size_after=%" V8PRIdPTR
652 " " 598 " "
653 "allocated=%" V8PRIdPTR 599 "allocated=%" V8PRIdPTR
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_HANDLES], 646 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_HANDLES],
701 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS], 647 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS],
702 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_HARMONY], 648 current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_HARMONY],
703 current_.scopes[Scope::MC_MARK_WRAPPER_PROLOGUE], 649 current_.scopes[Scope::MC_MARK_WRAPPER_PROLOGUE],
704 current_.scopes[Scope::MC_MARK_WRAPPER_EPILOGUE], 650 current_.scopes[Scope::MC_MARK_WRAPPER_EPILOGUE],
705 current_.scopes[Scope::MC_MARK_WRAPPER_TRACING], 651 current_.scopes[Scope::MC_MARK_WRAPPER_TRACING],
706 current_.scopes[Scope::MC_SWEEP], 652 current_.scopes[Scope::MC_SWEEP],
707 current_.scopes[Scope::MC_SWEEP_CODE], 653 current_.scopes[Scope::MC_SWEEP_CODE],
708 current_.scopes[Scope::MC_SWEEP_MAP], 654 current_.scopes[Scope::MC_SWEEP_MAP],
709 current_.scopes[Scope::MC_SWEEP_OLD], 655 current_.scopes[Scope::MC_SWEEP_OLD],
710 current_.incremental_marking_duration, 656 current_.scopes[Scope::MC_INCREMENTAL],
711 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE], 657 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE],
658 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY],
712 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE], 659 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE],
713 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE], 660 current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE],
714 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING], 661 current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING],
715 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE], 662 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE],
716 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING], 663 current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING],
717 current_.longest_incremental_marking_finalization_step, 664 current_
718 current_.incremental_marking_finalizaton_steps, 665 .incremental_marking_scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING]
719 current_.incremental_marking_steps, 666 .longest_step,
720 current_.longest_incremental_marking_step, 667 current_
668 .incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY]
669 .longest_step,
670 current_
671 .incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY]
672 .steps,
673 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL]
674 .longest_step,
675 current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
721 IncrementalMarkingSpeedInBytesPerMillisecond(), 676 IncrementalMarkingSpeedInBytesPerMillisecond(),
722 current_.start_object_size, current_.end_object_size, 677 current_.start_object_size, current_.end_object_size,
723 current_.start_holes_size, current_.end_holes_size, 678 current_.start_holes_size, current_.end_holes_size,
724 allocated_since_last_gc, heap_->promoted_objects_size(), 679 allocated_since_last_gc, heap_->promoted_objects_size(),
725 heap_->semi_space_copied_object_size(), 680 heap_->semi_space_copied_object_size(),
726 heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_, 681 heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_,
727 heap_->nodes_promoted_, heap_->promotion_ratio_, 682 heap_->nodes_promoted_, heap_->promotion_ratio_,
728 AverageSurvivalRatio(), heap_->promotion_rate_, 683 AverageSurvivalRatio(), heap_->promotion_rate_,
729 heap_->semi_space_copied_rate_, 684 heap_->semi_space_copied_rate_,
730 NewSpaceAllocationThroughputInBytesPerMillisecond(), 685 NewSpaceAllocationThroughputInBytesPerMillisecond(),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return sum / recorded_survival_ratios_.Count(); 816 return sum / recorded_survival_ratios_.Count();
862 } 817 }
863 818
864 bool GCTracer::SurvivalEventsRecorded() const { 819 bool GCTracer::SurvivalEventsRecorded() const {
865 return recorded_survival_ratios_.Count() > 0; 820 return recorded_survival_ratios_.Count() > 0;
866 } 821 }
867 822
868 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } 823 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); }
869 } // namespace internal 824 } // namespace internal
870 } // namespace v8 825 } // 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