Bug 1458154 - Add a tunable for idle nursery collection r=jonco

--HG--
extra : source : c5b1eae8a19756f85b8b059bff4bb1b4b8ab7c90
extra : amend_source : e1b38bbadd6d62efd22e754e752b064d175193ec
This commit is contained in:
Paul Bone 2018-02-12 17:17:33 +11:00
parent ac76d783ec
commit 5931e98c71
5 changed files with 44 additions and 9 deletions

View File

@ -256,6 +256,15 @@ typedef enum JSGCParamKey {
* Pref: None
*/
JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT = 26,
/**
* Attempt to run a minor GC in the idle time if the free space falls
* below this threshold.
*
* Default: NurseryChunkUsableSize / 4
* Pref: None
*/
JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION = 27,
} JSGCParamKey;
/*

View File

@ -336,6 +336,10 @@ namespace TuningDefaults {
/* JSGC_COMPACTING_ENABLED */
static const bool CompactingEnabled = true;
/* JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION */
static const uint32_t NurseryFreeThresholdForIdleCollection =
Nursery::NurseryChunkUsableSize / 4;
}}} // namespace js::gc::TuningDefaults
/*
@ -1479,6 +1483,11 @@ GCSchedulingTunables::setParameter(JSGCParamKey key, uint32_t value, const AutoL
case JSGC_MAX_EMPTY_CHUNK_COUNT:
setMaxEmptyChunkCount(value);
break;
case JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION:
if (value > gcMaxNurseryBytes())
value = gcMaxNurseryBytes();
nurseryFreeThresholdForIdleCollection_ = value;
break;
default:
MOZ_CRASH("Unknown GC parameter.");
}
@ -1572,7 +1581,8 @@ GCSchedulingTunables::GCSchedulingTunables()
lowFrequencyHeapGrowth_(TuningDefaults::LowFrequencyHeapGrowth),
dynamicMarkSliceEnabled_(TuningDefaults::DynamicMarkSliceEnabled),
minEmptyChunkCount_(TuningDefaults::MinEmptyChunkCount),
maxEmptyChunkCount_(TuningDefaults::MaxEmptyChunkCount)
maxEmptyChunkCount_(TuningDefaults::MaxEmptyChunkCount),
nurseryFreeThresholdForIdleCollection_(TuningDefaults::NurseryFreeThresholdForIdleCollection)
{}
void
@ -1653,6 +1663,10 @@ GCSchedulingTunables::resetParameter(JSGCParamKey key, const AutoLockGC& lock)
case JSGC_MAX_EMPTY_CHUNK_COUNT:
setMaxEmptyChunkCount(TuningDefaults::MaxEmptyChunkCount);
break;
case JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION:
nurseryFreeThresholdForIdleCollection_ =
TuningDefaults::NurseryFreeThresholdForIdleCollection;
break;
default:
MOZ_CRASH("Unknown GC parameter.");
}

View File

@ -676,6 +676,13 @@ js::Nursery::endProfile(ProfileKey key)
totalDurations_[key] += profileDurations_[key];
}
bool
js::Nursery::needIdleTimeCollection() const {
uint32_t threshold =
runtime()->gc.tunables.nurseryFreeThresholdForIdleCollection();
return minorGCRequested() || freeSpace() < threshold;
}
static inline bool
IsFullStoreBufferReason(JS::gcreason::Reason reason)
{

View File

@ -333,20 +333,14 @@ class Nursery
JS::gcreason::Reason minorGCTriggerReason() const { return minorGCTriggerReason_; }
void clearMinorGCRequest() { minorGCTriggerReason_ = JS::gcreason::NO_REASON; }
bool needIdleTimeCollection() const {
return minorGCRequested() ||
(freeSpace() < kIdleTimeCollectionThreshold);
}
bool needIdleTimeCollection() const;
bool enableProfiling() const { return enableProfiling_; }
private:
/* The amount of space in the mapped nursery available to allocations. */
static const size_t NurseryChunkUsableSize = gc::ChunkSize - gc::ChunkTrailerSize;
/* Attemp to run a minor GC in the idle time if the free space falls below this threshold. */
static constexpr size_t kIdleTimeCollectionThreshold = NurseryChunkUsableSize / 4;
private:
JSRuntime* runtime_;
/* Vector of allocated chunks to allocate from. */

View File

@ -429,6 +429,14 @@ class GCSchedulingTunables
UnprotectedData<uint32_t> minEmptyChunkCount_;
UnprotectedData<uint32_t> maxEmptyChunkCount_;
/*
* JSGC_NURSERY_FREE_THRESHOLD_FOR_IDLE_COLLECTION
*
* Attempt to run a minor GC in the idle time if the free space falls
* below this threshold.
*/
UnprotectedData<uint32_t> nurseryFreeThresholdForIdleCollection_;
public:
GCSchedulingTunables();
@ -449,6 +457,9 @@ class GCSchedulingTunables
bool isDynamicMarkSliceEnabled() const { return dynamicMarkSliceEnabled_; }
unsigned minEmptyChunkCount(const AutoLockGC&) const { return minEmptyChunkCount_; }
unsigned maxEmptyChunkCount() const { return maxEmptyChunkCount_; }
uint32_t nurseryFreeThresholdForIdleCollection() const {
return nurseryFreeThresholdForIdleCollection_;
}
MOZ_MUST_USE bool setParameter(JSGCParamKey key, uint32_t value, const AutoLockGC& lock);
void resetParameter(JSGCParamKey key, const AutoLockGC& lock);