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 { ...@@ -10,8 +10,6 @@ namespace internal {
const double HeapController::kMinHeapGrowingFactor = 1.1; const double HeapController::kMinHeapGrowingFactor = 1.1;
const double HeapController::kMaxHeapGrowingFactor = 4.0; 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::kConservativeHeapGrowingFactor = 1.3;
const double HeapController::kTargetMutatorUtilization = 0.97; const double HeapController::kTargetMutatorUtilization = 0.97;
...@@ -115,11 +113,12 @@ size_t HeapController::CalculateOldGenerationAllocationLimit( ...@@ -115,11 +113,12 @@ size_t HeapController::CalculateOldGenerationAllocationLimit(
mutator_speed); mutator_speed);
} }
if (growing_mode.kConservative() || growing_mode.kSlow()) { if (growing_mode == Heap::HeapGrowingMode::kConservative ||
growing_mode == Heap::HeapGrowingMode::kSlow) {
factor = Min(factor, kConservativeHeapGrowingFactor); factor = Min(factor, kConservativeHeapGrowingFactor);
} }
if (FLAG_stress_compaction || growing_mode.kMinimal()) { if (growing_mode == Heap::HeapGrowingMode::kMinimal) {
factor = kMinHeapGrowingFactor; factor = kMinHeapGrowingFactor;
} }
...@@ -152,7 +151,7 @@ size_t HeapController::MinimumAllocationLimitGrowingStep( ...@@ -152,7 +151,7 @@ size_t HeapController::MinimumAllocationLimitGrowingStep(
const size_t kRegularAllocationLimitGrowingStep = 8; const size_t kRegularAllocationLimitGrowingStep = 8;
const size_t kLowMemoryAllocationLimitGrowingStep = 2; const size_t kLowMemoryAllocationLimitGrowingStep = 2;
size_t limit = (Page::kPageSize > MB ? Page::kPageSize : MB); size_t limit = (Page::kPageSize > MB ? Page::kPageSize : MB);
return limit * (growing_mode.kConservative() return limit * (growing_mode == Heap::HeapGrowingMode::kConservative
? kLowMemoryAllocationLimitGrowingStep ? kLowMemoryAllocationLimitGrowingStep
: kRegularAllocationLimitGrowingStep); : kRegularAllocationLimitGrowingStep);
} }
......
...@@ -44,8 +44,6 @@ class HeapController { ...@@ -44,8 +44,6 @@ class HeapController {
double mutator_speed, double mutator_speed,
double max_factor); double max_factor);
static const double kMaxHeapGrowingFactorMemoryConstrained;
static const double kMaxHeapGrowingFactorIdle;
static const double kTargetMutatorUtilization; static const double kTargetMutatorUtilization;
Heap* heap_; Heap* heap_;
......
...@@ -4323,9 +4323,19 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation() { ...@@ -4323,9 +4323,19 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation() {
} }
Heap::HeapGrowingMode Heap::CurrentHeapGrowingMode() { Heap::HeapGrowingMode Heap::CurrentHeapGrowingMode() {
return Heap::HeapGrowingMode(ShouldOptimizeForMemoryUsage(), if (ShouldReduceMemory() || FLAG_stress_compaction) {
ShouldReduceMemory(), return Heap::HeapGrowingMode::kMinimal;
memory_reducer()->ShouldGrowHeapSlowly()); }
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. // This function returns either kNoLimit, kSoftLimit, or kHardLimit.
......
...@@ -2112,19 +2112,7 @@ class Heap { ...@@ -2112,19 +2112,7 @@ class Heap {
bool ShouldExpandOldGenerationOnSlowAllocation(); bool ShouldExpandOldGenerationOnSlowAllocation();
class HeapGrowingMode { enum class HeapGrowingMode { kSlow, kConservative, kMinimal, kDefault };
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_;
};
HeapGrowingMode CurrentHeapGrowingMode(); HeapGrowingMode CurrentHeapGrowingMode();
......
...@@ -74,29 +74,28 @@ TEST_F(HeapControllerTest, OldGenerationAllocationLimit) { ...@@ -74,29 +74,28 @@ TEST_F(HeapControllerTest, OldGenerationAllocationLimit) {
double factor = double factor =
HeapController::HeapGrowingFactor(gc_speed, mutator_speed, max_factor); HeapController::HeapGrowingFactor(gc_speed, mutator_speed, max_factor);
EXPECT_EQ( EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
static_cast<size_t>(old_gen_size * factor + new_space_capacity), heap->heap_controller()->CalculateOldGenerationAllocationLimit(
heap->heap_controller()->CalculateOldGenerationAllocationLimit( old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
old_gen_size, max_old_generation_size, gc_speed, mutator_speed, new_space_capacity, Heap::HeapGrowingMode::kDefault));
new_space_capacity, Heap::HeapGrowingMode(false, false, false)));
factor = Min(factor, HeapController::kConservativeHeapGrowingFactor); factor = Min(factor, HeapController::kConservativeHeapGrowingFactor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity), EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit( heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed, 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); factor = Min(factor, HeapController::kConservativeHeapGrowingFactor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity), EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit( heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed, 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; factor = HeapController::kMinHeapGrowingFactor;
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity), EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
heap->heap_controller()->CalculateOldGenerationAllocationLimit( heap->heap_controller()->CalculateOldGenerationAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed, 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) { 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