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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 073bffcf897ea39ee19f19651f7382920f1def04..1e19532ba60f16df5d3dd9744e281f6a30a81b56 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -4775,27 +4775,61 @@ void Heap::MakeHeapIterable() {
}
-bool Heap::HasLowYoungGenerationAllocationRate() {
- const double high_mutator_utilization = 0.993;
+static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) {
+ const double kMinMutatorUtilization = 0.0;
+ if (mutator_speed == 0 || gc_speed == 0) return kMinMutatorUtilization;
+ // Derivation:
+ // mutator_utilization = mutator_time / (mutator_time + gc_time)
+ // mutator_time = 1 / mutator_speed
+ // gc_time = 1 / gc_speed
+ // mutator_utilization = (1 / mutator_speed) /
+ // (1 / mutator_speed + 1 / gc_speed)
+ // mutator_utilization = gc_speed / (mutator_speed + gc_speed)
+ return gc_speed / (mutator_speed + gc_speed);
+}
+
+
+double Heap::YoungGenerationMutatorUtilization() {
double mutator_speed = static_cast<double>(
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
double gc_speed = static_cast<double>(
tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects));
- if (mutator_speed == 0 || gc_speed == 0) return false;
- double mutator_utilization = gc_speed / (mutator_speed + gc_speed);
- return mutator_utilization > high_mutator_utilization;
+ double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
+ if (FLAG_trace_mutator_utilization) {
+ PrintIsolate(isolate(),
+ "Young generation mutator utilization = %.3f ("
+ "mutator_speed=%.f, gc_speed=%.f)\n",
+ result, mutator_speed, gc_speed);
+ }
+ return result;
}
-bool Heap::HasLowOldGenerationAllocationRate() {
- const double high_mutator_utilization = 0.993;
+double Heap::OldGenerationMutatorUtilization() {
double mutator_speed = static_cast<double>(
tracer()->OldGenerationAllocationThroughputInBytesPerMillisecond());
double gc_speed = static_cast<double>(
tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
- if (mutator_speed == 0 || gc_speed == 0) return false;
- double mutator_utilization = gc_speed / (mutator_speed + gc_speed);
- return mutator_utilization > high_mutator_utilization;
+ double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
+ if (FLAG_trace_mutator_utilization) {
+ PrintIsolate(isolate(),
+ "Old generation mutator utilization = %.3f ("
+ "mutator_speed=%.f, gc_speed=%.f)\n",
+ result, mutator_speed, gc_speed);
+ }
+ return result;
+}
+
+
+bool Heap::HasLowYoungGenerationAllocationRate() {
+ const double high_mutator_utilization = 0.993;
+ return YoungGenerationMutatorUtilization() > high_mutator_utilization;
+}
+
+
+bool Heap::HasLowOldGenerationAllocationRate() {
+ const double high_mutator_utilization = 0.993;
+ return OldGenerationMutatorUtilization() > high_mutator_utilization;
}
« 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