Skip to content

Commit 0bfc739

Browse files
committed
Bug 1967467 - Add a GC parameter to control the nursery's max collection time target r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D250397 UltraBlame original commit: 6c3309f5718e483e9c32d901e1badc237cb48037
1 parent 3f6f2de commit 0bfc739

File tree

9 files changed

+44
-4
lines changed

9 files changed

+44
-4
lines changed

dom/base/nsJSEnvironment.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,11 @@ void nsJSContext::EnsureStatics() {
19781978
"javascript.options.mem.nursery_eager_collection_timeout_ms",
19791979
(void*)JSGC_NURSERY_EAGER_COLLECTION_TIMEOUT_MS);
19801980

1981+
Preferences::RegisterCallbackAndCall(
1982+
SetMemoryPrefChangedCallbackInt,
1983+
"javascript.options.mem.nursery_max_time_goal_ms",
1984+
(void*)JSGC_NURSERY_MAX_TIME_GOAL_MS);
1985+
19811986
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
19821987
if (!obs) {
19831988
MOZ_CRASH();

dom/workers/RuntimeService.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ void LoadJSGCMemoryOptions(const char* aPrefName, void* ) {
375375
#ifdef NIGHTLY_BUILD
376376
PREF("gc_experimental_semispace_nursery", JSGC_SEMISPACE_NURSERY_ENABLED),
377377
#endif
378+
PREF("nursery_max_time_goal_ms", JSGC_NURSERY_MAX_TIME_GOAL_MS),
378379

379380

380381

@@ -454,6 +455,7 @@ void LoadJSGCMemoryOptions(const char* aPrefName, void* ) {
454455
case JSGC_HEAP_GROWTH_FACTOR:
455456
case JSGC_PARALLEL_MARKING_THRESHOLD_MB:
456457
case JSGC_MAX_MARKING_THREADS:
458+
case JSGC_NURSERY_MAX_TIME_GOAL_MS:
457459
UpdateCommonJSGCMemoryOption(rts, pref->fullName, pref->key);
458460
break;
459461
default:

js/public/GCAPI.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,20 @@ typedef enum JSGCParamKey {
494494

495495

496496
JSGC_HIGH_FREQUENCY_MODE = 56,
497+
498+
499+
500+
501+
502+
503+
504+
505+
506+
507+
508+
509+
510+
JSGC_NURSERY_MAX_TIME_GOAL_MS = 57,
497511
} JSGCParamKey;
498512

499513

js/src/gc/GC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ArenaChunk;
7676
JSGC_NURSERY_EAGER_COLLECTION_THRESHOLD_PERCENT, true) \
7777
_("nurseryEagerCollectionTimeoutMS", \
7878
JSGC_NURSERY_EAGER_COLLECTION_TIMEOUT_MS, true) \
79+
_("nurseryMaxTimeGoalMS", JSGC_NURSERY_MAX_TIME_GOAL_MS, true) \
7980
_("zoneAllocDelayKB", JSGC_ZONE_ALLOC_DELAY_KB, true) \
8081
_("mallocThresholdBase", JSGC_MALLOC_THRESHOLD_BASE, true) \
8182
_("urgentThreshold", JSGC_URGENT_THRESHOLD_MB, true) \

js/src/gc/Nursery.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,9 +2452,10 @@ size_t js::Nursery::targetSize(JS::GCOptions options, JS::GCReason reason) {
24522452

24532453

24542454

2455-
static const double MaxTimeGoalMs = 4.0;
2456-
if (!gc->isInPageLoad() && !js::SupportDifferentialTesting()) {
2457-
double timeGrowth = MaxTimeGoalMs / collectorTime.ToMilliseconds();
2455+
double maxTimeGoalMS = tunables().nurseryMaxTimeGoalMS().ToMilliseconds();
2456+
if (!gc->isInPageLoad() && maxTimeGoalMS != 0.0 &&
2457+
!js::SupportDifferentialTesting()) {
2458+
double timeGrowth = maxTimeGoalMS / collectorTime.ToMilliseconds();
24582459
growthFactor = std::min(growthFactor, timeGrowth);
24592460
}
24602461
#endif

js/src/gc/Scheduling.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,14 @@
500500
* JSGC_GENERATE_MISSING_ALLOC_SITES \
501501
*/ \
502502
_(JSGC_GENERATE_MISSING_ALLOC_SITES, bool, generateMissingAllocSites, \
503-
ConvertBool, NoCheck, false)
503+
ConvertBool, NoCheck, false) \
504+
\
505+
/* \
506+
* JSGC_NURSERY_MAX_TIME_GOAL_MS \
507+
*/ \
508+
_(JSGC_NURSERY_MAX_TIME_GOAL_MS, mozilla::TimeDuration, \
509+
nurseryMaxTimeGoalMS, ConvertMillis, NoCheck, \
510+
mozilla::TimeDuration::FromMilliseconds(4))
504511

505512
namespace js {
506513

js/src/jit-test/tests/gc/gcparam.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ testChangeParam("urgentThreshold");
6060
testChangeParam("helperThreadRatio");
6161
testChangeParam("maxHelperThreads");
6262
testChangeParam("semispaceNurseryEnabled");
63+
testChangeParam("nurseryMaxTimeGoalMS");

modules/libpref/init/all.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,9 @@ pref("javascript.options.mem.nursery_eager_collection_threshold_percent", 25);
10211021

10221022
pref("javascript.options.mem.nursery_eager_collection_timeout_ms", 5000);
10231023

1024+
1025+
pref("javascript.options.mem.nursery_max_time_goal_ms", 4);
1026+
10241027
#ifdef JS_GC_ZEAL
10251028
pref("javascript.options.mem.gc_zeal.mode", 0);
10261029
pref("javascript.options.mem.gc_zeal.frequency", 5000);

toolkit/components/nimbus/FeatureManifest.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3708,6 +3708,12 @@ gc:
37083708
setPref:
37093709
branch: user
37103710
pref: "javascript.options.mem.nursery_eager_collection_timeout_ms"
3711+
nursery_max_time_goal_ms:
3712+
description: Set the nursery's maximum time goal, in ms.
3713+
type: int
3714+
setPref:
3715+
branch: user
3716+
pref: "javascript.options.mem.nursery_max_time_goal_ms"
37113717

37123718
jsParallelParsing:
37133719
description: Pref to toggle JS parallel parsing.

0 commit comments

Comments
 (0)