Commit c6d9a820 authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Commit Bot

[heap] Simplifying growing strategy.

Bug: chromium:852748
Change-Id: Iac1c52d45e84af190415aeae5df167ab501b4bc4
Reviewed-on: https://chromium-review.googlesource.com/1109821Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
Cr-Commit-Position: refs/heads/master@{#53918}
parent c6d5179b
......@@ -10,8 +10,6 @@ namespace internal {
const double HeapController::kMinHeapGrowingFactor = 1.1;
const double HeapController::kMaxHeapGrowingFactor = 4.0;
const double HeapController::kMaxHeapGrowingFactorMemoryConstrained = 2.0;
const double HeapController::kMaxHeapGrowingFactorIdle = 1.5;
const double HeapController::kConservativeHeapGrowingFactor = 1.3;
const double HeapController::kTargetMutatorUtilization = 0.97;
......@@ -115,11 +113,12 @@ size_t HeapController::CalculateOldGenerationAllocationLimit(
mutator_speed);
}
if (growing_mode.kConservative() || growing_mode.kSlow()) {
if (growing_mode == Heap::HeapGrowingMode::kConservative ||
growing_mode == Heap::HeapGrowingMode::kSlow) {
factor = Min(factor, kConservativeHeapGrowingFactor);
}
if (FLAG_stress_compaction || growing_mode.kMinimal()) {
if (growing_mode == Heap::HeapGrowingMode::kMinimal) {
factor = kMinHeapGrowingFactor;
}
......@@ -152,7 +151,7 @@ size_t HeapController::MinimumAllocationLimitGrowingStep(
const size_t kRegularAllocationLimitGrowingStep = 8;
const size_t kLowMemoryAllocationLimitGrowingStep = 2;
size_t limit = (Page::kPageSize > MB ? Page::kPageSize : MB);
return limit * (growing_mode.kConservative()
return limit * (growing_mode == Heap::HeapGrowingMode::kConservative
? kLowMemoryAllocationLimitGrowingStep
: kRegularAllocationLimitGrowingStep);
}
......
......@@ -44,8 +44,6 @@ class HeapController {
double mutator_speed,
double max_factor);
static const double kMaxHeapGrowingFactorMemoryConstrained;
static const double kMaxHeapGrowingFactorIdle;
static const double kTargetMutatorUtilization;
Heap* heap_;
......
......@@ -4323,9 +4323,19 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation() {
}
Heap::HeapGrowingMode Heap::CurrentHeapGrowingMode() {
return Heap::HeapGrowingMode(ShouldOptimizeForMemoryUsage(),
ShouldReduceMemory(),
memory_reducer()->ShouldGrowHeapSlowly());
if (ShouldReduceMemory() || FLAG_stress_compaction) {
return Heap::HeapGrowingMode::kMinimal;
}
if (ShouldOptimizeForMemoryUsage()) {
return Heap::HeapGrowingMode::kConservative;
}
if (memory_reducer()->ShouldGrowHeapSlowly()) {
return Heap::HeapGrowingMode::kSlow;
}
return Heap::HeapGrowingMode::kDefault;
}
// This function returns either kNoLimit, kSoftLimit, or kHardLimit.
......
......@@ -2112,19 +2112,7 @@ class Heap {
bool ShouldExpandOldGenerationOnSlowAllocation();
class HeapGrowingMode {
public:
HeapGrowingMode(bool kConservative, bool kMinimal, bool kSlow)
: kConservative_(kConservative), kMinimal_(kMinimal), kSlow_(kSlow) {}
bool kConservative() { return kConservative_; }
bool kMinimal() { return kMinimal_; }
bool kSlow() { return kSlow_; }
private:
bool kConservative_;
bool kMinimal_;
bool kSlow_;
};
enum class HeapGrowingMode { kSlow, kConservative, kMinimal, kDefault };
HeapGrowingMode CurrentHeapGrowingMode();
......
......@@ -74,29 +74,28 @@ TEST_F(HeapControllerTest, OldGenerationAllocationLimit) {
double factor =
HeapController::HeapGrowingFactor(gc_speed, mutator_speed, max_factor);
EXPECT_EQ(
static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode(false, false, false)));
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode::kDefault));
factor = Min(factor, HeapController::kConservativeHeapGrowingFactor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode(true, false, false)));
new_space_capacity, Heap::HeapGrowingMode::kSlow));
factor = Min(factor, HeapController::kConservativeHeapGrowingFactor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode(false, false, true)));
new_space_capacity, Heap::HeapGrowingMode::kConservative));
factor = HeapController::kMinHeapGrowingFactor;
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode(false, true, false)));
new_space_capacity, Heap::HeapGrowingMode::kMinimal));
}
TEST(HeapController, MaxOldGenerationSize) {
......
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