| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 // Time spent in the mutator during the end of the last garbage collection | 139 // Time spent in the mutator during the end of the last garbage collection |
| 140 // to the beginning of the next garbage collection. | 140 // to the beginning of the next garbage collection. |
| 141 double duration_; | 141 double duration_; |
| 142 | 142 |
| 143 // Memory allocated in the new space during the end of the last garbage | 143 // Memory allocated in the new space during the end of the last garbage |
| 144 // collection to the beginning of the next garbage collection. | 144 // collection to the beginning of the next garbage collection. |
| 145 intptr_t allocation_in_bytes_; | 145 intptr_t allocation_in_bytes_; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 |
| 149 class ContextDisposalEvent { |
| 150 public: |
| 151 // Default constructor leaves the event uninitialized. |
| 152 ContextDisposalEvent() {} |
| 153 |
| 154 explicit ContextDisposalEvent(double time); |
| 155 |
| 156 // Time when context disposal event happened. |
| 157 double time_; |
| 158 }; |
| 159 |
| 160 |
| 148 class Event { | 161 class Event { |
| 149 public: | 162 public: |
| 150 enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 }; | 163 enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 }; |
| 151 | 164 |
| 152 // Default constructor leaves the event uninitialized. | 165 // Default constructor leaves the event uninitialized. |
| 153 Event() {} | 166 Event() {} |
| 154 | 167 |
| 155 Event(Type type, const char* gc_reason, const char* collector_reason); | 168 Event(Type type, const char* gc_reason, const char* collector_reason); |
| 156 | 169 |
| 157 // Returns a string describing the event type. | 170 // Returns a string describing the event type. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // Amounts of time spent in different scopes during GC. | 247 // Amounts of time spent in different scopes during GC. |
| 235 double scopes[Scope::NUMBER_OF_SCOPES]; | 248 double scopes[Scope::NUMBER_OF_SCOPES]; |
| 236 }; | 249 }; |
| 237 | 250 |
| 238 static const int kRingBufferMaxSize = 10; | 251 static const int kRingBufferMaxSize = 10; |
| 239 | 252 |
| 240 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; | 253 typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer; |
| 241 | 254 |
| 242 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; | 255 typedef RingBuffer<AllocationEvent, kRingBufferMaxSize> AllocationEventBuffer; |
| 243 | 256 |
| 257 typedef RingBuffer<ContextDisposalEvent, kRingBufferMaxSize> |
| 258 ContextDisposalEventBuffer; |
| 259 |
| 244 explicit GCTracer(Heap* heap); | 260 explicit GCTracer(Heap* heap); |
| 245 | 261 |
| 246 // Start collecting data. | 262 // Start collecting data. |
| 247 void Start(GarbageCollector collector, const char* gc_reason, | 263 void Start(GarbageCollector collector, const char* gc_reason, |
| 248 const char* collector_reason); | 264 const char* collector_reason); |
| 249 | 265 |
| 250 // Stop collecting data and print results. | 266 // Stop collecting data and print results. |
| 251 void Stop(); | 267 void Stop(); |
| 252 | 268 |
| 253 // Log an allocation throughput event. | 269 // Log an allocation throughput event. |
| 254 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); | 270 void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); |
| 255 | 271 |
| 272 void AddContextDisposalTime(double time); |
| 273 |
| 256 // Log an incremental marking step. | 274 // Log an incremental marking step. |
| 257 void AddIncrementalMarkingStep(double duration, intptr_t bytes); | 275 void AddIncrementalMarkingStep(double duration, intptr_t bytes); |
| 258 | 276 |
| 259 // Log time spent in marking. | 277 // Log time spent in marking. |
| 260 void AddMarkingTime(double duration) { | 278 void AddMarkingTime(double duration) { |
| 261 cumulative_marking_duration_ += duration; | 279 cumulative_marking_duration_ += duration; |
| 262 } | 280 } |
| 263 | 281 |
| 264 // Time spent in marking. | 282 // Time spent in marking. |
| 265 double cumulative_marking_duration() const { | 283 double cumulative_marking_duration() const { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 intptr_t ScavengeSpeedInBytesPerMillisecond() const; | 333 intptr_t ScavengeSpeedInBytesPerMillisecond() const; |
| 316 | 334 |
| 317 // Compute the max mark-sweep speed in bytes/millisecond. | 335 // Compute the max mark-sweep speed in bytes/millisecond. |
| 318 // Returns 0 if no events have been recorded. | 336 // Returns 0 if no events have been recorded. |
| 319 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; | 337 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; |
| 320 | 338 |
| 321 // Allocation throughput in the new space in bytes/millisecond. | 339 // Allocation throughput in the new space in bytes/millisecond. |
| 322 // Returns 0 if no events have been recorded. | 340 // Returns 0 if no events have been recorded. |
| 323 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; | 341 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; |
| 324 | 342 |
| 343 // Computes the context disposal rate in milliseconds. It takes the time |
| 344 // frame of the first and last context disposal event and devides it by the |
| 345 // number of recorded events. |
| 346 // Returns 0 if no events have been recorded. |
| 347 double ContextDisposalRateInMilliseconds() const; |
| 348 |
| 325 private: | 349 private: |
| 326 // Print one detailed trace line in name=value format. | 350 // Print one detailed trace line in name=value format. |
| 327 // TODO(ernstm): Move to Heap. | 351 // TODO(ernstm): Move to Heap. |
| 328 void PrintNVP() const; | 352 void PrintNVP() const; |
| 329 | 353 |
| 330 // Print one trace line. | 354 // Print one trace line. |
| 331 // TODO(ernstm): Move to Heap. | 355 // TODO(ernstm): Move to Heap. |
| 332 void Print() const; | 356 void Print() const; |
| 333 | 357 |
| 334 // 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. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 352 | 376 |
| 353 // RingBuffers for SCAVENGER events. | 377 // RingBuffers for SCAVENGER events. |
| 354 EventBuffer scavenger_events_; | 378 EventBuffer scavenger_events_; |
| 355 | 379 |
| 356 // RingBuffers for MARK_COMPACTOR events. | 380 // RingBuffers for MARK_COMPACTOR events. |
| 357 EventBuffer mark_compactor_events_; | 381 EventBuffer mark_compactor_events_; |
| 358 | 382 |
| 359 // RingBuffer for allocation events. | 383 // RingBuffer for allocation events. |
| 360 AllocationEventBuffer allocation_events_; | 384 AllocationEventBuffer allocation_events_; |
| 361 | 385 |
| 386 ContextDisposalEventBuffer context_disposal_events_; |
| 387 |
| 362 // Cumulative number of incremental marking steps since creation of tracer. | 388 // Cumulative number of incremental marking steps since creation of tracer. |
| 363 int cumulative_incremental_marking_steps_; | 389 int cumulative_incremental_marking_steps_; |
| 364 | 390 |
| 365 // Cumulative size of incremental marking steps (in bytes) since creation of | 391 // Cumulative size of incremental marking steps (in bytes) since creation of |
| 366 // tracer. | 392 // tracer. |
| 367 intptr_t cumulative_incremental_marking_bytes_; | 393 intptr_t cumulative_incremental_marking_bytes_; |
| 368 | 394 |
| 369 // Cumulative duration of incremental marking steps since creation of tracer. | 395 // Cumulative duration of incremental marking steps since creation of tracer. |
| 370 double cumulative_incremental_marking_duration_; | 396 double cumulative_incremental_marking_duration_; |
| 371 | 397 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 392 // 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 |
| 393 // collection. | 419 // collection. |
| 394 intptr_t new_space_top_after_gc_; | 420 intptr_t new_space_top_after_gc_; |
| 395 | 421 |
| 396 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 422 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
| 397 }; | 423 }; |
| 398 } | 424 } |
| 399 } // namespace v8::internal | 425 } // namespace v8::internal |
| 400 | 426 |
| 401 #endif // V8_HEAP_GC_TRACER_H_ | 427 #endif // V8_HEAP_GC_TRACER_H_ |
| OLD | NEW |