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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // Default constructor leaves the event uninitialized. | 158 // Default constructor leaves the event uninitialized. |
159 ContextDisposalEvent() {} | 159 ContextDisposalEvent() {} |
160 | 160 |
161 explicit ContextDisposalEvent(double time); | 161 explicit ContextDisposalEvent(double time); |
162 | 162 |
163 // Time when context disposal event happened. | 163 // Time when context disposal event happened. |
164 double time_; | 164 double time_; |
165 }; | 165 }; |
166 | 166 |
167 | 167 |
168 class PromotionEvent { | 168 class SurvivalEvent { |
169 public: | 169 public: |
170 // Default constructor leaves the event uninitialized. | 170 // Default constructor leaves the event uninitialized. |
171 PromotionEvent() {} | 171 SurvivalEvent() {} |
172 | 172 |
173 explicit PromotionEvent(double promotion_ratio); | 173 explicit SurvivalEvent(double survival_ratio); |
174 | 174 |
175 double promotion_ratio_; | 175 double promotion_ratio_; |
176 }; | 176 }; |
177 | 177 |
178 | 178 |
179 class Event { | 179 class Event { |
180 public: | 180 public: |
181 enum Type { | 181 enum Type { |
182 SCAVENGER = 0, | 182 SCAVENGER = 0, |
183 MARK_COMPACTOR = 1, | 183 MARK_COMPACTOR = 1, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 static const size_t kRingBufferMaxSize = 10; | 278 static const size_t kRingBufferMaxSize = 10; |
279 | 279 |
280 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; | 280 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; |
281 | 281 |
282 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; | 282 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; |
283 | 283 |
284 typedef RingBuffer<ContextDisposalEvent, kRingBufferMaxSize> | 284 typedef RingBuffer<ContextDisposalEvent, kRingBufferMaxSize> |
285 ContextDisposalEventBuffer; | 285 ContextDisposalEventBuffer; |
286 | 286 |
287 typedef RingBuffer<PromotionEvent, kRingBufferMaxSize> PromotionEventBuffer; | 287 typedef RingBuffer<SurvivalEvent, kRingBufferMaxSize> SurvivalEventBuffer; |
288 | 288 |
289 explicit GCTracer(Heap* heap); | 289 explicit GCTracer(Heap* heap); |
290 | 290 |
291 // Start collecting data. | 291 // Start collecting data. |
292 void Start(GarbageCollector collector, const char* gc_reason, | 292 void Start(GarbageCollector collector, const char* gc_reason, |
293 const char* collector_reason); | 293 const char* collector_reason); |
294 | 294 |
295 // Stop collecting data and print results. | 295 // Stop collecting data and print results. |
296 void Stop(GarbageCollector collector); | 296 void Stop(GarbageCollector collector); |
297 | 297 |
298 // Log an allocation throughput event. | 298 // Log an allocation throughput event. |
299 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); | 299 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); |
300 | 300 |
301 void AddContextDisposalTime(double time); | 301 void AddContextDisposalTime(double time); |
302 | 302 |
303 void AddPromotionRatio(double promotion_ratio); | 303 void AddSurvivalRatio(double survival_ratio); |
304 | 304 |
305 // Log an incremental marking step. | 305 // Log an incremental marking step. |
306 void AddIncrementalMarkingStep(double duration, intptr_t bytes); | 306 void AddIncrementalMarkingStep(double duration, intptr_t bytes); |
307 | 307 |
308 // Log time spent in marking. | 308 // Log time spent in marking. |
309 void AddMarkingTime(double duration) { | 309 void AddMarkingTime(double duration) { |
310 cumulative_marking_duration_ += duration; | 310 cumulative_marking_duration_ += duration; |
311 } | 311 } |
312 | 312 |
313 // Time spent in marking. | 313 // Time spent in marking. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // Allocation throughput in the new space in bytes/millisecond. | 381 // Allocation throughput in the new space in bytes/millisecond. |
382 // Returns 0 if no events have been recorded. | 382 // Returns 0 if no events have been recorded. |
383 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; | 383 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; |
384 | 384 |
385 // Computes the context disposal rate in milliseconds. It takes the time | 385 // Computes the context disposal rate in milliseconds. It takes the time |
386 // frame of the first recorded context disposal to the current time and | 386 // frame of the first recorded context disposal to the current time and |
387 // divides it by the number of recorded events. | 387 // divides it by the number of recorded events. |
388 // Returns 0 if no events have been recorded. | 388 // Returns 0 if no events have been recorded. |
389 double ContextDisposalRateInMilliseconds() const; | 389 double ContextDisposalRateInMilliseconds() const; |
390 | 390 |
391 // Computes the average promotion ratio based on the last recorded promotion | 391 // Computes the average survival ratio based on the last recorded survival |
392 // events. | 392 // events. |
393 // Returns 0 if no events have been recorded. | 393 // Returns 0 if no events have been recorded. |
394 double AveragePromotionRatio() const; | 394 double AverageSurvivalRatio() const; |
395 | 395 |
396 // Returns true if at least one survival event was recorded. | 396 // Returns true if at least one survival event was recorded. |
397 bool SurvivalEventsRecorded() const; | 397 bool SurvivalEventsRecorded() const; |
398 | 398 |
399 // Discard all recorded survival events. | 399 // Discard all recorded survival events. |
400 void ResetSurvivalEvents(); | 400 void ResetSurvivalEvents(); |
401 | 401 |
402 private: | 402 private: |
403 // Print one detailed trace line in name=value format. | 403 // Print one detailed trace line in name=value format. |
404 // TODO(ernstm): Move to Heap. | 404 // TODO(ernstm): Move to Heap. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 // RingBuffers for INCREMENTAL_MARK_COMPACTOR events. | 446 // RingBuffers for INCREMENTAL_MARK_COMPACTOR events. |
447 EventBuffer incremental_mark_compactor_events_; | 447 EventBuffer incremental_mark_compactor_events_; |
448 | 448 |
449 // RingBuffer for allocation events. | 449 // RingBuffer for allocation events. |
450 AllocationEventBuffer allocation_events_; | 450 AllocationEventBuffer allocation_events_; |
451 | 451 |
452 // RingBuffer for context disposal events. | 452 // RingBuffer for context disposal events. |
453 ContextDisposalEventBuffer context_disposal_events_; | 453 ContextDisposalEventBuffer context_disposal_events_; |
454 | 454 |
455 // RingBuffer for promotion events. | 455 // RingBuffer for survival events. |
456 PromotionEventBuffer promotion_events_; | 456 SurvivalEventBuffer survival_events_; |
457 | 457 |
458 // Cumulative number of incremental marking steps since creation of tracer. | 458 // Cumulative number of incremental marking steps since creation of tracer. |
459 int cumulative_incremental_marking_steps_; | 459 int cumulative_incremental_marking_steps_; |
460 | 460 |
461 // Cumulative size of incremental marking steps (in bytes) since creation of | 461 // Cumulative size of incremental marking steps (in bytes) since creation of |
462 // tracer. | 462 // tracer. |
463 intptr_t cumulative_incremental_marking_bytes_; | 463 intptr_t cumulative_incremental_marking_bytes_; |
464 | 464 |
465 // Cumulative duration of incremental marking steps since creation of tracer. | 465 // Cumulative duration of incremental marking steps since creation of tracer. |
466 double cumulative_incremental_marking_duration_; | 466 double cumulative_incremental_marking_duration_; |
(...skipping 24 matching lines...) Expand all Loading... |
491 | 491 |
492 // Counts how many tracers were started without stopping. | 492 // Counts how many tracers were started without stopping. |
493 int start_counter_; | 493 int start_counter_; |
494 | 494 |
495 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 495 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
496 }; | 496 }; |
497 } | 497 } |
498 } // namespace v8::internal | 498 } // namespace v8::internal |
499 | 499 |
500 #endif // V8_HEAP_GC_TRACER_H_ | 500 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |