Reviewers: Hannes Payer,
Message:
Hannes, ptal. This is just refactoring without any change in behavior.
Description:
Extract function to compute mutator utilization.
This function will be used later instead of HasLowAllocationRate
to decide how many pages to compact.
BUG=chromium:502247
Please review this at https://codereview.chromium.org/1254603002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+55, -10 lines):
M src/flag-definitions.h
M src/heap/heap.h
M src/heap/heap.cc
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
bbffaa8a72973ec2d55ffbe3064f2c03c81e6b87..be2492648490f63e1c678e970895108409a3d87b
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -615,6 +615,8 @@ DEFINE_INT(trace_allocation_stack_interval, -1,
DEFINE_BOOL(trace_fragmentation, false, "report fragmentation for old
space")
DEFINE_BOOL(trace_fragmentation_verbose, false,
"report fragmentation for old space (detailed)")
+DEFINE_BOOL(trace_mutator_utilization, false,
+ "print mutator utilization, allocation speed, gc speed")
DEFINE_BOOL(weak_embedded_maps_in_optimized_code, true,
"make maps embedded in optimized code weak")
DEFINE_BOOL(weak_embedded_objects_in_optimized_code, true,
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
073bffcf897ea39ee19f19651f7382920f1def04..a03ec6f708ac056e4919824d226b340a9dec506b
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -4775,27 +4775,67 @@ void Heap::MakeHeapIterable() {
}
-bool Heap::HasLowYoungGenerationAllocationRate() {
- const double high_mutator_utilization = 0.993;
+static double ComputeMutatorUtilization(double mutator_speed, double
gc_speed) {
+ const double kMaxMutatorUtilization = 1.0;
+ if (mutator_speed == 0 || gc_speed == 0) return kMaxMutatorUtilization;
+ // 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;
+}
+
+
+double Heap::MutatorUtilization() {
+ return Max(YoungGenerationMutatorUtilization(),
+ OldGenerationMutatorUtilization());
+}
+
+
+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;
}
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
6c679e6e733cafc82d38dd25f96870b67bb93136..abafae36bb77947b4f3a325de1a108b7fd3e91af
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1631,6 +1631,7 @@ class Heap {
bool HasLowAllocationRate();
bool HasHighFragmentation();
bool HasHighFragmentation(intptr_t used, intptr_t committed);
+ double MutatorUtilization();
protected:
// Methods made available to tests.
@@ -2267,6 +2268,8 @@ class Heap {
bool HasLowYoungGenerationAllocationRate();
bool HasLowOldGenerationAllocationRate();
+ double YoungGenerationMutatorUtilization();
+ double OldGenerationMutatorUtilization();
void ReduceNewSpaceSize();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.