Commit 4735bc7e authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Commit Bot

[heap] Fixing the performance issue of the new heap growing strategy.

Bug: chromium:852748
Change-Id: Ifdadf3188815fe38741e6f0e817070972e7f445b
Reviewed-on: https://chromium-review.googlesource.com/1108205
Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53904}
parent a6d35890
......@@ -115,12 +115,11 @@ size_t HeapController::CalculateOldGenerationAllocationLimit(
mutator_speed);
}
if (growing_mode == Heap::HeapGrowingMode::kConservative) {
if (growing_mode.kConservative() || growing_mode.kSlow()) {
factor = Min(factor, kConservativeHeapGrowingFactor);
}
if (FLAG_stress_compaction ||
growing_mode == Heap::HeapGrowingMode::kMinimal) {
if (FLAG_stress_compaction || growing_mode.kMinimal()) {
factor = kMinHeapGrowingFactor;
}
......@@ -153,8 +152,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 == Heap::HeapGrowingMode::kConservative ||
growing_mode == Heap::HeapGrowingMode::kMinimal
return limit * (growing_mode.kConservative()
? kLowMemoryAllocationLimitGrowingStep
: kRegularAllocationLimitGrowingStep);
}
......
......@@ -4323,14 +4323,9 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation() {
}
Heap::HeapGrowingMode Heap::CurrentHeapGrowingMode() {
if (ShouldReduceMemory()) return HeapGrowingMode::kMinimal;
if (memory_reducer()->ShouldGrowHeapSlowly() ||
ShouldOptimizeForMemoryUsage()) {
return HeapGrowingMode::kConservative;
}
return HeapGrowingMode::kDefault;
return Heap::HeapGrowingMode(ShouldOptimizeForMemoryUsage(),
ShouldReduceMemory(),
memory_reducer()->ShouldGrowHeapSlowly());
}
// This function returns either kNoLimit, kSoftLimit, or kHardLimit.
......
......@@ -2112,7 +2112,20 @@ class Heap {
bool ShouldExpandOldGenerationOnSlowAllocation();
enum class HeapGrowingMode { kDefault, kConservative, kMinimal };
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_;
};
HeapGrowingMode CurrentHeapGrowingMode();
enum class IncrementalMarkingLimit { kNoLimit, kSoftLimit, kHardLimit };
......
......@@ -74,22 +74,29 @@ 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)));
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::kDefault));
new_space_capacity, Heap::HeapGrowingMode(true, false, false)));
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::kConservative));
new_space_capacity, Heap::HeapGrowingMode(false, false, true)));
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::kMinimal));
new_space_capacity, Heap::HeapGrowingMode(false, true, false)));
}
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