Bug 1593270 - Take account of adjusted slice budget when recording how long over budget slices ran r=allstarschh

The problem is that we change the slice budget after passing it to gcstats::AutoGCSlice. Later on we compare the actual time taken against the old value and think we've overrun our budget. The fix is to make the change earlier.

Depends on D52161

Differential Revision: https://phabricator.services.mozilla.com/D52162

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jon Coppeard 2019-11-07 15:14:45 +00:00
parent a52ff2f347
commit d5ecf971f1
2 changed files with 24 additions and 17 deletions

View File

@ -6965,21 +6965,6 @@ inline void GCRuntime::checkZoneIsScheduled(Zone* zone, JS::GCReason reason,
#endif
}
static double LinearInterpolate(double x, double x0, double y0, double x1,
double y1) {
MOZ_ASSERT(x0 < x1);
if (x < x0) {
return y0;
}
if (x < x1) {
return y0 + (y1 - y0) * ((x - x0) / (x1 - x0));
}
return y1;
}
GCRuntime::IncrementalResult GCRuntime::budgetIncrementalGC(
bool nonincrementalByAPI, JS::GCReason reason, SliceBudget& budget) {
if (nonincrementalByAPI) {
@ -7066,6 +7051,25 @@ GCRuntime::IncrementalResult GCRuntime::budgetIncrementalGC(
return resetIncrementalGC(resetReason);
}
return IncrementalResult::Ok;
}
static double LinearInterpolate(double x, double x0, double y0, double x1,
double y1) {
MOZ_ASSERT(x0 < x1);
if (x < x0) {
return y0;
}
if (x < x1) {
return y0 + (y1 - y0) * ((x - x0) / (x1 - x0));
}
return y1;
}
void GCRuntime::maybeIncreaseSliceBudget(SliceBudget& budget) {
#ifndef JS_MORE_DETERMINISTIC
// Increase time budget for long-running incremental collections. Enforce a
// minimum time budget that increases linearly with time/slice count up to a
@ -7092,8 +7096,6 @@ GCRuntime::IncrementalResult GCRuntime::budgetIncrementalGC(
}
}
#endif // JS_MORE_DETERMINISTIC
return IncrementalResult::Ok;
}
static void ScheduleZones(GCRuntime* gc) {
@ -7190,6 +7192,10 @@ MOZ_NEVER_INLINE GCRuntime::IncrementalResult GCRuntime::gcCycle(
// Note that GC callbacks are allowed to re-enter GC.
AutoCallGCCallbacks callCallbacks(*this);
// Increase slice budget for long running collections before it is recorded by
// AutoGCSlice.
maybeIncreaseSliceBudget(budget);
ScheduleZones(this);
gcstats::AutoGCSlice agc(stats(), scanZonesBeforeGC(),
gckind.valueOr(invocationKind), budget, reason);

View File

@ -595,6 +595,7 @@ class GCRuntime {
void requestMajorGC(JS::GCReason reason);
SliceBudget defaultBudget(JS::GCReason reason, int64_t millis);
void maybeIncreaseSliceBudget(SliceBudget& budget);
IncrementalResult budgetIncrementalGC(bool nonincrementalByAPI,
JS::GCReason reason,
SliceBudget& budget);