From 45d7cc2fc41d7192366cae536e4b8f7d8e61006b Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Wed, 1 Nov 2017 11:07:13 +0000 Subject: [PATCH] Bug 1413218 - Make the malloc threashold grow a little slower r=sfink --- js/src/jsgc.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 22183e967540..6c9872ee88e4 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -288,6 +288,15 @@ namespace TuningDefaults { /* JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT */ static const float AllocThresholdFactorAvoidInterrupt = 0.9f; + /* no parameter */ + static const float MallocThresholdGrowFactor = 1.5f; + + /* no parameter */ + static const float MallocThresholdShrinkFactor = 0.9f; + + /* no parameter */ + static const size_t MallocThresholdLimit = 1024 * 1024 * 1024; + /* no parameter */ static const size_t ZoneAllocDelayBytes = 1024 * 1024; @@ -1380,7 +1389,7 @@ GCSchedulingTunables::setParameter(JSGCParamKey key, uint32_t value, const AutoL void GCSchedulingTunables::setMaxMallocBytes(size_t value) { - maxMallocBytes_ = value; + maxMallocBytes_ = std::min(value, TuningDefaults::MallocThresholdLimit); } void @@ -1917,10 +1926,13 @@ MemoryCounter::updateOnGCEnd(const GCSchedulingTunables& tunables, const AutoLoc // Update the trigger threshold at the end of GC and adjust the current // byte count to reflect bytes allocated since the start of GC. MOZ_ASSERT(bytes_ >= bytesAtStartOfGC_); - if (shouldTriggerGC(tunables)) - maxBytes_ *= 2; - else - maxBytes_ = std::max(tunables.maxMallocBytes(), size_t(maxBytes_ * 0.9)); + if (shouldTriggerGC(tunables)) { + maxBytes_ = std::min(TuningDefaults::MallocThresholdLimit, + size_t(maxBytes_ * TuningDefaults::MallocThresholdGrowFactor)); + } else { + maxBytes_ = std::max(tunables.maxMallocBytes(), + size_t(maxBytes_ * TuningDefaults::MallocThresholdShrinkFactor)); + } bytes_ -= bytesAtStartOfGC_; triggered_ = NoTrigger; }