| Index: runtime/vm/pages.cc
|
| diff --git a/runtime/vm/pages.cc b/runtime/vm/pages.cc
|
| index 772806d260ffdcee2a21acd72d5bf70f8c67ee8c..c5ebaa59e7724abc219e8d4a3fd0fa0aed0743f9 100644
|
| --- a/runtime/vm/pages.cc
|
| +++ b/runtime/vm/pages.cc
|
| @@ -466,6 +466,7 @@ PageSpaceController::PageSpaceController(int heap_growth_ratio,
|
| : is_enabled_(false),
|
| grow_heap_(heap_growth_rate),
|
| heap_growth_ratio_(heap_growth_ratio),
|
| + desired_utilization_((100.0 - heap_growth_ratio) / 100.0),
|
| heap_growth_rate_(heap_growth_rate),
|
| garbage_collection_time_ratio_(garbage_collection_time_ratio) {
|
| }
|
| @@ -492,13 +493,14 @@ bool PageSpaceController::CanGrowPageSpace(intptr_t size_in_bytes) {
|
|
|
|
|
| void PageSpaceController::EvaluateGarbageCollection(
|
| - size_t in_use_before, size_t in_use_after, int64_t start, int64_t end) {
|
| + intptr_t in_use_before, intptr_t in_use_after, int64_t start, int64_t end) {
|
| ASSERT(in_use_before >= in_use_after);
|
| ASSERT(end >= start);
|
| history_.AddGarbageCollectionTime(start, end);
|
| int collected_garbage_ratio =
|
| static_cast<int>((static_cast<double>(in_use_before - in_use_after) /
|
| - static_cast<double>(in_use_before)) * 100);
|
| + static_cast<double>(in_use_before))
|
| + * 100.0);
|
| bool enough_free_space =
|
| (collected_garbage_ratio >= heap_growth_ratio_);
|
| int garbage_collection_time_fraction =
|
| @@ -525,7 +527,16 @@ void PageSpaceController::EvaluateGarbageCollection(
|
| }
|
| OS::PrintErr("\n");
|
| }
|
| - grow_heap_ = heap_growth_rate_;
|
| + if (!enough_free_space) {
|
| + intptr_t growth_target = static_cast<intptr_t>(in_use_after /
|
| + desired_utilization_);
|
| + intptr_t growth_in_bytes = Utils::RoundUp(growth_target - in_use_after,
|
| + PageSpace::kPageSize);
|
| + intptr_t growth_in_pages = growth_in_bytes / PageSpace::kPageSize;
|
| + grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_);
|
| + } else {
|
| + grow_heap_ = heap_growth_rate_;
|
| + }
|
| }
|
| }
|
|
|
|
|