Open Bug 1526416 Opened 6 years ago Updated 2 years ago

[meta] Preallocated about:newtab can use a lot of memory if there are multiple windows open

Categories

(Firefox :: Tabbed Browser, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: memory-footprint, meta, Whiteboard: [fxperf:p3])

I just looked at about:memory after starting Firefox with my normal session, and the preallocated about:newtabs (of which I have a bit more than 40) are using at least 260MB of RAM. Basically about 6MB each.

Obvious questions:

  1. Could we use less?

  2. Do we really need to preallocate so many? It doesn't quite seem to be one per window (I have 65 windows), but Gijs says we currently should be doing one per window...

Oh, and that number is about 6.5% of the total memory usage across all processes for the session.

I seem to recall that we used to have a single preloaded about:newtab in a hidden DOM window that we'd swap in when creating a new newtab. And then we switched to the preloaded-per-window model.

I'll try to find the bug so we can examine that decision.

Found it - bug 1077652.

Perhaps we should revisit the assumptions bug 1077652 was based on - that was 4 years ago, and pre-e10s.

Should probably evaluate this for fx-perf considering it will affect startup.

It may be worth looking into whether swapping docshells is still expensive, and/or using a hybrid method (ie creating the browser in one doc, and if we happen to be in the same window, continue doing what we do now, and only docshell swap if we're in a different window), and/or having a limited N (maybe 1, maybe more than 1) of preloaded tabs that we docshell swap to the top N focused windows when those change, or something.

260mb of preloaded tab memory is pretty sad though.

Whiteboard: [fxperf]

(In reply to Mike Conley (:mconley) (:⚙️) from comment #3)

Found it - bug 1077652.

Perhaps we should revisit the assumptions bug 1077652 was based on - that was 4 years ago, and pre-e10s.

One implicit assumption, that most users don't have lots of windows, is most likely still true. This seems like an extreme case.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #0)

[...] Basically about 6MB each.

Obvious questions:

  1. Could we use less?

This is the more interesting question to me. Using less memory per preload would benefit more users than sharing the preloaded page across windows.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #0)

  1. Do we really need to preallocate so many? It doesn't quite seem to be one per window (I have 65 windows), but Gijs says we currently should be doing one per window...

We only preload in windows where you already opened a tab (bug 1353013), so that's probably why you see a lower number.

Priority: -- → P3

We only preload in windows where you already opened a tab

Ah, so basically "one per window that has more than one tab" in my session restore case?

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #6)

We only preload in windows where you already opened a tab

Ah, so basically "one per window that has more than one tab" in my session restore case?

More like, "one per window that has had more than one tab", since the preloading kicks off once a tab has been opened in that window.

Whiteboard: [fxperf] → [fxperf:p3]

(In reply to Mike Conley (:mconley) (:⚙️) from comment #7)

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #6)

We only preload in windows where you already opened a tab

Ah, so basically "one per window that has more than one tab" in my session restore case?

More like, "one per window that has had more than one tab", since the preloading kicks off once a tab has been opened in that window.

Hm, from code inspection, it looks like we also do this for the lazy browser sessionstore tabs? So if you restore a window, any window with more than 1 tab will get a preload browser. Changing that so it only happens when users add tabs seems like a quick win, at least... Or is that a dumb idea for some reason I haven't thought of yet?

Flags: needinfo?(mconley)

(In reply to :Gijs (he/him) from comment #8)

Hm, from code inspection, it looks like we also do this for the lazy browser sessionstore tabs? So if you restore a window, any window with more than 1 tab will get a preload browser. Changing that so it only happens when users add tabs seems like a quick win, at least... Or is that a dumb idea for some reason I haven't thought of yet?

Not a dumb idea at all - in fact, that'd probably help with real restoration performance, since it'd mean that the privileged content process wouldn't try to grab CPU cycles while restoring the other tabs in that window.

Flags: needinfo?(mconley)
Depends on: 1527081
Depends on: 1353013
Keywords: meta
Summary: Preallocated about:newtab can use a lot of memory if there are multiple windows open → [meta] Preallocated about:newtab can use a lot of memory if there are multiple windows open
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.