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