OLD | NEW |
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/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 explicit ContextDisposalEvent(double time); | 154 explicit ContextDisposalEvent(double time); |
155 | 155 |
156 // Time when context disposal event happened. | 156 // Time when context disposal event happened. |
157 double time_; | 157 double time_; |
158 }; | 158 }; |
159 | 159 |
160 | 160 |
161 class Event { | 161 class Event { |
162 public: | 162 public: |
163 enum Type { | 163 enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 }; |
164 SCAVENGER = 0, | |
165 MARK_COMPACTOR = 1, | |
166 INCREMENTAL_MARK_COMPACTOR = 2, | |
167 START = 3 | |
168 }; | |
169 | 164 |
170 // Default constructor leaves the event uninitialized. | 165 // Default constructor leaves the event uninitialized. |
171 Event() {} | 166 Event() {} |
172 | 167 |
173 Event(Type type, const char* gc_reason, const char* collector_reason); | 168 Event(Type type, const char* gc_reason, const char* collector_reason); |
174 | 169 |
175 // Returns a string describing the event type. | 170 // Returns a string describing the event type. |
176 const char* TypeName(bool short_name) const; | 171 const char* TypeName(bool short_name) const; |
177 | 172 |
178 // Type of event | 173 // Type of event |
(...skipping 30 matching lines...) Expand all Loading... |
209 | 204 |
210 // Size of new space objects in constructor. | 205 // Size of new space objects in constructor. |
211 intptr_t new_space_object_size; | 206 intptr_t new_space_object_size; |
212 | 207 |
213 // Number of incremental marking steps since creation of tracer. | 208 // Number of incremental marking steps since creation of tracer. |
214 // (value at start of event) | 209 // (value at start of event) |
215 int cumulative_incremental_marking_steps; | 210 int cumulative_incremental_marking_steps; |
216 | 211 |
217 // Incremental marking steps since | 212 // Incremental marking steps since |
218 // - last event for SCAVENGER events | 213 // - last event for SCAVENGER events |
219 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR | 214 // - last MARK_COMPACTOR event for MARK_COMPACTOR events |
220 // events | |
221 int incremental_marking_steps; | 215 int incremental_marking_steps; |
222 | 216 |
223 // Bytes marked since creation of tracer (value at start of event). | 217 // Bytes marked since creation of tracer (value at start of event). |
224 intptr_t cumulative_incremental_marking_bytes; | 218 intptr_t cumulative_incremental_marking_bytes; |
225 | 219 |
226 // Bytes marked since | 220 // Bytes marked since |
227 // - last event for SCAVENGER events | 221 // - last event for SCAVENGER events |
228 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR | 222 // - last MARK_COMPACTOR event for MARK_COMPACTOR events |
229 // events | |
230 intptr_t incremental_marking_bytes; | 223 intptr_t incremental_marking_bytes; |
231 | 224 |
232 // Cumulative duration of incremental marking steps since creation of | 225 // Cumulative duration of incremental marking steps since creation of |
233 // tracer. (value at start of event) | 226 // tracer. (value at start of event) |
234 double cumulative_incremental_marking_duration; | 227 double cumulative_incremental_marking_duration; |
235 | 228 |
236 // Duration of incremental marking steps since | 229 // Duration of incremental marking steps since |
237 // - last event for SCAVENGER events | 230 // - last event for SCAVENGER events |
238 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR | 231 // - last MARK_COMPACTOR event for MARK_COMPACTOR events |
239 // events | |
240 double incremental_marking_duration; | 232 double incremental_marking_duration; |
241 | 233 |
242 // Cumulative pure duration of incremental marking steps since creation of | 234 // Cumulative pure duration of incremental marking steps since creation of |
243 // tracer. (value at start of event) | 235 // tracer. (value at start of event) |
244 double cumulative_pure_incremental_marking_duration; | 236 double cumulative_pure_incremental_marking_duration; |
245 | 237 |
246 // Duration of pure incremental marking steps since | 238 // Duration of pure incremental marking steps since |
247 // - last event for SCAVENGER events | 239 // - last event for SCAVENGER events |
248 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR | 240 // - last MARK_COMPACTOR event for MARK_COMPACTOR events |
249 // events | |
250 double pure_incremental_marking_duration; | 241 double pure_incremental_marking_duration; |
251 | 242 |
252 // Longest incremental marking step since start of marking. | 243 // Longest incremental marking step since start of marking. |
253 // (value at start of event) | 244 // (value at start of event) |
254 double longest_incremental_marking_step; | 245 double longest_incremental_marking_step; |
255 | 246 |
256 // Amounts of time spent in different scopes during GC. | 247 // Amounts of time spent in different scopes during GC. |
257 double scopes[Scope::NUMBER_OF_SCOPES]; | 248 double scopes[Scope::NUMBER_OF_SCOPES]; |
258 }; | 249 }; |
259 | 250 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 double MeanMarkCompactorDuration() const { | 309 double MeanMarkCompactorDuration() const { |
319 return MeanDuration(mark_compactor_events_); | 310 return MeanDuration(mark_compactor_events_); |
320 } | 311 } |
321 | 312 |
322 // Compute the max duration of the last mark compactor events. Return 0 if no | 313 // Compute the max duration of the last mark compactor events. Return 0 if no |
323 // events have been recorded. | 314 // events have been recorded. |
324 double MaxMarkCompactorDuration() const { | 315 double MaxMarkCompactorDuration() const { |
325 return MaxDuration(mark_compactor_events_); | 316 return MaxDuration(mark_compactor_events_); |
326 } | 317 } |
327 | 318 |
328 // Compute the mean duration of the last incremental mark compactor | |
329 // events. Returns 0 if no events have been recorded. | |
330 double MeanIncrementalMarkCompactorDuration() const { | |
331 return MeanDuration(incremental_mark_compactor_events_); | |
332 } | |
333 | |
334 // Compute the mean step duration of the last incremental marking round. | 319 // Compute the mean step duration of the last incremental marking round. |
335 // Returns 0 if no incremental marking round has been completed. | 320 // Returns 0 if no incremental marking round has been completed. |
336 double MeanIncrementalMarkingDuration() const; | 321 double MeanIncrementalMarkingDuration() const; |
337 | 322 |
338 // Compute the max step duration of the last incremental marking round. | 323 // Compute the max step duration of the last incremental marking round. |
339 // Returns 0 if no incremental marking round has been completed. | 324 // Returns 0 if no incremental marking round has been completed. |
340 double MaxIncrementalMarkingDuration() const; | 325 double MaxIncrementalMarkingDuration() const; |
341 | 326 |
342 // Compute the average incremental marking speed in bytes/millisecond. | 327 // Compute the average incremental marking speed in bytes/millisecond. |
343 // Returns 0 if no events have been recorded. | 328 // Returns 0 if no events have been recorded. |
344 intptr_t IncrementalMarkingSpeedInBytesPerMillisecond() const; | 329 intptr_t IncrementalMarkingSpeedInBytesPerMillisecond() const; |
345 | 330 |
346 // Compute the average scavenge speed in bytes/millisecond. | 331 // Compute the average scavenge speed in bytes/millisecond. |
347 // Returns 0 if no events have been recorded. | 332 // Returns 0 if no events have been recorded. |
348 intptr_t ScavengeSpeedInBytesPerMillisecond() const; | 333 intptr_t ScavengeSpeedInBytesPerMillisecond() const; |
349 | 334 |
350 // Compute the average mark-sweep speed in bytes/millisecond. | 335 // Compute the max mark-sweep speed in bytes/millisecond. |
351 // Returns 0 if no events have been recorded. | 336 // Returns 0 if no events have been recorded. |
352 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; | 337 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; |
353 | 338 |
354 // Compute the average incremental mark-sweep finalize speed in | |
355 // bytes/millisecond. | |
356 // Returns 0 if no events have been recorded. | |
357 intptr_t FinalIncrementalMarkCompactSpeedInBytesPerMillisecond() const; | |
358 | |
359 // Allocation throughput in the new space in bytes/millisecond. | 339 // Allocation throughput in the new space in bytes/millisecond. |
360 // Returns 0 if no events have been recorded. | 340 // Returns 0 if no events have been recorded. |
361 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; | 341 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; |
362 | 342 |
363 // Computes the context disposal rate in milliseconds. It takes the time | 343 // Computes the context disposal rate in milliseconds. It takes the time |
364 // frame of the first recorded context disposal to the current time and | 344 // frame of the first recorded context disposal to the current time and |
365 // divides it by the number of recorded events. | 345 // divides it by the number of recorded events. |
366 // Returns 0 if no events have been recorded. | 346 // Returns 0 if no events have been recorded. |
367 double ContextDisposalRateInMilliseconds() const; | 347 double ContextDisposalRateInMilliseconds() const; |
368 | 348 |
369 private: | 349 private: |
370 // Print one detailed trace line in name=value format. | 350 // Print one detailed trace line in name=value format. |
371 // TODO(ernstm): Move to Heap. | 351 // TODO(ernstm): Move to Heap. |
372 void PrintNVP() const; | 352 void PrintNVP() const; |
373 | 353 |
374 // Print one trace line. | 354 // Print one trace line. |
375 // TODO(ernstm): Move to Heap. | 355 // TODO(ernstm): Move to Heap. |
376 void Print() const; | 356 void Print() const; |
377 | 357 |
378 // Compute the mean duration of the events in the given ring buffer. | 358 // Compute the mean duration of the events in the given ring buffer. |
379 double MeanDuration(const EventBuffer& events) const; | 359 double MeanDuration(const EventBuffer& events) const; |
380 | 360 |
381 // Compute the max duration of the events in the given ring buffer. | 361 // Compute the max duration of the events in the given ring buffer. |
382 double MaxDuration(const EventBuffer& events) const; | 362 double MaxDuration(const EventBuffer& events) const; |
383 | 363 |
384 void ClearMarkCompactStatistics() { | |
385 cumulative_incremental_marking_steps_ = 0; | |
386 cumulative_incremental_marking_bytes_ = 0; | |
387 cumulative_incremental_marking_duration_ = 0; | |
388 cumulative_pure_incremental_marking_duration_ = 0; | |
389 longest_incremental_marking_step_ = 0; | |
390 cumulative_marking_duration_ = 0; | |
391 cumulative_sweeping_duration_ = 0; | |
392 } | |
393 | |
394 // Pointer to the heap that owns this tracer. | 364 // Pointer to the heap that owns this tracer. |
395 Heap* heap_; | 365 Heap* heap_; |
396 | 366 |
397 // Current tracer event. Populated during Start/Stop cycle. Valid after Stop() | 367 // Current tracer event. Populated during Start/Stop cycle. Valid after Stop() |
398 // has returned. | 368 // has returned. |
399 Event current_; | 369 Event current_; |
400 | 370 |
401 // Previous tracer event. | 371 // Previous tracer event. |
402 Event previous_; | 372 Event previous_; |
403 | 373 |
404 // Previous INCREMENTAL_MARK_COMPACTOR event. | 374 // Previous MARK_COMPACTOR event. |
405 Event previous_incremental_mark_compactor_event_; | 375 Event previous_mark_compactor_event_; |
406 | 376 |
407 // RingBuffers for SCAVENGER events. | 377 // RingBuffers for SCAVENGER events. |
408 EventBuffer scavenger_events_; | 378 EventBuffer scavenger_events_; |
409 | 379 |
410 // RingBuffers for MARK_COMPACTOR events. | 380 // RingBuffers for MARK_COMPACTOR events. |
411 EventBuffer mark_compactor_events_; | 381 EventBuffer mark_compactor_events_; |
412 | 382 |
413 // RingBuffers for INCREMENTAL_MARK_COMPACTOR events. | |
414 EventBuffer incremental_mark_compactor_events_; | |
415 | |
416 // RingBuffer for allocation events. | 383 // RingBuffer for allocation events. |
417 AllocationEventBuffer allocation_events_; | 384 AllocationEventBuffer allocation_events_; |
418 | 385 |
419 ContextDisposalEventBuffer context_disposal_events_; | 386 ContextDisposalEventBuffer context_disposal_events_; |
420 | 387 |
421 // Cumulative number of incremental marking steps since creation of tracer. | 388 // Cumulative number of incremental marking steps since creation of tracer. |
422 int cumulative_incremental_marking_steps_; | 389 int cumulative_incremental_marking_steps_; |
423 | 390 |
424 // Cumulative size of incremental marking steps (in bytes) since creation of | 391 // Cumulative size of incremental marking steps (in bytes) since creation of |
425 // tracer. | 392 // tracer. |
(...skipping 25 matching lines...) Expand all Loading... |
451 // Holds the new space top pointer recorded at the end of the last garbage | 418 // Holds the new space top pointer recorded at the end of the last garbage |
452 // collection. | 419 // collection. |
453 intptr_t new_space_top_after_gc_; | 420 intptr_t new_space_top_after_gc_; |
454 | 421 |
455 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 422 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
456 }; | 423 }; |
457 } | 424 } |
458 } // namespace v8::internal | 425 } // namespace v8::internal |
459 | 426 |
460 #endif // V8_HEAP_GC_TRACER_H_ | 427 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |