Commit 748e3394 authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Commit Bot

[heap ]Added test to verify the output of CalculateOldGenerationAllocationLimit.

Bug: chromium:845409
Change-Id: Id8b89e6dac48bba9065ac9f04ce48f951aa2186b
Reviewed-on: https://chromium-review.googlesource.com/1092860
Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53617}
parent 7f442da6
...@@ -18,7 +18,7 @@ class HeapController { ...@@ -18,7 +18,7 @@ class HeapController {
explicit HeapController(Heap* heap) : heap_(heap) {} explicit HeapController(Heap* heap) : heap_(heap) {}
// Computes the allocation limit to trigger the next full garbage collection. // Computes the allocation limit to trigger the next full garbage collection.
size_t CalculateOldGenerationAllocationLimit( V8_EXPORT_PRIVATE size_t CalculateOldGenerationAllocationLimit(
size_t old_gen_size, size_t max_old_generation_size, double gc_speed, size_t old_gen_size, size_t max_old_generation_size, double gc_speed,
double mutator_speed, size_t new_space_capacity, double mutator_speed, size_t new_space_capacity,
Heap::HeapGrowingMode growing_mode); Heap::HeapGrowingMode growing_mode);
...@@ -33,10 +33,11 @@ class HeapController { ...@@ -33,10 +33,11 @@ class HeapController {
private: private:
FRIEND_TEST(HeapController, HeapGrowingFactor); FRIEND_TEST(HeapController, HeapGrowingFactor);
FRIEND_TEST(HeapController, MaxHeapGrowingFactor); FRIEND_TEST(HeapController, MaxHeapGrowingFactor);
FRIEND_TEST(HeapController, OldGenerationSize); FRIEND_TEST(HeapControllerTest, OldGenerationAllocationLimit);
V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor; V8_EXPORT_PRIVATE static const double kMinHeapGrowingFactor;
V8_EXPORT_PRIVATE static const double kMaxHeapGrowingFactor; V8_EXPORT_PRIVATE static const double kMaxHeapGrowingFactor;
V8_EXPORT_PRIVATE static const double kConservativeHeapGrowingFactor;
V8_EXPORT_PRIVATE static double MaxHeapGrowingFactor( V8_EXPORT_PRIVATE static double MaxHeapGrowingFactor(
size_t max_old_generation_size); size_t max_old_generation_size);
V8_EXPORT_PRIVATE static double HeapGrowingFactor(double gc_speed, V8_EXPORT_PRIVATE static double HeapGrowingFactor(double gc_speed,
...@@ -45,7 +46,6 @@ class HeapController { ...@@ -45,7 +46,6 @@ class HeapController {
static const double kMaxHeapGrowingFactorMemoryConstrained; static const double kMaxHeapGrowingFactorMemoryConstrained;
static const double kMaxHeapGrowingFactorIdle; static const double kMaxHeapGrowingFactorIdle;
static const double kConservativeHeapGrowingFactor;
static const double kTargetMutatorUtilization; static const double kTargetMutatorUtilization;
Heap* heap_; Heap* heap_;
......
...@@ -2524,6 +2524,8 @@ class Heap { ...@@ -2524,6 +2524,8 @@ class Heap {
// Used in cctest. // Used in cctest.
friend class heap::HeapTester; friend class heap::HeapTester;
FRIEND_TEST(HeapControllerTest, OldGenerationAllocationLimit);
DISALLOW_COPY_AND_ASSIGN(Heap); DISALLOW_COPY_AND_ASSIGN(Heap);
}; };
......
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
#include "src/handles.h" #include "src/handles.h"
#include "src/heap/heap-controller.h" #include "src/heap/heap-controller.h"
#include "src/heap/heap.h"
#include "test/unittests/test-utils.h" #include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
typedef TestWithIsolate HeapControllerTest;
double Round(double x) { double Round(double x) {
// Round to three digits. // Round to three digits.
return floor(x * 1000 + 0.5) / 1000; return floor(x * 1000 + 0.5) / 1000;
...@@ -60,7 +61,38 @@ TEST(HeapController, MaxHeapGrowingFactor) { ...@@ -60,7 +61,38 @@ TEST(HeapController, MaxHeapGrowingFactor) {
static_cast<size_t>(HeapController::kMaxOldGenerationSize) * MB)); static_cast<size_t>(HeapController::kMaxOldGenerationSize) * MB));
} }
TEST(HeapController, OldGenerationSize) { TEST_F(HeapControllerTest, OldGenerationAllocationLimit) {
Heap* heap = i_isolate()->heap();
size_t old_gen_size = 128 * MB;
size_t max_old_generation_size = 512 * MB;
double gc_speed = 100;
double mutator_speed = 1;
size_t new_space_capacity = 16 * MB;
double max_factor =
HeapController::MaxHeapGrowingFactor(max_old_generation_size);
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::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::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::kMinimal));
}
TEST(HeapController, MaxOldGenerationSize) {
uint64_t configurations[][2] = { uint64_t configurations[][2] = {
{0, HeapController::kMinOldGenerationSize}, {0, HeapController::kMinOldGenerationSize},
{512, HeapController::kMinOldGenerationSize}, {512, HeapController::kMinOldGenerationSize},
......
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