Chromium Code Reviews

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

Issue 2264033002: [heap] Tracer: Handle incremental marking scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | src/heap/gc-tracer.cc » ('j') | src/heap/gc-tracer.cc » ('J')
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 #ifndef V8_HEAP_GC_TRACER_H_ 5 #ifndef V8_HEAP_GC_TRACER_H_
6 #define V8_HEAP_GC_TRACER_H_ 6 #define V8_HEAP_GC_TRACER_H_
7 7
8 #include "src/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
(...skipping 41 matching lines...)
52 }; 52 };
53 53
54 typedef std::pair<uint64_t, double> BytesAndDuration; 54 typedef std::pair<uint64_t, double> BytesAndDuration;
55 55
56 inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) { 56 inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) {
57 return std::make_pair(bytes, duration); 57 return std::make_pair(bytes, duration);
58 } 58 }
59 59
60 enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; 60 enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects };
61 61
62 #define TRACER_SCOPES(F) \ 62 #define INCREMENTAL_SCOPES(F) \
63 F(EXTERNAL_WEAK_GLOBAL_HANDLES) \ 63 F(MC_INCREMENTAL_FINALIZE) \
64 F(MC_CLEAR) \ 64 F(MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING) \
65 F(MC_CLEAR_CODE_FLUSH) \ 65 F(MC_INCREMENTAL_EXTERNAL_EPILOGUE) \
66 F(MC_CLEAR_DEPENDENT_CODE) \ 66 F(MC_INCREMENTAL_EXTERNAL_PROLOGUE)
67 F(MC_CLEAR_GLOBAL_HANDLES) \ 67
68 F(MC_CLEAR_MAPS) \ 68 #define TRACER_SCOPES(F) \
69 F(MC_CLEAR_SLOTS_BUFFER) \ 69 INCREMENTAL_SCOPES(F) \
70 F(MC_CLEAR_STORE_BUFFER) \ 70 F(EXTERNAL_WEAK_GLOBAL_HANDLES) \
71 F(MC_CLEAR_STRING_TABLE) \ 71 F(MC_CLEAR) \
72 F(MC_CLEAR_WEAK_CELLS) \ 72 F(MC_CLEAR_CODE_FLUSH) \
73 F(MC_CLEAR_WEAK_COLLECTIONS) \ 73 F(MC_CLEAR_DEPENDENT_CODE) \
74 F(MC_CLEAR_WEAK_LISTS) \ 74 F(MC_CLEAR_GLOBAL_HANDLES) \
75 F(MC_EVACUATE) \ 75 F(MC_CLEAR_MAPS) \
76 F(MC_EVACUATE_CANDIDATES) \ 76 F(MC_CLEAR_SLOTS_BUFFER) \
77 F(MC_EVACUATE_CLEAN_UP) \ 77 F(MC_CLEAR_STORE_BUFFER) \
78 F(MC_EVACUATE_COPY) \ 78 F(MC_CLEAR_STRING_TABLE) \
79 F(MC_EVACUATE_UPDATE_POINTERS) \ 79 F(MC_CLEAR_WEAK_CELLS) \
80 F(MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED) \ 80 F(MC_CLEAR_WEAK_COLLECTIONS) \
81 F(MC_EVACUATE_UPDATE_POINTERS_TO_NEW) \ 81 F(MC_CLEAR_WEAK_LISTS) \
82 F(MC_EVACUATE_UPDATE_POINTERS_WEAK) \ 82 F(MC_EVACUATE) \
83 F(MC_EXTERNAL_EPILOGUE) \ 83 F(MC_EVACUATE_CANDIDATES) \
84 F(MC_EXTERNAL_PROLOGUE) \ 84 F(MC_EVACUATE_CLEAN_UP) \
85 F(MC_FINISH) \ 85 F(MC_EVACUATE_COPY) \
86 F(MC_INCREMENTAL_FINALIZE) \ 86 F(MC_EVACUATE_UPDATE_POINTERS) \
87 F(MC_INCREMENTAL_EXTERNAL_EPILOGUE) \ 87 F(MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED) \
88 F(MC_INCREMENTAL_EXTERNAL_PROLOGUE) \ 88 F(MC_EVACUATE_UPDATE_POINTERS_TO_NEW) \
89 F(MC_MARK) \ 89 F(MC_EVACUATE_UPDATE_POINTERS_WEAK) \
90 F(MC_MARK_FINISH_INCREMENTAL) \ 90 F(MC_EXTERNAL_EPILOGUE) \
91 F(MC_MARK_PREPARE_CODE_FLUSH) \ 91 F(MC_EXTERNAL_PROLOGUE) \
92 F(MC_MARK_ROOTS) \ 92 F(MC_FINISH) \
93 F(MC_MARK_WEAK_CLOSURE) \ 93 F(MC_MARK) \
94 F(MC_MARK_WEAK_CLOSURE_EPHEMERAL) \ 94 F(MC_MARK_FINISH_INCREMENTAL) \
95 F(MC_MARK_WEAK_CLOSURE_WEAK_HANDLES) \ 95 F(MC_MARK_PREPARE_CODE_FLUSH) \
96 F(MC_MARK_WEAK_CLOSURE_WEAK_ROOTS) \ 96 F(MC_MARK_ROOTS) \
97 F(MC_MARK_WEAK_CLOSURE_HARMONY) \ 97 F(MC_MARK_WEAK_CLOSURE) \
98 F(MC_SWEEP) \ 98 F(MC_MARK_WEAK_CLOSURE_EPHEMERAL) \
99 F(MC_SWEEP_CODE) \ 99 F(MC_MARK_WEAK_CLOSURE_WEAK_HANDLES) \
100 F(MC_SWEEP_MAP) \ 100 F(MC_MARK_WEAK_CLOSURE_WEAK_ROOTS) \
101 F(MC_SWEEP_OLD) \ 101 F(MC_MARK_WEAK_CLOSURE_HARMONY) \
102 F(SCAVENGER_CODE_FLUSH_CANDIDATES) \ 102 F(MC_SWEEP) \
103 F(SCAVENGER_EXTERNAL_EPILOGUE) \ 103 F(MC_SWEEP_CODE) \
104 F(SCAVENGER_EXTERNAL_PROLOGUE) \ 104 F(MC_SWEEP_MAP) \
105 F(SCAVENGER_OBJECT_GROUPS) \ 105 F(MC_SWEEP_OLD) \
106 F(SCAVENGER_OLD_TO_NEW_POINTERS) \ 106 F(SCAVENGER_CODE_FLUSH_CANDIDATES) \
107 F(SCAVENGER_ROOTS) \ 107 F(SCAVENGER_EXTERNAL_EPILOGUE) \
108 F(SCAVENGER_SCAVENGE) \ 108 F(SCAVENGER_EXTERNAL_PROLOGUE) \
109 F(SCAVENGER_SEMISPACE) \ 109 F(SCAVENGER_OBJECT_GROUPS) \
110 F(SCAVENGER_OLD_TO_NEW_POINTERS) \
111 F(SCAVENGER_ROOTS) \
112 F(SCAVENGER_SCAVENGE) \
113 F(SCAVENGER_SEMISPACE) \
110 F(SCAVENGER_WEAK) 114 F(SCAVENGER_WEAK)
111 115
112 #define TRACE_GC(tracer, scope_id) \ 116 #define TRACE_GC(tracer, scope_id) \
113 GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \ 117 GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
114 GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id); \ 118 GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id); \
115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), \ 119 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), \
116 GCTracer::Scope::Name(gc_tracer_scope_id)) 120 GCTracer::Scope::Name(gc_tracer_scope_id))
117 121
118 // GCTracer collects and prints ONE line after each garbage collector 122 // GCTracer collects and prints ONE line after each garbage collector
119 // invocation IFF --trace_gc is used. 123 // invocation IFF --trace_gc is used.
120 // TODO(ernstm): Unit tests. 124 // TODO(ernstm): Unit tests.
121 class GCTracer { 125 class GCTracer {
122 public: 126 public:
123 class Scope { 127 class Scope {
124 public: 128 public:
125 enum ScopeId { 129 enum ScopeId {
126 #define DEFINE_SCOPE(scope) scope, 130 #define DEFINE_SCOPE(scope) scope,
127 TRACER_SCOPES(DEFINE_SCOPE) 131 TRACER_SCOPES(DEFINE_SCOPE)
128 #undef DEFINE_SCOPE 132 #undef DEFINE_SCOPE
129 NUMBER_OF_SCOPES 133 NUMBER_OF_SCOPES,
134
135 FIRST_INCREMENTAL_SCOPE = MC_INCREMENTAL_FINALIZE,
136 LAST_INCREMENTAL_SCOPE = MC_INCREMENTAL_EXTERNAL_PROLOGUE,
137 NUMBER_OF_INCREMENTAL_SCOPES =
138 LAST_INCREMENTAL_SCOPE - FIRST_INCREMENTAL_SCOPE + 1
130 }; 139 };
131 140
132 Scope(GCTracer* tracer, ScopeId scope); 141 Scope(GCTracer* tracer, ScopeId scope);
133 ~Scope(); 142 ~Scope();
134 static const char* Name(ScopeId id); 143 static const char* Name(ScopeId id);
135 144
136 private: 145 private:
137 GCTracer* tracer_; 146 GCTracer* tracer_;
138 ScopeId scope_; 147 ScopeId scope_;
139 double start_time_; 148 double start_time_;
(...skipping 50 matching lines...)
190 // Total amount of space either wasted or contained in one of free lists 199 // Total amount of space either wasted or contained in one of free lists
191 // before the current GC. 200 // before the current GC.
192 intptr_t start_holes_size; 201 intptr_t start_holes_size;
193 202
194 // Total amount of space either wasted or contained in one of free lists 203 // Total amount of space either wasted or contained in one of free lists
195 // after the current GC. 204 // after the current GC.
196 intptr_t end_holes_size; 205 intptr_t end_holes_size;
197 206
198 // Size of new space objects in constructor. 207 // Size of new space objects in constructor.
199 intptr_t new_space_object_size; 208 intptr_t new_space_object_size;
200 // Size of survived new space objects in desctructor. 209 // Size of survived new space objects in destructor.
201 intptr_t survived_new_space_object_size; 210 intptr_t survived_new_space_object_size;
202 211
203 // Number of incremental marking steps since creation of tracer. 212 // Number of incremental marking steps since creation of tracer.
204 // (value at start of event) 213 // (value at start of event)
205 int cumulative_incremental_marking_steps; 214 int cumulative_incremental_marking_steps;
206 215
207 // Incremental marking steps since 216 // Incremental marking steps since
208 // - last event for SCAVENGER events 217 // - last event for SCAVENGER events
209 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR 218 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR
210 // events 219 // events
(...skipping 21 matching lines...)
232 // Cumulative pure duration of incremental marking steps since creation of 241 // Cumulative pure duration of incremental marking steps since creation of
233 // tracer. (value at start of event) 242 // tracer. (value at start of event)
234 double cumulative_pure_incremental_marking_duration; 243 double cumulative_pure_incremental_marking_duration;
235 244
236 // Duration of pure incremental marking steps since 245 // Duration of pure incremental marking steps since
237 // - last event for SCAVENGER events 246 // - last event for SCAVENGER events
238 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR 247 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR
239 // events 248 // events
240 double pure_incremental_marking_duration; 249 double pure_incremental_marking_duration;
241 250
242 // Longest incremental marking step since start of marking. 251 // Longest incremental marking step since start of marking (start of event).
243 // (value at start of event)
244 double longest_incremental_marking_step; 252 double longest_incremental_marking_step;
245 253
254 // Number of incremental marking finalization steps since creation of
255 // tracer.
256 int cumulative_incremental_marking_finalization_steps;
Michael Lippautz 2016/08/22 12:40:06 Similar to incremental marking, we keep track of f
257
258 // Cumulative pure duration of incremental marking steps since creation of
259 // tracer. (value at start of event)
260 double cumulative_incremental_marking_finalizaton_duration;
261
262 // Longest incremental marking finalization step since start of marking
263 // (start of event).
264 double longest_incremental_marking_finalization_step;
265
266 // Incremental marking finalization steps since
267 // - last event for SCAVENGER events
268 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR
269 // events
270 int incremental_marking_finalizaton_steps;
271
272 // Duration of incremental marking finalization steps since
273 // - last event for SCAVENGER events
274 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR
275 // events
276 double incremental_marking_finalization_duration;
277
278 double cumulative_incremental_scopes[Scope::NUMBER_OF_INCREMENTAL_SCOPES];
279
246 // Amounts of time spent in different scopes during GC. 280 // Amounts of time spent in different scopes during GC.
247 double scopes[Scope::NUMBER_OF_SCOPES]; 281 double scopes[Scope::NUMBER_OF_SCOPES];
248 }; 282 };
249 283
250 static const int kThroughputTimeFrameMs = 5000; 284 static const int kThroughputTimeFrameMs = 5000;
251 285
252 explicit GCTracer(Heap* heap); 286 explicit GCTracer(Heap* heap);
253 287
254 // Start collecting data. 288 // Start collecting data.
255 void Start(GarbageCollector collector, const char* gc_reason, 289 void Start(GarbageCollector collector, const char* gc_reason,
(...skipping 192 matching lines...)
448 // creation of tracer. 482 // creation of tracer.
449 double cumulative_incremental_marking_finalization_duration_; 483 double cumulative_incremental_marking_finalization_duration_;
450 484
451 // Longest incremental marking finalization step since start of marking. 485 // Longest incremental marking finalization step since start of marking.
452 double longest_incremental_marking_finalization_step_; 486 double longest_incremental_marking_finalization_step_;
453 487
454 // Total marking time. 488 // Total marking time.
455 // This timer is precise when run with --print-cumulative-gc-stat 489 // This timer is precise when run with --print-cumulative-gc-stat
456 double cumulative_marking_duration_; 490 double cumulative_marking_duration_;
457 491
492 // Cumulative duration of incremental marking scopes since the creation of
493 // the tracer.
494 double cumulative_incremental_scopes_[Scope::NUMBER_OF_INCREMENTAL_SCOPES];
495
458 // Total sweeping time on the main thread. 496 // Total sweeping time on the main thread.
459 // This timer is precise when run with --print-cumulative-gc-stat 497 // This timer is precise when run with --print-cumulative-gc-stat
460 // TODO(hpayer): Account for sweeping time on sweeper threads. Add a 498 // TODO(hpayer): Account for sweeping time on sweeper threads. Add a
461 // different field for that. 499 // different field for that.
462 // TODO(hpayer): This timer right now just holds the sweeping time 500 // TODO(hpayer): This timer right now just holds the sweeping time
463 // of the initial atomic sweeping pause. Make sure that it accumulates 501 // of the initial atomic sweeping pause. Make sure that it accumulates
464 // all sweeping operations performed on the main thread. 502 // all sweeping operations performed on the main thread.
465 double cumulative_sweeping_duration_; 503 double cumulative_sweeping_duration_;
466 504
467 // Timestamp and allocation counter at the last sampled allocation event. 505 // Timestamp and allocation counter at the last sampled allocation event.
(...skipping 24 matching lines...)
492 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_; 530 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_;
493 RingBuffer<double> recorded_context_disposal_times_; 531 RingBuffer<double> recorded_context_disposal_times_;
494 RingBuffer<double> recorded_survival_ratios_; 532 RingBuffer<double> recorded_survival_ratios_;
495 533
496 DISALLOW_COPY_AND_ASSIGN(GCTracer); 534 DISALLOW_COPY_AND_ASSIGN(GCTracer);
497 }; 535 };
498 } // namespace internal 536 } // namespace internal
499 } // namespace v8 537 } // namespace v8
500 538
501 #endif // V8_HEAP_GC_TRACER_H_ 539 #endif // V8_HEAP_GC_TRACER_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/gc-tracer.cc » ('j') | src/heap/gc-tracer.cc » ('J')

Powered by Google App Engine