| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 GCTracer* tracer_; | 124 GCTracer* tracer_; |
| 125 ScopeId scope_; | 125 ScopeId scope_; |
| 126 double start_time_; | 126 double start_time_; |
| 127 | 127 |
| 128 DISALLOW_COPY_AND_ASSIGN(Scope); | 128 DISALLOW_COPY_AND_ASSIGN(Scope); |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 | 131 |
| 132 class AllocationEvent { |
| 133 public: |
| 134 // Default constructor leaves the event uninitialized. |
| 135 AllocationEvent() {} |
| 136 |
| 137 AllocationEvent(double duration, intptr_t allocation_in_bytes); |
| 138 |
| 139 // Time spent in the mutator during the end of the last garbage collection |
| 140 // to the beginning of the next garbage collection. |
| 141 double duration_; |
| 142 |
| 143 // Memory allocated in the new space during the end of the last garbage |
| 144 // collection to the beginning of the next garbage collection. |
| 145 intptr_t allocation_in_bytes_; |
| 146 }; |
| 147 |
| 132 class Event { | 148 class Event { |
| 133 public: | 149 public: |
| 134 enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 }; | 150 enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 }; |
| 135 | 151 |
| 136 // Default constructor leaves the event uninitialized. | 152 // Default constructor leaves the event uninitialized. |
| 137 Event() {} | 153 Event() {} |
| 138 | 154 |
| 139 Event(Type type, const char* gc_reason, const char* collector_reason); | 155 Event(Type type, const char* gc_reason, const char* collector_reason); |
| 140 | 156 |
| 141 // Returns a string describing the event type. | 157 // Returns a string describing the event type. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 double longest_incremental_marking_step; | 232 double longest_incremental_marking_step; |
| 217 | 233 |
| 218 // Amounts of time spent in different scopes during GC. | 234 // Amounts of time spent in different scopes during GC. |
| 219 double scopes[Scope::NUMBER_OF_SCOPES]; | 235 double scopes[Scope::NUMBER_OF_SCOPES]; |
| 220 }; | 236 }; |
| 221 | 237 |
| 222 static const int kRingBufferMaxSize = 10; | 238 static const int kRingBufferMaxSize = 10; |
| 223 | 239 |
| 224 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; | 240 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; |
| 225 | 241 |
| 242 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; |
| 243 |
| 226 explicit GCTracer(Heap* heap); | 244 explicit GCTracer(Heap* heap); |
| 227 | 245 |
| 228 // Start collecting data. | 246 // Start collecting data. |
| 229 void Start(GarbageCollector collector, const char* gc_reason, | 247 void Start(GarbageCollector collector, const char* gc_reason, |
| 230 const char* collector_reason); | 248 const char* collector_reason); |
| 231 | 249 |
| 232 // Stop collecting data and print results. | 250 // Stop collecting data and print results. |
| 233 void Stop(); | 251 void Stop(); |
| 234 | 252 |
| 253 // Log an allocation throughput event. |
| 254 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); |
| 255 |
| 235 // Log an incremental marking step. | 256 // Log an incremental marking step. |
| 236 void AddIncrementalMarkingStep(double duration, intptr_t bytes); | 257 void AddIncrementalMarkingStep(double duration, intptr_t bytes); |
| 237 | 258 |
| 238 // Log time spent in marking. | 259 // Log time spent in marking. |
| 239 void AddMarkingTime(double duration) { | 260 void AddMarkingTime(double duration) { |
| 240 cumulative_marking_duration_ += duration; | 261 cumulative_marking_duration_ += duration; |
| 241 } | 262 } |
| 242 | 263 |
| 243 // Time spent in marking. | 264 // Time spent in marking. |
| 244 double cumulative_marking_duration() const { | 265 double cumulative_marking_duration() const { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 intptr_t IncrementalMarkingSpeedInBytesPerMillisecond() const; | 311 intptr_t IncrementalMarkingSpeedInBytesPerMillisecond() const; |
| 291 | 312 |
| 292 // Compute the average scavenge speed in bytes/millisecond. | 313 // Compute the average scavenge speed in bytes/millisecond. |
| 293 // Returns 0 if no events have been recorded. | 314 // Returns 0 if no events have been recorded. |
| 294 intptr_t ScavengeSpeedInBytesPerMillisecond() const; | 315 intptr_t ScavengeSpeedInBytesPerMillisecond() const; |
| 295 | 316 |
| 296 // Compute the max mark-sweep speed in bytes/millisecond. | 317 // Compute the max mark-sweep speed in bytes/millisecond. |
| 297 // Returns 0 if no events have been recorded. | 318 // Returns 0 if no events have been recorded. |
| 298 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; | 319 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; |
| 299 | 320 |
| 321 // Allocation throughput in the new space in bytes/millisecond. |
| 322 // Returns 0 if no events have been recorded. |
| 323 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; |
| 324 |
| 300 private: | 325 private: |
| 301 // Print one detailed trace line in name=value format. | 326 // Print one detailed trace line in name=value format. |
| 302 // TODO(ernstm): Move to Heap. | 327 // TODO(ernstm): Move to Heap. |
| 303 void PrintNVP() const; | 328 void PrintNVP() const; |
| 304 | 329 |
| 305 // Print one trace line. | 330 // Print one trace line. |
| 306 // TODO(ernstm): Move to Heap. | 331 // TODO(ernstm): Move to Heap. |
| 307 void Print() const; | 332 void Print() const; |
| 308 | 333 |
| 309 // Compute the mean duration of the events in the given ring buffer. | 334 // Compute the mean duration of the events in the given ring buffer. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 324 | 349 |
| 325 // Previous MARK_COMPACTOR event. | 350 // Previous MARK_COMPACTOR event. |
| 326 Event previous_mark_compactor_event_; | 351 Event previous_mark_compactor_event_; |
| 327 | 352 |
| 328 // RingBuffers for SCAVENGER events. | 353 // RingBuffers for SCAVENGER events. |
| 329 EventBuffer scavenger_events_; | 354 EventBuffer scavenger_events_; |
| 330 | 355 |
| 331 // RingBuffers for MARK_COMPACTOR events. | 356 // RingBuffers for MARK_COMPACTOR events. |
| 332 EventBuffer mark_compactor_events_; | 357 EventBuffer mark_compactor_events_; |
| 333 | 358 |
| 359 // RingBuffer for allocation events. |
| 360 AllocationEventBuffer allocation_events_; |
| 361 |
| 334 // Cumulative number of incremental marking steps since creation of tracer. | 362 // Cumulative number of incremental marking steps since creation of tracer. |
| 335 int cumulative_incremental_marking_steps_; | 363 int cumulative_incremental_marking_steps_; |
| 336 | 364 |
| 337 // Cumulative size of incremental marking steps (in bytes) since creation of | 365 // Cumulative size of incremental marking steps (in bytes) since creation of |
| 338 // tracer. | 366 // tracer. |
| 339 intptr_t cumulative_incremental_marking_bytes_; | 367 intptr_t cumulative_incremental_marking_bytes_; |
| 340 | 368 |
| 341 // Cumulative duration of incremental marking steps since creation of tracer. | 369 // Cumulative duration of incremental marking steps since creation of tracer. |
| 342 double cumulative_incremental_marking_duration_; | 370 double cumulative_incremental_marking_duration_; |
| 343 | 371 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 354 | 382 |
| 355 // Total sweeping time on the main thread. | 383 // Total sweeping time on the main thread. |
| 356 // This timer is precise when run with --print-cumulative-gc-stat | 384 // This timer is precise when run with --print-cumulative-gc-stat |
| 357 // TODO(hpayer): Account for sweeping time on sweeper threads. Add a | 385 // TODO(hpayer): Account for sweeping time on sweeper threads. Add a |
| 358 // different field for that. | 386 // different field for that. |
| 359 // TODO(hpayer): This timer right now just holds the sweeping time | 387 // TODO(hpayer): This timer right now just holds the sweeping time |
| 360 // of the initial atomic sweeping pause. Make sure that it accumulates | 388 // of the initial atomic sweeping pause. Make sure that it accumulates |
| 361 // all sweeping operations performed on the main thread. | 389 // all sweeping operations performed on the main thread. |
| 362 double cumulative_sweeping_duration_; | 390 double cumulative_sweeping_duration_; |
| 363 | 391 |
| 392 // Holds the new space top pointer recorded at the end of the last garbage |
| 393 // collection. |
| 394 intptr_t new_space_top_after_gc_; |
| 395 |
| 364 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 396 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
| 365 }; | 397 }; |
| 366 } | 398 } |
| 367 } // namespace v8::internal | 399 } // namespace v8::internal |
| 368 | 400 |
| 369 #endif // V8_HEAP_GC_TRACER_H_ | 401 #endif // V8_HEAP_GC_TRACER_H_ |
| OLD | NEW |