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 #include "src/heap/gc-tracer.h" | 5 #include "src/heap/gc-tracer.h" |
6 | 6 |
7 #include "src/counters.h" | 7 #include "src/counters.h" |
8 #include "src/heap/heap-inl.h" | 8 #include "src/heap/heap-inl.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 | 10 |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 ContextDisposalRateInMilliseconds(), | 668 ContextDisposalRateInMilliseconds(), |
669 CompactionSpeedInBytesPerMillisecond()); | 669 CompactionSpeedInBytesPerMillisecond()); |
670 break; | 670 break; |
671 case Event::START: | 671 case Event::START: |
672 break; | 672 break; |
673 default: | 673 default: |
674 UNREACHABLE(); | 674 UNREACHABLE(); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 double GCTracer::AverageSpeed(const RingBuffer<BytesAndDuration>& buffer, | 678 double GCTracer::AverageSpeed(const base::RingBuffer<BytesAndDuration>& buffer, |
679 const BytesAndDuration& initial, double time_ms) { | 679 const BytesAndDuration& initial, double time_ms) { |
680 BytesAndDuration sum = buffer.Sum( | 680 BytesAndDuration sum = buffer.Sum( |
681 [time_ms](BytesAndDuration a, BytesAndDuration b) { | 681 [time_ms](BytesAndDuration a, BytesAndDuration b) { |
682 if (time_ms != 0 && a.second >= time_ms) return a; | 682 if (time_ms != 0 && a.second >= time_ms) return a; |
683 return std::make_pair(a.first + b.first, a.second + b.second); | 683 return std::make_pair(a.first + b.first, a.second + b.second); |
684 }, | 684 }, |
685 initial); | 685 initial); |
686 uint64_t bytes = sum.first; | 686 uint64_t bytes = sum.first; |
687 double durations = sum.second; | 687 double durations = sum.second; |
688 if (durations == 0.0) return 0; | 688 if (durations == 0.0) return 0; |
689 double speed = bytes / durations; | 689 double speed = bytes / durations; |
690 const int max_speed = 1024 * MB; | 690 const int max_speed = 1024 * MB; |
691 const int min_speed = 1; | 691 const int min_speed = 1; |
692 if (speed >= max_speed) return max_speed; | 692 if (speed >= max_speed) return max_speed; |
693 if (speed <= min_speed) return min_speed; | 693 if (speed <= min_speed) return min_speed; |
694 return speed; | 694 return speed; |
695 } | 695 } |
696 | 696 |
697 double GCTracer::AverageSpeed(const RingBuffer<BytesAndDuration>& buffer) { | 697 double GCTracer::AverageSpeed( |
| 698 const base::RingBuffer<BytesAndDuration>& buffer) { |
698 return AverageSpeed(buffer, MakeBytesAndDuration(0, 0), 0); | 699 return AverageSpeed(buffer, MakeBytesAndDuration(0, 0), 0); |
699 } | 700 } |
700 | 701 |
701 void GCTracer::RecordIncrementalMarkingSpeed(size_t bytes, double duration) { | 702 void GCTracer::RecordIncrementalMarkingSpeed(size_t bytes, double duration) { |
702 if (duration == 0 || bytes == 0) return; | 703 if (duration == 0 || bytes == 0) return; |
703 double current_speed = bytes / duration; | 704 double current_speed = bytes / duration; |
704 if (recorded_incremental_marking_speed_ == 0) { | 705 if (recorded_incremental_marking_speed_ == 0) { |
705 recorded_incremental_marking_speed_ = current_speed; | 706 recorded_incremental_marking_speed_ = current_speed; |
706 } else { | 707 } else { |
707 recorded_incremental_marking_speed_ = | 708 recorded_incremental_marking_speed_ = |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 } | 815 } |
815 | 816 |
816 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } | 817 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } |
817 | 818 |
818 void GCTracer::NotifyIncrementalMarkingStart() { | 819 void GCTracer::NotifyIncrementalMarkingStart() { |
819 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); | 820 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); |
820 } | 821 } |
821 | 822 |
822 } // namespace internal | 823 } // namespace internal |
823 } // namespace v8 | 824 } // namespace v8 |
OLD | NEW |