Open Bug 1814510 Opened 3 years ago Updated 1 year ago

GC scheduler should not treat Android background idle time as idle time

Categories

(Core :: JavaScript: GC, defect, P3)

defect

Tracking

()

People

(Reporter: sfink, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxdroid][android-tab-reloading])

From https://bugzilla.mozilla.org/show_bug.cgi?id=1810550#c5

If a content process is in the background on Android, the GC scheduling code will probably think it has idle time to schedule as much GC as it wants. This probably only matters if there are occasional timers or events firing that do some allocation, but still background idle time should be considered a worse time to GC, not a better time.

(Fixing this would require the scheduler to have an accurate picture of the current state, which from bug 1810550 looks like it currently may not.)

Severity: -- → S3
Priority: -- → P3

I talked about this bug a bit with Christian and he would prefer a different spin on this:

When the app is in the background, that's still a good time to run GC. However, the issue is that we will run GC as one long uninterrupted task.
Instead, we should run it in small increments, for example for 100ms every 1s. The hope is that this will avoid exceeding Android's thresholds for "excessive CPU usage".

In addition to this discussion, please also see this ticket: https://bugzilla.mozilla.org/show_bug.cgi?id=1450787
As mentioned in this comment, looks like Android cannot even trigger a GC due to that pref being disabled.

We are now currently investigating enabling the javascript.options.gc_on_memory_pressure pref on Android with Olli.
According to our current findings, we are running a long GC when this pref is enabled and app is taken to the background. This causes ~750ms of jank on the parent process. See profile: https://share.firefox.dev/3QXZlPR.
And according to the perfetto traces, we've observed that this GC is running on mid and little cores, so it was not that bad news from that point of view.
We also discussed having the incremental GC instead of the full one once the app is backgrounded. I'll finalize investigations and take action on that ticket soon (in 1-2 weeks).

See Also: → 1450787

Incremental GC might still end up running the entire GC work consecutively if there's no other work that delays the incremental slices. I think if we want to keep "CPU time over the span of one second" below a certain threshold, we'll need something that enforces this threshold.

Whiteboard: [fxdroid][android-tab-reloading]
You need to log in before you can comment on or make changes to this bug.