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() {
mark_compact_collector()->EnsureSweepingCompleted();
}
namespace {
static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) {
const double kMinMutatorUtilization = 0.0;
const double kConservativeGcSpeedInBytesPerMillisecond = 200000;
double ComputeMutatorUtilizationImpl(double mutator_speed, double gc_speed) {
constexpr double kMinMutatorUtilization = 0.0;
constexpr double kConservativeGcSpeedInBytesPerMillisecond = 200000;
if (mutator_speed == 0) return kMinMutatorUtilization;
if (gc_speed == 0) gc_speed = kConservativeGcSpeedInBytesPerMillisecond;
// Derivation:
......@@ -3027,54 +3028,53 @@ static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) {
return gc_speed / (mutator_speed + gc_speed);
}
} // namespace
double Heap::YoungGenerationMutatorUtilization() {
double mutator_speed = static_cast<double>(
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
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);
double Heap::ComputeMutatorUtilization(const char* tag, double mutator_speed,
double gc_speed) {
double result = ComputeMutatorUtilizationImpl(mutator_speed, gc_speed);
if (FLAG_trace_mutator_utilization) {
isolate()->PrintWithTimestamp(
"Old generation mutator utilization = %.3f ("
"%s mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed);
tag, result, mutator_speed, gc_speed);
}
return result;
}
bool Heap::HasLowYoungGenerationAllocationRate() {
const double high_mutator_utilization = 0.993;
return YoungGenerationMutatorUtilization() > high_mutator_utilization;
double mu = ComputeMutatorUtilization(
"Young generation",
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(),
tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects));
constexpr double kHighMutatorUtilization = 0.993;
return mu > kHighMutatorUtilization;
}
bool Heap::HasLowOldGenerationAllocationRate() {
const double high_mutator_utilization = 0.993;
return OldGenerationMutatorUtilization() > high_mutator_utilization;
double mu = ComputeMutatorUtilization(
"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() {
return HasLowYoungGenerationAllocationRate() &&
HasLowOldGenerationAllocationRate();
HasLowOldGenerationAllocationRate() && HasLowEmbedderAllocationRate();
}
bool Heap::IsIneffectiveMarkCompact(size_t old_generation_size,
......
......@@ -1539,10 +1539,11 @@ class Heap {
void ConfigureInitialOldGenerationSize();
double ComputeMutatorUtilization(const char* tag, double mutator_speed,
double gc_speed);
bool HasLowYoungGenerationAllocationRate();
bool HasLowOldGenerationAllocationRate();
double YoungGenerationMutatorUtilization();
double OldGenerationMutatorUtilization();
bool HasLowEmbedderAllocationRate();
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