Open Bug 1532955 Opened 2 years ago Updated 1 month ago

Implement low-memory detection on Linux for automatic tabs discard


(Core :: Widget: Gtk, enhancement, P1)




Fission Milestone M8


(Reporter: russianneuromancer, Assigned: KrisWright)


(Blocks 2 open bugs)


User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 OPR/58.0.3135.79

Steps to reproduce:

As recommended in bug 675539 I register separate bugreport about low-memory detection on Linux.

Possible way to detect low-memory on Linux is PSI which should be available since Linux 4.20.

Blocks: 675539
Component: Untriaged → Widget: Gtk
Product: Firefox → Core

My suggestion? If a system has no swap, you check for some cutoff of free RAM (and possibly cache?) and start discarding tabs as you approach it.

If swap is on, I would be curious to see the result of measuring pageout/pagein rates of the firefox process to indicate when to discard tabs. ps has a flag for showing major page faults (paging to disk) per process so presumably there is a POSIX call for this information.

My thought is, on something like a 4GB system if you have firfox plus some other stuff going on you can easily have 600-800MB of "junk" get swapped out (least recently used after all... I suppose it's the loaded but inactive daemons, various chunks of gnome, etc..) resulting in plenty of RAM for the working set. So measuring total system page rate will not provide useful info for when to discard tabs. Your two scenarios where you'd get firefox pageout; 1) You start some other large application, so it would begin to page firefox. Cuttings tabs then would presumably increase performance of both firefox and the other application. 2) firefox RAM usage has crept up enough to start paging, an appropriate time to cut RAM usage.


I realized that the major page fault is actually measuring page ins not page outs.. so it would not stop firefox from being swapped out to begin with. Nevertheless the most problematic swap behavior is thrash (one too many tabs, and performance drops off a cliff as the active working set exceeds available RAM..) You would have probably a moment of slowdown as firefox starts to thrash, then the tabs would be cleared and it'd speed back up. Not ideal but much better than having that "one too many tabs" bring the system to it's knees thrashing.


Ever confirmed: true
Priority: -- → P3
Type: defect → enhancement
Blocks: 1587762
No longer blocks: 675539

Kris, I'm assigning this bug to you because I've been told that you will help integrate Linux's memory pressure events with Firefox tab unloading. Thanks!

Assignee: nobody → kwright
Fission Milestone: --- → M8
See Also: → 1579198
Severity: normal → S4
OS: Unspecified → Linux
Priority: P3 → P1
Hardware: Unspecified → All
Version: 67 Branch → Trunk
You need to log in before you can comment on or make changes to this bug.