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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // Default constructor leaves the event uninitialized. | 152 // Default constructor leaves the event uninitialized. |
153 ContextDisposalEvent() {} | 153 ContextDisposalEvent() {} |
154 | 154 |
155 explicit ContextDisposalEvent(double time); | 155 explicit ContextDisposalEvent(double time); |
156 | 156 |
157 // Time when context disposal event happened. | 157 // Time when context disposal event happened. |
158 double time_; | 158 double time_; |
159 }; | 159 }; |
160 | 160 |
161 | 161 |
162 class SurvivalEvent { | |
163 public: | |
164 // Default constructor leaves the event uninitialized. | |
165 SurvivalEvent() {} | |
166 | |
167 explicit SurvivalEvent(double survival_rate); | |
168 | |
169 double survival_rate_; | |
170 }; | |
171 | |
172 | |
173 class Event { | 162 class Event { |
174 public: | 163 public: |
175 enum Type { | 164 enum Type { |
176 SCAVENGER = 0, | 165 SCAVENGER = 0, |
177 MARK_COMPACTOR = 1, | 166 MARK_COMPACTOR = 1, |
178 INCREMENTAL_MARK_COMPACTOR = 2, | 167 INCREMENTAL_MARK_COMPACTOR = 2, |
179 START = 3 | 168 START = 3 |
180 }; | 169 }; |
181 | 170 |
182 // Default constructor leaves the event uninitialized. | 171 // Default constructor leaves the event uninitialized. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 260 |
272 static const size_t kRingBufferMaxSize = 10; | 261 static const size_t kRingBufferMaxSize = 10; |
273 | 262 |
274 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; | 263 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; |
275 | 264 |
276 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; | 265 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; |
277 | 266 |
278 typedef RingBuffer<ContextDisposalEvent, kRingBufferMaxSize> | 267 typedef RingBuffer<ContextDisposalEvent, kRingBufferMaxSize> |
279 ContextDisposalEventBuffer; | 268 ContextDisposalEventBuffer; |
280 | 269 |
281 typedef RingBuffer<SurvivalEvent, kRingBufferMaxSize> SurvivalEventBuffer; | |
282 | |
283 explicit GCTracer(Heap* heap); | 270 explicit GCTracer(Heap* heap); |
284 | 271 |
285 // Start collecting data. | 272 // Start collecting data. |
286 void Start(GarbageCollector collector, const char* gc_reason, | 273 void Start(GarbageCollector collector, const char* gc_reason, |
287 const char* collector_reason); | 274 const char* collector_reason); |
288 | 275 |
289 // Stop collecting data and print results. | 276 // Stop collecting data and print results. |
290 void Stop(GarbageCollector collector); | 277 void Stop(GarbageCollector collector); |
291 | 278 |
292 // Log an allocation throughput event. | 279 // Log an allocation throughput event. |
293 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); | 280 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); |
294 | 281 |
295 void AddContextDisposalTime(double time); | 282 void AddContextDisposalTime(double time); |
296 | 283 |
297 void AddSurvivalRate(double survival_rate); | |
298 | |
299 // Log an incremental marking step. | 284 // Log an incremental marking step. |
300 void AddIncrementalMarkingStep(double duration, intptr_t bytes); | 285 void AddIncrementalMarkingStep(double duration, intptr_t bytes); |
301 | 286 |
302 // Log time spent in marking. | 287 // Log time spent in marking. |
303 void AddMarkingTime(double duration) { | 288 void AddMarkingTime(double duration) { |
304 cumulative_marking_duration_ += duration; | 289 cumulative_marking_duration_ += duration; |
305 } | 290 } |
306 | 291 |
307 // Time spent in marking. | 292 // Time spent in marking. |
308 double cumulative_marking_duration() const { | 293 double cumulative_marking_duration() const { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // Allocation throughput in the new space in bytes/millisecond. | 360 // Allocation throughput in the new space in bytes/millisecond. |
376 // Returns 0 if no events have been recorded. | 361 // Returns 0 if no events have been recorded. |
377 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; | 362 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; |
378 | 363 |
379 // Computes the context disposal rate in milliseconds. It takes the time | 364 // Computes the context disposal rate in milliseconds. It takes the time |
380 // frame of the first recorded context disposal to the current time and | 365 // frame of the first recorded context disposal to the current time and |
381 // divides it by the number of recorded events. | 366 // divides it by the number of recorded events. |
382 // Returns 0 if no events have been recorded. | 367 // Returns 0 if no events have been recorded. |
383 double ContextDisposalRateInMilliseconds() const; | 368 double ContextDisposalRateInMilliseconds() const; |
384 | 369 |
385 // Computes the average survival rate based on the last recorded survival | |
386 // events. | |
387 // Returns 0 if no events have been recorded. | |
388 double AverageSurvivalRate() const; | |
389 | |
390 // Returns true if at least one survival event was recorded. | |
391 bool SurvivalEventsRecorded() const; | |
392 | |
393 private: | 370 private: |
394 // Print one detailed trace line in name=value format. | 371 // Print one detailed trace line in name=value format. |
395 // TODO(ernstm): Move to Heap. | 372 // TODO(ernstm): Move to Heap. |
396 void PrintNVP() const; | 373 void PrintNVP() const; |
397 | 374 |
398 // Print one trace line. | 375 // Print one trace line. |
399 // TODO(ernstm): Move to Heap. | 376 // TODO(ernstm): Move to Heap. |
400 void Print() const; | 377 void Print() const; |
401 | 378 |
402 // Compute the mean duration of the events in the given ring buffer. | 379 // Compute the mean duration of the events in the given ring buffer. |
(...skipping 30 matching lines...) Expand all Loading... |
433 | 410 |
434 // RingBuffers for MARK_COMPACTOR events. | 411 // RingBuffers for MARK_COMPACTOR events. |
435 EventBuffer mark_compactor_events_; | 412 EventBuffer mark_compactor_events_; |
436 | 413 |
437 // RingBuffers for INCREMENTAL_MARK_COMPACTOR events. | 414 // RingBuffers for INCREMENTAL_MARK_COMPACTOR events. |
438 EventBuffer incremental_mark_compactor_events_; | 415 EventBuffer incremental_mark_compactor_events_; |
439 | 416 |
440 // RingBuffer for allocation events. | 417 // RingBuffer for allocation events. |
441 AllocationEventBuffer allocation_events_; | 418 AllocationEventBuffer allocation_events_; |
442 | 419 |
443 // RingBuffer for context disposal events. | |
444 ContextDisposalEventBuffer context_disposal_events_; | 420 ContextDisposalEventBuffer context_disposal_events_; |
445 | 421 |
446 // RingBuffer for survival events. | |
447 SurvivalEventBuffer survival_events_; | |
448 | |
449 // Cumulative number of incremental marking steps since creation of tracer. | 422 // Cumulative number of incremental marking steps since creation of tracer. |
450 int cumulative_incremental_marking_steps_; | 423 int cumulative_incremental_marking_steps_; |
451 | 424 |
452 // Cumulative size of incremental marking steps (in bytes) since creation of | 425 // Cumulative size of incremental marking steps (in bytes) since creation of |
453 // tracer. | 426 // tracer. |
454 intptr_t cumulative_incremental_marking_bytes_; | 427 intptr_t cumulative_incremental_marking_bytes_; |
455 | 428 |
456 // Cumulative duration of incremental marking steps since creation of tracer. | 429 // Cumulative duration of incremental marking steps since creation of tracer. |
457 double cumulative_incremental_marking_duration_; | 430 double cumulative_incremental_marking_duration_; |
458 | 431 |
(...skipping 23 matching lines...) Expand all Loading... |
482 | 455 |
483 // Counts how many tracers were started without stopping. | 456 // Counts how many tracers were started without stopping. |
484 int start_counter_; | 457 int start_counter_; |
485 | 458 |
486 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 459 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
487 }; | 460 }; |
488 } | 461 } |
489 } // namespace v8::internal | 462 } // namespace v8::internal |
490 | 463 |
491 #endif // V8_HEAP_GC_TRACER_H_ | 464 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |