Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: runtime/vm/pages.cc

Issue 2829853007: Some fixes to GC heuristics. (Closed)
Patch Set: spolling Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
diff --git a/runtime/vm/pages.cc b/runtime/vm/pages.cc
index 903eff459c6dca0f3b2650d01ac57b632263adab..beb81891ffcbe2bc6e1f9cbf5e4f95ee79864864 100644
--- a/runtime/vm/pages.cc
+++ b/runtime/vm/pages.cc
@@ -1217,7 +1217,11 @@ void PageSpaceController::EvaluateGarbageCollection(SpaceUsage before,
if (allocated_since_previous_gc > 0) {
const intptr_t garbage = before.used_in_words - after.used_in_words;
ASSERT(garbage >= 0);
- const double k = garbage / static_cast<double>(allocated_since_previous_gc);
+ // It makes no sense to expect that each kb allocated will cause more than
+ // one kb of garbage, so we clamp k at 1.0.
+ const double k = Utils::Minimum(
+ 1.0, garbage / static_cast<double>(allocated_since_previous_gc));
+
const int garbage_ratio = static_cast<int>(k * 100);
kasperl 2017/04/27 06:58:16 Maybe we wouldn't need this named constant if 'k'
heap_->RecordData(PageSpace::kGarbageRatio, garbage_ratio);
@@ -1247,7 +1251,7 @@ void PageSpaceController::EvaluateGarbageCollection(SpaceUsage before,
while (min < max) {
local_grow_heap = (max + min) / 2;
const intptr_t limit = after.capacity_in_words +
- (grow_heap_ * PageSpace::kPageSizeInWords);
+ (local_grow_heap * PageSpace::kPageSizeInWords);
const intptr_t allocated_before_next_gc = limit - after.used_in_words;
const double estimated_garbage = k * allocated_before_next_gc;
if (t <= estimated_garbage / limit) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698