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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 explicit ContextDisposalEvent(double time); | 154 explicit ContextDisposalEvent(double time); |
155 | 155 |
156 // Time when context disposal event happened. | 156 // Time when context disposal event happened. |
157 double time_; | 157 double time_; |
158 }; | 158 }; |
159 | 159 |
160 | 160 |
161 class Event { | 161 class Event { |
162 public: | 162 public: |
163 enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 }; | 163 enum Type { |
| 164 SCAVENGER = 0, |
| 165 MARK_COMPACTOR = 1, |
| 166 INCREMENTAL_MARK_COMPACTOR = 2, |
| 167 START = 3 |
| 168 }; |
164 | 169 |
165 // Default constructor leaves the event uninitialized. | 170 // Default constructor leaves the event uninitialized. |
166 Event() {} | 171 Event() {} |
167 | 172 |
168 Event(Type type, const char* gc_reason, const char* collector_reason); | 173 Event(Type type, const char* gc_reason, const char* collector_reason); |
169 | 174 |
170 // Returns a string describing the event type. | 175 // Returns a string describing the event type. |
171 const char* TypeName(bool short_name) const; | 176 const char* TypeName(bool short_name) const; |
172 | 177 |
173 // Type of event | 178 // Type of event |
(...skipping 30 matching lines...) Expand all Loading... |
204 | 209 |
205 // Size of new space objects in constructor. | 210 // Size of new space objects in constructor. |
206 intptr_t new_space_object_size; | 211 intptr_t new_space_object_size; |
207 | 212 |
208 // Number of incremental marking steps since creation of tracer. | 213 // Number of incremental marking steps since creation of tracer. |
209 // (value at start of event) | 214 // (value at start of event) |
210 int cumulative_incremental_marking_steps; | 215 int cumulative_incremental_marking_steps; |
211 | 216 |
212 // Incremental marking steps since | 217 // Incremental marking steps since |
213 // - last event for SCAVENGER events | 218 // - last event for SCAVENGER events |
214 // - last MARK_COMPACTOR event for MARK_COMPACTOR events | 219 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR |
| 220 // events |
215 int incremental_marking_steps; | 221 int incremental_marking_steps; |
216 | 222 |
217 // Bytes marked since creation of tracer (value at start of event). | 223 // Bytes marked since creation of tracer (value at start of event). |
218 intptr_t cumulative_incremental_marking_bytes; | 224 intptr_t cumulative_incremental_marking_bytes; |
219 | 225 |
220 // Bytes marked since | 226 // Bytes marked since |
221 // - last event for SCAVENGER events | 227 // - last event for SCAVENGER events |
222 // - last MARK_COMPACTOR event for MARK_COMPACTOR events | 228 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR |
| 229 // events |
223 intptr_t incremental_marking_bytes; | 230 intptr_t incremental_marking_bytes; |
224 | 231 |
225 // Cumulative duration of incremental marking steps since creation of | 232 // Cumulative duration of incremental marking steps since creation of |
226 // tracer. (value at start of event) | 233 // tracer. (value at start of event) |
227 double cumulative_incremental_marking_duration; | 234 double cumulative_incremental_marking_duration; |
228 | 235 |
229 // Duration of incremental marking steps since | 236 // Duration of incremental marking steps since |
230 // - last event for SCAVENGER events | 237 // - last event for SCAVENGER events |
231 // - last MARK_COMPACTOR event for MARK_COMPACTOR events | 238 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR |
| 239 // events |
232 double incremental_marking_duration; | 240 double incremental_marking_duration; |
233 | 241 |
234 // Cumulative pure duration of incremental marking steps since creation of | 242 // Cumulative pure duration of incremental marking steps since creation of |
235 // tracer. (value at start of event) | 243 // tracer. (value at start of event) |
236 double cumulative_pure_incremental_marking_duration; | 244 double cumulative_pure_incremental_marking_duration; |
237 | 245 |
238 // Duration of pure incremental marking steps since | 246 // Duration of pure incremental marking steps since |
239 // - last event for SCAVENGER events | 247 // - last event for SCAVENGER events |
240 // - last MARK_COMPACTOR event for MARK_COMPACTOR events | 248 // - last INCREMENTAL_MARK_COMPACTOR event for INCREMENTAL_MARK_COMPACTOR |
| 249 // events |
241 double pure_incremental_marking_duration; | 250 double pure_incremental_marking_duration; |
242 | 251 |
243 // Longest incremental marking step since start of marking. | 252 // Longest incremental marking step since start of marking. |
244 // (value at start of event) | 253 // (value at start of event) |
245 double longest_incremental_marking_step; | 254 double longest_incremental_marking_step; |
246 | 255 |
247 // Amounts of time spent in different scopes during GC. | 256 // Amounts of time spent in different scopes during GC. |
248 double scopes[Scope::NUMBER_OF_SCOPES]; | 257 double scopes[Scope::NUMBER_OF_SCOPES]; |
249 }; | 258 }; |
250 | 259 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 double MeanMarkCompactorDuration() const { | 318 double MeanMarkCompactorDuration() const { |
310 return MeanDuration(mark_compactor_events_); | 319 return MeanDuration(mark_compactor_events_); |
311 } | 320 } |
312 | 321 |
313 // Compute the max duration of the last mark compactor events. Return 0 if no | 322 // Compute the max duration of the last mark compactor events. Return 0 if no |
314 // events have been recorded. | 323 // events have been recorded. |
315 double MaxMarkCompactorDuration() const { | 324 double MaxMarkCompactorDuration() const { |
316 return MaxDuration(mark_compactor_events_); | 325 return MaxDuration(mark_compactor_events_); |
317 } | 326 } |
318 | 327 |
| 328 // Compute the mean duration of the last incremental mark compactor |
| 329 // events. Returns 0 if no events have been recorded. |
| 330 double MeanIncrementalMarkCompactorDuration() const { |
| 331 return MeanDuration(incremental_mark_compactor_events_); |
| 332 } |
| 333 |
319 // Compute the mean step duration of the last incremental marking round. | 334 // Compute the mean step duration of the last incremental marking round. |
320 // Returns 0 if no incremental marking round has been completed. | 335 // Returns 0 if no incremental marking round has been completed. |
321 double MeanIncrementalMarkingDuration() const; | 336 double MeanIncrementalMarkingDuration() const; |
322 | 337 |
323 // Compute the max step duration of the last incremental marking round. | 338 // Compute the max step duration of the last incremental marking round. |
324 // Returns 0 if no incremental marking round has been completed. | 339 // Returns 0 if no incremental marking round has been completed. |
325 double MaxIncrementalMarkingDuration() const; | 340 double MaxIncrementalMarkingDuration() const; |
326 | 341 |
327 // Compute the average incremental marking speed in bytes/millisecond. | 342 // Compute the average incremental marking speed in bytes/millisecond. |
328 // Returns 0 if no events have been recorded. | 343 // Returns 0 if no events have been recorded. |
329 intptr_t IncrementalMarkingSpeedInBytesPerMillisecond() const; | 344 intptr_t IncrementalMarkingSpeedInBytesPerMillisecond() const; |
330 | 345 |
331 // Compute the average scavenge speed in bytes/millisecond. | 346 // Compute the average scavenge speed in bytes/millisecond. |
332 // Returns 0 if no events have been recorded. | 347 // Returns 0 if no events have been recorded. |
333 intptr_t ScavengeSpeedInBytesPerMillisecond() const; | 348 intptr_t ScavengeSpeedInBytesPerMillisecond() const; |
334 | 349 |
335 // Compute the max mark-sweep speed in bytes/millisecond. | 350 // Compute the average mark-sweep speed in bytes/millisecond. |
336 // Returns 0 if no events have been recorded. | 351 // Returns 0 if no events have been recorded. |
337 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; | 352 intptr_t MarkCompactSpeedInBytesPerMillisecond() const; |
338 | 353 |
| 354 // Compute the average incremental mark-sweep finalize speed in |
| 355 // bytes/millisecond. |
| 356 // Returns 0 if no events have been recorded. |
| 357 intptr_t FinalIncrementalMarkCompactSpeedInBytesPerMillisecond() const; |
| 358 |
339 // Allocation throughput in the new space in bytes/millisecond. | 359 // Allocation throughput in the new space in bytes/millisecond. |
340 // Returns 0 if no events have been recorded. | 360 // Returns 0 if no events have been recorded. |
341 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; | 361 intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const; |
342 | 362 |
343 // Computes the context disposal rate in milliseconds. It takes the time | 363 // Computes the context disposal rate in milliseconds. It takes the time |
344 // frame of the first recorded context disposal to the current time and | 364 // frame of the first recorded context disposal to the current time and |
345 // divides it by the number of recorded events. | 365 // divides it by the number of recorded events. |
346 // Returns 0 if no events have been recorded. | 366 // Returns 0 if no events have been recorded. |
347 double ContextDisposalRateInMilliseconds() const; | 367 double ContextDisposalRateInMilliseconds() const; |
348 | 368 |
349 private: | 369 private: |
350 // Print one detailed trace line in name=value format. | 370 // Print one detailed trace line in name=value format. |
351 // TODO(ernstm): Move to Heap. | 371 // TODO(ernstm): Move to Heap. |
352 void PrintNVP() const; | 372 void PrintNVP() const; |
353 | 373 |
354 // Print one trace line. | 374 // Print one trace line. |
355 // TODO(ernstm): Move to Heap. | 375 // TODO(ernstm): Move to Heap. |
356 void Print() const; | 376 void Print() const; |
357 | 377 |
358 // Compute the mean duration of the events in the given ring buffer. | 378 // Compute the mean duration of the events in the given ring buffer. |
359 double MeanDuration(const EventBuffer& events) const; | 379 double MeanDuration(const EventBuffer& events) const; |
360 | 380 |
361 // Compute the max duration of the events in the given ring buffer. | 381 // Compute the max duration of the events in the given ring buffer. |
362 double MaxDuration(const EventBuffer& events) const; | 382 double MaxDuration(const EventBuffer& events) const; |
363 | 383 |
| 384 void ClearMarkCompactStatistics() { |
| 385 cumulative_incremental_marking_steps_ = 0; |
| 386 cumulative_incremental_marking_bytes_ = 0; |
| 387 cumulative_incremental_marking_duration_ = 0; |
| 388 cumulative_pure_incremental_marking_duration_ = 0; |
| 389 longest_incremental_marking_step_ = 0; |
| 390 cumulative_marking_duration_ = 0; |
| 391 cumulative_sweeping_duration_ = 0; |
| 392 } |
| 393 |
364 // Pointer to the heap that owns this tracer. | 394 // Pointer to the heap that owns this tracer. |
365 Heap* heap_; | 395 Heap* heap_; |
366 | 396 |
367 // Current tracer event. Populated during Start/Stop cycle. Valid after Stop() | 397 // Current tracer event. Populated during Start/Stop cycle. Valid after Stop() |
368 // has returned. | 398 // has returned. |
369 Event current_; | 399 Event current_; |
370 | 400 |
371 // Previous tracer event. | 401 // Previous tracer event. |
372 Event previous_; | 402 Event previous_; |
373 | 403 |
374 // Previous MARK_COMPACTOR event. | 404 // Previous INCREMENTAL_MARK_COMPACTOR event. |
375 Event previous_mark_compactor_event_; | 405 Event previous_incremental_mark_compactor_event_; |
376 | 406 |
377 // RingBuffers for SCAVENGER events. | 407 // RingBuffers for SCAVENGER events. |
378 EventBuffer scavenger_events_; | 408 EventBuffer scavenger_events_; |
379 | 409 |
380 // RingBuffers for MARK_COMPACTOR events. | 410 // RingBuffers for MARK_COMPACTOR events. |
381 EventBuffer mark_compactor_events_; | 411 EventBuffer mark_compactor_events_; |
382 | 412 |
| 413 // RingBuffers for INCREMENTAL_MARK_COMPACTOR events. |
| 414 EventBuffer incremental_mark_compactor_events_; |
| 415 |
383 // RingBuffer for allocation events. | 416 // RingBuffer for allocation events. |
384 AllocationEventBuffer allocation_events_; | 417 AllocationEventBuffer allocation_events_; |
385 | 418 |
386 ContextDisposalEventBuffer context_disposal_events_; | 419 ContextDisposalEventBuffer context_disposal_events_; |
387 | 420 |
388 // Cumulative number of incremental marking steps since creation of tracer. | 421 // Cumulative number of incremental marking steps since creation of tracer. |
389 int cumulative_incremental_marking_steps_; | 422 int cumulative_incremental_marking_steps_; |
390 | 423 |
391 // Cumulative size of incremental marking steps (in bytes) since creation of | 424 // Cumulative size of incremental marking steps (in bytes) since creation of |
392 // tracer. | 425 // tracer. |
(...skipping 25 matching lines...) Expand all Loading... |
418 // Holds the new space top pointer recorded at the end of the last garbage | 451 // Holds the new space top pointer recorded at the end of the last garbage |
419 // collection. | 452 // collection. |
420 intptr_t new_space_top_after_gc_; | 453 intptr_t new_space_top_after_gc_; |
421 | 454 |
422 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 455 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
423 }; | 456 }; |
424 } | 457 } |
425 } // namespace v8::internal | 458 } // namespace v8::internal |
426 | 459 |
427 #endif // V8_HEAP_GC_TRACER_H_ | 460 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |