Bug 1032750 - Don't update GC triggers on uncollected zones r=terrence

This commit is contained in:
Jon Coppeard 2014-07-02 08:05:58 +01:00
parent 514348c3a1
commit eb8fe4ffcf
3 changed files with 17 additions and 5 deletions

View File

@ -107,6 +107,13 @@ Zone::onTooMuchMalloc()
}
}
bool
Zone::isCloseToAllocTrigger(bool highFrequencyGC) const
{
double factor = highFrequencyGC ? 0.85 : 0.9;
return usage.gcBytes() >= factor * threshold.gcTriggerBytes();
}
void
Zone::beginSweepTypes(FreeOp *fop, bool releaseTypes)
{

View File

@ -153,6 +153,8 @@ struct Zone : public JS::shadow::Zone,
bool isTooMuchMalloc() const { return gcMallocBytes <= 0; }
void onTooMuchMalloc();
bool isCloseToAllocTrigger(bool highFrequencyGC) const;
void *onOutOfMemory(void *p, size_t nbytes) {
return runtimeFromMainThread()->onOutOfMemory(p, nbytes);
}

View File

@ -1113,7 +1113,7 @@ GCRuntime::GCRuntime(JSRuntime *rt) :
verifyPostData(nullptr),
chunkAllocationSinceLastGC(false),
nextFullGCTime(0),
lastGCTime(0),
lastGCTime(PRMJ_Now()),
mode(JSGC_MODE_INCREMENTAL),
decommitThreshold(32 * 1024 * 1024),
cleanUpEverything(false),
@ -3308,9 +3308,8 @@ GCRuntime::maybeGC(Zone *zone)
if (gcIfNeeded())
return true;
double factor = schedulingState.inHighFrequencyGCMode() ? 0.85 : 0.9;
if (zone->usage.gcBytes() > 1024 * 1024 &&
zone->usage.gcBytes() >= factor * zone->threshold.gcTriggerBytes() &&
zone->isCloseToAllocTrigger(schedulingState.inHighFrequencyGCMode()) &&
incrementalState == NO_INCREMENTAL &&
!isBackgroundSweeping())
{
@ -5628,10 +5627,10 @@ GCRuntime::finishCollection()
schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables);
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
zone->threshold.updateAfterGC(zone->usage.gcBytes(), invocationKind, tunables,
schedulingState);
if (zone->isCollecting()) {
MOZ_ASSERT(zone->isGCFinished() || zone->isGCCompacting());
zone->threshold.updateAfterGC(zone->usage.gcBytes(), invocationKind, tunables,
schedulingState);
zone->setGCState(Zone::NoGC);
zone->active = false;
}
@ -6219,6 +6218,10 @@ GCRuntime::scanZonesBeforeGC()
if (incrementalState != NO_INCREMENTAL && zone->needsIncrementalBarrier())
zone->scheduleGC();
/* This is a heuristic to reduce the total number of collections. */
if (zone->isCloseToAllocTrigger(schedulingState.inHighFrequencyGCMode()))
zone->scheduleGC();
zoneStats.zoneCount++;
if (zone->isGCScheduled()) {
zoneStats.collectedZoneCount++;