Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: src/heap/gc-tracer.h

Issue 2413243002: Introduce a CompilerDispatcherTracer and track how long jobs take (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/base/ring-buffer.h"
10 #include "src/counters.h" 11 #include "src/counters.h"
11 #include "src/globals.h" 12 #include "src/globals.h"
12 #include "testing/gtest/include/gtest/gtest_prod.h" 13 #include "testing/gtest/include/gtest/gtest_prod.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 17
17 template <typename T>
18 class RingBuffer {
19 public:
20 RingBuffer() { Reset(); }
21 static const int kSize = 10;
22 void Push(const T& value) {
23 if (count_ == kSize) {
24 elements_[start_++] = value;
25 if (start_ == kSize) start_ = 0;
26 } else {
27 DCHECK_EQ(start_, 0);
28 elements_[count_++] = value;
29 }
30 }
31
32 int Count() const { return count_; }
33
34 template <typename Callback>
35 T Sum(Callback callback, const T& initial) const {
36 int j = start_ + count_ - 1;
37 if (j >= kSize) j -= kSize;
38 T result = initial;
39 for (int i = 0; i < count_; i++) {
40 result = callback(result, elements_[j]);
41 if (--j == -1) j += kSize;
42 }
43 return result;
44 }
45
46 void Reset() { start_ = count_ = 0; }
47
48 private:
49 T elements_[kSize];
50 int start_;
51 int count_;
52 DISALLOW_COPY_AND_ASSIGN(RingBuffer);
53 };
54
55 typedef std::pair<uint64_t, double> BytesAndDuration; 18 typedef std::pair<uint64_t, double> BytesAndDuration;
56 19
57 inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) { 20 inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) {
58 return std::make_pair(bytes, duration); 21 return std::make_pair(bytes, duration);
59 } 22 }
60 23
61 enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; 24 enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects };
62 25
63 #define INCREMENTAL_SCOPES(F) \ 26 #define INCREMENTAL_SCOPES(F) \
64 /* MC_INCREMENTAL is the top-level incremental marking scope. */ \ 27 /* MC_INCREMENTAL is the top-level incremental marking scope. */ \
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughputWithProvidedTime); 333 FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughputWithProvidedTime);
371 FRIEND_TEST(GCTracerTest, OldGenerationAllocationThroughputWithProvidedTime); 334 FRIEND_TEST(GCTracerTest, OldGenerationAllocationThroughputWithProvidedTime);
372 FRIEND_TEST(GCTracerTest, RegularScope); 335 FRIEND_TEST(GCTracerTest, RegularScope);
373 FRIEND_TEST(GCTracerTest, IncrementalMarkingDetails); 336 FRIEND_TEST(GCTracerTest, IncrementalMarkingDetails);
374 FRIEND_TEST(GCTracerTest, IncrementalScope); 337 FRIEND_TEST(GCTracerTest, IncrementalScope);
375 FRIEND_TEST(GCTracerTest, IncrementalMarkingSpeed); 338 FRIEND_TEST(GCTracerTest, IncrementalMarkingSpeed);
376 339
377 // Returns the average speed of the events in the buffer. 340 // Returns the average speed of the events in the buffer.
378 // If the buffer is empty, the result is 0. 341 // If the buffer is empty, the result is 0.
379 // Otherwise, the result is between 1 byte/ms and 1 GB/ms. 342 // Otherwise, the result is between 1 byte/ms and 1 GB/ms.
380 static double AverageSpeed(const RingBuffer<BytesAndDuration>& buffer); 343 static double AverageSpeed(const base::RingBuffer<BytesAndDuration>& buffer);
381 static double AverageSpeed(const RingBuffer<BytesAndDuration>& buffer, 344 static double AverageSpeed(const base::RingBuffer<BytesAndDuration>& buffer,
382 const BytesAndDuration& initial, double time_ms); 345 const BytesAndDuration& initial, double time_ms);
383 346
384 void ResetForTesting(); 347 void ResetForTesting();
385 void ResetIncrementalMarkingCounters(); 348 void ResetIncrementalMarkingCounters();
386 void RecordIncrementalMarkingSpeed(size_t bytes, double duration); 349 void RecordIncrementalMarkingSpeed(size_t bytes, double duration);
387 350
388 // Print one detailed trace line in name=value format. 351 // Print one detailed trace line in name=value format.
389 // TODO(ernstm): Move to Heap. 352 // TODO(ernstm): Move to Heap.
390 void PrintNVP() const; 353 void PrintNVP() const;
391 354
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 size_t old_generation_allocation_in_bytes_since_gc_; 409 size_t old_generation_allocation_in_bytes_since_gc_;
447 410
448 double combined_mark_compact_speed_cache_; 411 double combined_mark_compact_speed_cache_;
449 412
450 // Counts how many tracers were started without stopping. 413 // Counts how many tracers were started without stopping.
451 int start_counter_; 414 int start_counter_;
452 415
453 // Separate timer used for --runtime_call_stats 416 // Separate timer used for --runtime_call_stats
454 RuntimeCallTimer timer_; 417 RuntimeCallTimer timer_;
455 418
456 RingBuffer<BytesAndDuration> recorded_scavenges_total_; 419 base::RingBuffer<BytesAndDuration> recorded_scavenges_total_;
457 RingBuffer<BytesAndDuration> recorded_scavenges_survived_; 420 base::RingBuffer<BytesAndDuration> recorded_scavenges_survived_;
458 RingBuffer<BytesAndDuration> recorded_compactions_; 421 base::RingBuffer<BytesAndDuration> recorded_compactions_;
459 RingBuffer<BytesAndDuration> recorded_incremental_mark_compacts_; 422 base::RingBuffer<BytesAndDuration> recorded_incremental_mark_compacts_;
460 RingBuffer<BytesAndDuration> recorded_mark_compacts_; 423 base::RingBuffer<BytesAndDuration> recorded_mark_compacts_;
461 RingBuffer<BytesAndDuration> recorded_new_generation_allocations_; 424 base::RingBuffer<BytesAndDuration> recorded_new_generation_allocations_;
462 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_; 425 base::RingBuffer<BytesAndDuration> recorded_old_generation_allocations_;
463 RingBuffer<double> recorded_context_disposal_times_; 426 base::RingBuffer<double> recorded_context_disposal_times_;
464 RingBuffer<double> recorded_survival_ratios_; 427 base::RingBuffer<double> recorded_survival_ratios_;
465 428
466 DISALLOW_COPY_AND_ASSIGN(GCTracer); 429 DISALLOW_COPY_AND_ASSIGN(GCTracer);
467 }; 430 };
468 } // namespace internal 431 } // namespace internal
469 } // namespace v8 432 } // namespace v8
470 433
471 #endif // V8_HEAP_GC_TRACER_H_ 434 #endif // V8_HEAP_GC_TRACER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698