Bug 1640844 - Part 5: Take account of how much time we spend collecting when calculating nursery size r=sfink

This adds a goal of using less then 1% of total time collecthing the nursery, which has the effect of increasing the nursery size where a lot of nursery garbage is created but little is tenured.

In local testing this is a win on ARES6 and octane, but perfherder paints a more ambiguous picture.  I'd like to land this anyway and we can back it out if it causes problems.

Differential Revision: https://phabricator.services.mozilla.com/D80003
This commit is contained in:
Jon Coppeard 2020-07-13 07:49:32 +00:00
Родитель 7e76f843c7
Коммит 7d07e35bc9
2 изменённых файлов: 20 добавлений и 3 удалений

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

@ -1557,10 +1557,22 @@ size_t js::Nursery::targetSize(JSGCInvocationKind kind, JS::GCReason reason) {
double fractionPromoted =
double(previousGC.tenuredBytes) / double(previousGC.nurseryCapacity);
// Adjust the nursery size to try to achieve a target promotion rate.
static const double PromotionGoal = 0.02;
// Calculate the fraction of time spent collecting the nursery.
double timeFraction = 0.0;
#ifndef JS_MORE_DETERMINISTIC
if (lastResizeTime) {
TimeDuration collectorTime = now - collectionStartTime();
TimeDuration totalTime = now - lastResizeTime;
timeFraction = collectorTime.ToSeconds() / totalTime.ToSeconds();
}
#endif
double growthFactor = fractionPromoted / PromotionGoal;
// Adjust the nursery size to try to achieve a target promotion rate and
// collector time goals.
static const double PromotionGoal = 0.02;
static const double TimeGoal = 0.01;
double growthFactor =
std::max(fractionPromoted / PromotionGoal, timeFraction / TimeGoal);
// Limit the range of the growth factor to prevent transient high promotion
// rates from affecting the nursery size too far into the future.
@ -1574,6 +1586,7 @@ size_t js::Nursery::targetSize(JSGCInvocationKind kind, JS::GCReason reason) {
now - lastResizeTime < TimeDuration::FromMilliseconds(200)) {
growthFactor = 0.75 * smoothedGrowthFactor + 0.25 * growthFactor;
}
lastResizeTime = now;
smoothedGrowthFactor = growthFactor;
#endif

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

@ -426,6 +426,10 @@ class Nursery {
void joinDecommitTask() { decommitTask.join(); }
mozilla::TimeStamp collectionStartTime() {
return startTimes_[ProfileKey::Total];
}
// Round a size in bytes to the nearest valid nursery size.
static size_t roundSize(size_t size);