Open Bug 1515380 Opened 6 years ago Updated 2 years ago

[meta] Shrink GC nursery on background tabs

Categories

(Core :: JavaScript: GC, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: tcampbell, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: meta, Whiteboard: [overhead:800k])

The nursery is currently a large contributor to content process overhead. It is currently a fixed 1MB allocation that does not go away. On the other hand, the nursery is an important part of browser performance.

Heuristics for dynamically resizing the nursery are hard to get right, but we can instead use the notion of background/throttled tabs. This should be a little more predictable and prioritize foreground tabs.

In Bug 1433007, :pbone has been observing that reducing the nursery size to ~160kB still leaves something functional. This is probably a good starting goal for off-thread. The GC supports disabling the nursery entirely, but that may have weirder perf side-effects than we can tolerate.

In Bug 1468099, the TabGroup::HasOnlyThrottableTabs() API was added which might be a good starting point. Another point may be nsJSEnvironmentObserver::Observe() if we need an observer event. We can discuss with dom / front-end about how to fire this event.
Depends on: 1515383
(from jesup on IRC)

Background tabs can have (significant) JS running, like webrtc, webaudio, video (audio) playback, etc. And background has two variants: non-focused-but-visible (i.e. another window), and non-visible. We have to care about such aspects for things like timer request throttling already, so we could key off of those decisions. This also can interact with the Page Lifecycle API proposal (which includes freezing or unloading background tabs to the existing cycle). I'd presume non-visible is the focus. [jonco agreed]
The |HasOnlyThrottableTabs| API should be covering those much of that: https://searchfox.org/mozilla-central/source/dom/base/TimeoutManager.cpp#1088-1092
Summary: Shrink GC nursery on background tabs → [meta] Shrink GC nursery on background tabs

The first thing to do here is to limit the nursery size to 1MB for processes containing only background tabs.

I wonder if that API is too expensive to call every time we do a minor GC?

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.