Open Bug 625155 Opened 15 years ago Updated 1 year ago

Alter GC heuristics when browser not focused

Categories

(Core :: JavaScript: GC, enhancement)

enhancement

Tracking

()

People

(Reporter: wes, Assigned: smaug)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

As we move further and further into long delays between runs of the cycle collector and JSAPI garbage collector, we run the risk of producing a browser which consumes more RAM than it needs to, as well as increasing our fragmenation. If we kick off a run of the GC and CC when the browser loses focus, we can reclaim some memory when the user isn't needing interactive behaviour. Game system emulators, Flight of the Navigator, Defender of the Favicon, AJAX long poll apps, etc, can all generate plenty of churn objects when the browser is not focused, but we don't need to make the frame-rate/memory-usage trade-off when the browser isn't focused. So we could potentially restore some functionality (like calling JS_MaybeGC, or reducing the JSAPI GC threshold) when that is the case. That way the browser will be more likely to not need immediate GC when the user requires interaction again. Similarly, if we have per-tab GC, we can be slightly more aggressive with GC at the expense of framerate for tabs that are not visible, etc.
We could perhaps do something simple even for FF4. Call CC let's say 10 seconds after the FF was deactivated (no FF window focused). And perhaps we could increase the possibility for GC and CC when FF isn't focused.
Attached patch GC and CC after deactivation (obsolete) — Splinter Review
Applies over bug 624549.
Assignee: nobody → Olli.Pettay
Product: Firefox → Core
QA Contact: general → general
Attachment #503292 - Flags: review?(jst)
Attachment #503292 - Flags: review?(jst)
Attached patch patchSplinter Review
Over a patch I'm going to attach to bug 624549.
Attachment #503292 - Attachment is obsolete: true
Attachment #506462 - Flags: review?(jst)
Comment on attachment 506462 [details] [diff] [review] patch + mAfterDeactivationTimer->InitWithFuncCallback(DeactivationTimerFired, + nsnull, 2500, + nsITimer::TYPE_ONE_SHOT); What made you change your mind from 10s to 2.5s?
There is the user interactivity timer, which would fire "inactive" and that *might* cause CC (without GC). I think we just want to have a proper CC+GC when FF is deactivated. That is a bit hackish, and should be documented somewhere.
Comment on attachment 506462 [details] [diff] [review] patch I need to update this. I still think we want something like this.
Attachment #506462 - Flags: review?(jst)

Sorry, there was a problem with the detection of inactive users. I'm reverting the change.

Assignee: nobody → smaug
Severity: normal → S3
Component: General → JavaScript: GC
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: