Bug 1770768 - Part 2: Add a GC parameter for the heap growth factor used when balanced heap limits are enabled r=sfink

Differential Revision: https://phabricator.services.mozilla.com/D152863
This commit is contained in:
Jon Coppeard 2022-08-02 10:05:05 +00:00
Родитель 9d60e6b077
Коммит d5ad2725fb
6 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -233,6 +233,16 @@ typedef enum JSGCParamKey {
*/
JSGC_BALANCED_HEAP_LIMITS_ENABLED = 17,
/**
* Heap growth parameter for balanced heap limit calculation.
*
* This parameter trades off GC time for memory usage. Smaller values result
* in lower memory use and larger values result in less time spent collecting.
*
* Default: HeapGrowthFactor
*/
JSGC_HEAP_GROWTH_FACTOR = 18,
/**
* Lower limit for collecting a zone (MB).
*

Просмотреть файл

@ -1166,6 +1166,8 @@ uint32_t GCRuntime::getParameter(JSGCParamKey key, const AutoLockGC& lock) {
return uint32_t(tunables.lowFrequencyHeapGrowth() * 100);
case JSGC_BALANCED_HEAP_LIMITS_ENABLED:
return uint32_t(tunables.balancedHeapLimitsEnabled());
case JSGC_HEAP_GROWTH_FACTOR:
return uint32_t(tunables.heapGrowthFactor());
case JSGC_ALLOCATION_THRESHOLD:
return tunables.gcZoneAllocThresholdBase() / 1024 / 1024;
case JSGC_SMALL_HEAP_INCREMENTAL_LIMIT:

Просмотреть файл

@ -61,6 +61,7 @@ struct Cell;
true) \
_("lowFrequencyHeapGrowth", JSGC_LOW_FREQUENCY_HEAP_GROWTH, true) \
_("balancedHeapLimitsEnabled", JSGC_BALANCED_HEAP_LIMITS_ENABLED, true) \
_("heapGrowthFactor", JSGC_HEAP_GROWTH_FACTOR, true) \
_("allocationThreshold", JSGC_ALLOCATION_THRESHOLD, true) \
_("smallHeapIncrementalLimit", JSGC_SMALL_HEAP_INCREMENTAL_LIMIT, true) \
_("largeHeapIncrementalLimit", JSGC_LARGE_HEAP_INCREMENTAL_LIMIT, true) \

Просмотреть файл

@ -56,6 +56,7 @@ GCSchedulingTunables::GCSchedulingTunables()
TuningDefaults::HighFrequencyLargeHeapGrowth),
lowFrequencyHeapGrowth_(TuningDefaults::LowFrequencyHeapGrowth),
balancedHeapLimitsEnabled_(TuningDefaults::BalancedHeapLimitsEnabled),
heapGrowthFactor_(TuningDefaults::HeapGrowthFactor),
nurseryFreeThresholdForIdleCollection_(
TuningDefaults::NurseryFreeThresholdForIdleCollection),
nurseryFreeThresholdForIdleCollectionFraction_(
@ -148,6 +149,10 @@ bool GCSchedulingTunables::setParameter(JSGCParamKey key, uint32_t value) {
setLowFrequencyHeapGrowth(newGrowth);
break;
}
case JSGC_HEAP_GROWTH_FACTOR: {
setHeapGrowthFactor(double(value));
break;
}
case JSGC_ALLOCATION_THRESHOLD: {
size_t threshold;
if (!megabytesToBytes(value, &threshold)) {
@ -314,6 +319,10 @@ void GCSchedulingTunables::setLowFrequencyHeapGrowth(double value) {
MOZ_ASSERT(lowFrequencyHeapGrowth_ >= MinHeapGrowthFactor);
}
void GCSchedulingTunables::setHeapGrowthFactor(double value) {
heapGrowthFactor_ = value;
}
void GCSchedulingTunables::resetParameter(JSGCParamKey key) {
switch (key) {
case JSGC_MAX_BYTES:
@ -349,6 +358,9 @@ void GCSchedulingTunables::resetParameter(JSGCParamKey key) {
case JSGC_BALANCED_HEAP_LIMITS_ENABLED:
balancedHeapLimitsEnabled_ = TuningDefaults::BalancedHeapLimitsEnabled;
break;
case JSGC_HEAP_GROWTH_FACTOR:
setHeapGrowthFactor(TuningDefaults::HeapGrowthFactor);
break;
case JSGC_ALLOCATION_THRESHOLD:
gcZoneAllocThresholdBase_ = TuningDefaults::GCZoneAllocThresholdBase;
break;

Просмотреть файл

@ -387,6 +387,9 @@ static const double HighFrequencyLargeHeapGrowth = 1.5;
/* JSGC_LOW_FREQUENCY_HEAP_GROWTH */
static const double LowFrequencyHeapGrowth = 1.5;
/* JSGC_HEAP_GROWTH_FACTOR */
static const double HeapGrowthFactor = 40.0;
/* JSGC_MIN_EMPTY_CHUNK_COUNT */
static const uint32_t MinEmptyChunkCount = 1;
@ -536,6 +539,11 @@ class GCSchedulingTunables {
*/
MainThreadOrGCTaskData<bool> balancedHeapLimitsEnabled_;
/*
* JSGC_HEAP_GROWTH_FACTOR
*/
MainThreadOrGCTaskData<double> heapGrowthFactor_;
/*
* JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION
* JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION_FRACTION
@ -634,6 +642,7 @@ class GCSchedulingTunables {
}
double lowFrequencyHeapGrowth() const { return lowFrequencyHeapGrowth_; }
bool balancedHeapLimitsEnabled() const { return balancedHeapLimitsEnabled_; }
double heapGrowthFactor() const { return heapGrowthFactor_; }
uint32_t nurseryFreeThresholdForIdleCollection() const {
return nurseryFreeThresholdForIdleCollection_;
}
@ -669,6 +678,9 @@ class GCSchedulingTunables {
void setHighFrequencySmallHeapGrowth(double value);
void setHighFrequencyLargeHeapGrowth(double value);
void setLowFrequencyHeapGrowth(double value);
void setHeapGrowthFactor(double value);
void setMinEmptyChunkCount(uint32_t value);
void setMaxEmptyChunkCount(uint32_t value);
static bool megabytesToBytes(uint32_t value, size_t* bytesOut);
static bool kilobytesToBytes(uint32_t value, size_t* bytesOut);

Просмотреть файл

@ -46,6 +46,7 @@ testChangeParam("highFrequencySmallHeapGrowth");
testChangeParam("highFrequencyLargeHeapGrowth");
testChangeParam("lowFrequencyHeapGrowth");
testChangeParam("balancedHeapLimitsEnabled");
testChangeParam("heapGrowthFactor");
testChangeParam("allocationThreshold");
testChangeParam("smallHeapIncrementalLimit");
testChangeParam("largeHeapIncrementalLimit");