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

Side by Side Diff: src/heap/heap.cc

Issue 1254603002: Extract function to compute mutator utilization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: return min mutator utilization instead of max when there is no data. Created 5 years, 5 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
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 4757 matching lines...) Expand 10 before | Expand all | Expand 10 after
4768 if (!IsHeapIterable()) { 4768 if (!IsHeapIterable()) {
4769 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); 4769 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable");
4770 } 4770 }
4771 if (mark_compact_collector()->sweeping_in_progress()) { 4771 if (mark_compact_collector()->sweeping_in_progress()) {
4772 mark_compact_collector()->EnsureSweepingCompleted(); 4772 mark_compact_collector()->EnsureSweepingCompleted();
4773 } 4773 }
4774 DCHECK(IsHeapIterable()); 4774 DCHECK(IsHeapIterable());
4775 } 4775 }
4776 4776
4777 4777
4778 static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) {
4779 const double kMinMutatorUtilization = 0.0;
4780 if (mutator_speed == 0 || gc_speed == 0) return kMinMutatorUtilization;
4781 // Derivation:
4782 // mutator_utilization = mutator_time / (mutator_time + gc_time)
4783 // mutator_time = 1 / mutator_speed
4784 // gc_time = 1 / gc_speed
4785 // mutator_utilization = (1 / mutator_speed) /
4786 // (1 / mutator_speed + 1 / gc_speed)
4787 // mutator_utilization = gc_speed / (mutator_speed + gc_speed)
4788 return gc_speed / (mutator_speed + gc_speed);
4789 }
4790
4791
4792 double Heap::YoungGenerationMutatorUtilization() {
4793 double mutator_speed = static_cast<double>(
4794 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
4795 double gc_speed = static_cast<double>(
4796 tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects));
4797 double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
4798 if (FLAG_trace_mutator_utilization) {
4799 PrintIsolate(isolate(),
4800 "Young generation mutator utilization = %.3f ("
4801 "mutator_speed=%.f, gc_speed=%.f)\n",
4802 result, mutator_speed, gc_speed);
4803 }
4804 return result;
4805 }
4806
4807
4808 double Heap::OldGenerationMutatorUtilization() {
4809 double mutator_speed = static_cast<double>(
4810 tracer()->OldGenerationAllocationThroughputInBytesPerMillisecond());
4811 double gc_speed = static_cast<double>(
4812 tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
4813 double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
4814 if (FLAG_trace_mutator_utilization) {
4815 PrintIsolate(isolate(),
4816 "Old generation mutator utilization = %.3f ("
4817 "mutator_speed=%.f, gc_speed=%.f)\n",
4818 result, mutator_speed, gc_speed);
4819 }
4820 return result;
4821 }
4822
4823
4778 bool Heap::HasLowYoungGenerationAllocationRate() { 4824 bool Heap::HasLowYoungGenerationAllocationRate() {
4779 const double high_mutator_utilization = 0.993; 4825 const double high_mutator_utilization = 0.993;
4780 double mutator_speed = static_cast<double>( 4826 return YoungGenerationMutatorUtilization() > high_mutator_utilization;
4781 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
4782 double gc_speed = static_cast<double>(
4783 tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects));
4784 if (mutator_speed == 0 || gc_speed == 0) return false;
4785 double mutator_utilization = gc_speed / (mutator_speed + gc_speed);
4786 return mutator_utilization > high_mutator_utilization;
4787 } 4827 }
4788 4828
4789 4829
4790 bool Heap::HasLowOldGenerationAllocationRate() { 4830 bool Heap::HasLowOldGenerationAllocationRate() {
4791 const double high_mutator_utilization = 0.993; 4831 const double high_mutator_utilization = 0.993;
4792 double mutator_speed = static_cast<double>( 4832 return OldGenerationMutatorUtilization() > high_mutator_utilization;
4793 tracer()->OldGenerationAllocationThroughputInBytesPerMillisecond());
4794 double gc_speed = static_cast<double>(
4795 tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
4796 if (mutator_speed == 0 || gc_speed == 0) return false;
4797 double mutator_utilization = gc_speed / (mutator_speed + gc_speed);
4798 return mutator_utilization > high_mutator_utilization;
4799 } 4833 }
4800 4834
4801 4835
4802 bool Heap::HasLowAllocationRate() { 4836 bool Heap::HasLowAllocationRate() {
4803 return HasLowYoungGenerationAllocationRate() && 4837 return HasLowYoungGenerationAllocationRate() &&
4804 HasLowOldGenerationAllocationRate(); 4838 HasLowOldGenerationAllocationRate();
4805 } 4839 }
4806 4840
4807 4841
4808 bool Heap::HasHighFragmentation() { 4842 bool Heap::HasHighFragmentation() {
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
6918 *object_type = "CODE_TYPE"; \ 6952 *object_type = "CODE_TYPE"; \
6919 *object_sub_type = "CODE_AGE/" #name; \ 6953 *object_sub_type = "CODE_AGE/" #name; \
6920 return true; 6954 return true;
6921 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6955 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6922 #undef COMPARE_AND_RETURN_NAME 6956 #undef COMPARE_AND_RETURN_NAME
6923 } 6957 }
6924 return false; 6958 return false;
6925 } 6959 }
6926 } // namespace internal 6960 } // namespace internal
6927 } // namespace v8 6961 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698