Commit d3e96993 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Add embedder allocation rate signal

Consider embedder allocation rate when scheduling full garbage
collections.

Change-Id: If9c40df514c8346e21f6ba63eeca976acce4d122
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1631423Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61861}
parent 03a82cc7
...@@ -3011,10 +3011,11 @@ void Heap::MakeHeapIterable() { ...@@ -3011,10 +3011,11 @@ void Heap::MakeHeapIterable() {
mark_compact_collector()->EnsureSweepingCompleted(); mark_compact_collector()->EnsureSweepingCompleted();
} }
namespace {
static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) { double ComputeMutatorUtilizationImpl(double mutator_speed, double gc_speed) {
const double kMinMutatorUtilization = 0.0; constexpr double kMinMutatorUtilization = 0.0;
const double kConservativeGcSpeedInBytesPerMillisecond = 200000; constexpr double kConservativeGcSpeedInBytesPerMillisecond = 200000;
if (mutator_speed == 0) return kMinMutatorUtilization; if (mutator_speed == 0) return kMinMutatorUtilization;
if (gc_speed == 0) gc_speed = kConservativeGcSpeedInBytesPerMillisecond; if (gc_speed == 0) gc_speed = kConservativeGcSpeedInBytesPerMillisecond;
// Derivation: // Derivation:
...@@ -3027,54 +3028,53 @@ static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) { ...@@ -3027,54 +3028,53 @@ static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) {
return gc_speed / (mutator_speed + gc_speed); return gc_speed / (mutator_speed + gc_speed);
} }
} // namespace
double Heap::YoungGenerationMutatorUtilization() { double Heap::ComputeMutatorUtilization(const char* tag, double mutator_speed,
double mutator_speed = static_cast<double>( double gc_speed) {
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); double result = ComputeMutatorUtilizationImpl(mutator_speed, gc_speed);
double gc_speed =
tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects);
double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
if (FLAG_trace_mutator_utilization) {
isolate()->PrintWithTimestamp(
"Young generation mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed);
}
return result;
}
double Heap::OldGenerationMutatorUtilization() {
double mutator_speed = static_cast<double>(
tracer()->OldGenerationAllocationThroughputInBytesPerMillisecond());
double gc_speed = static_cast<double>(
tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
if (FLAG_trace_mutator_utilization) { if (FLAG_trace_mutator_utilization) {
isolate()->PrintWithTimestamp( isolate()->PrintWithTimestamp(
"Old generation mutator utilization = %.3f (" "%s mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n", "mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed); tag, result, mutator_speed, gc_speed);
} }
return result; return result;
} }
bool Heap::HasLowYoungGenerationAllocationRate() { bool Heap::HasLowYoungGenerationAllocationRate() {
const double high_mutator_utilization = 0.993; double mu = ComputeMutatorUtilization(
return YoungGenerationMutatorUtilization() > high_mutator_utilization; "Young generation",
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(),
tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects));
constexpr double kHighMutatorUtilization = 0.993;
return mu > kHighMutatorUtilization;
} }
bool Heap::HasLowOldGenerationAllocationRate() { bool Heap::HasLowOldGenerationAllocationRate() {
const double high_mutator_utilization = 0.993; double mu = ComputeMutatorUtilization(
return OldGenerationMutatorUtilization() > high_mutator_utilization; "Old generation",
tracer()->OldGenerationAllocationThroughputInBytesPerMillisecond(),
tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
const double kHighMutatorUtilization = 0.993;
return mu > kHighMutatorUtilization;
} }
bool Heap::HasLowEmbedderAllocationRate() {
if (!UseGlobalMemoryScheduling()) return true;
DCHECK_NOT_NULL(local_embedder_heap_tracer());
double mu = ComputeMutatorUtilization(
"Embedder",
tracer()->CurrentEmbedderAllocationThroughputInBytesPerMillisecond(),
tracer()->EmbedderSpeedInBytesPerMillisecond());
const double kHighMutatorUtilization = 0.993;
return mu > kHighMutatorUtilization;
}
bool Heap::HasLowAllocationRate() { bool Heap::HasLowAllocationRate() {
return HasLowYoungGenerationAllocationRate() && return HasLowYoungGenerationAllocationRate() &&
HasLowOldGenerationAllocationRate(); HasLowOldGenerationAllocationRate() && HasLowEmbedderAllocationRate();
} }
bool Heap::IsIneffectiveMarkCompact(size_t old_generation_size, bool Heap::IsIneffectiveMarkCompact(size_t old_generation_size,
......
...@@ -1539,10 +1539,11 @@ class Heap { ...@@ -1539,10 +1539,11 @@ class Heap {
void ConfigureInitialOldGenerationSize(); void ConfigureInitialOldGenerationSize();
double ComputeMutatorUtilization(const char* tag, double mutator_speed,
double gc_speed);
bool HasLowYoungGenerationAllocationRate(); bool HasLowYoungGenerationAllocationRate();
bool HasLowOldGenerationAllocationRate(); bool HasLowOldGenerationAllocationRate();
double YoungGenerationMutatorUtilization(); bool HasLowEmbedderAllocationRate();
double OldGenerationMutatorUtilization();
void ReduceNewSpaceSize(); void ReduceNewSpaceSize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment