NEW205806
[GTK] Implement memory pressure monitoring using GMemoryMonitor
https://bugs.webkit.org/show_bug.cgi?id=205806
Summary [GTK] Implement memory pressure monitoring using GMemoryMonitor
Michael Catanzaro
Reported 2020-01-06 09:28:51 PST
We've been discussing memory pressure in Fedora and I realized WebKit could benefit from this work too. Unnecessary wakeups are sad for battery life. Currently MemoryPressureMonitor.cpp and MemoryPressureHandlerLinux.cpp perform wakeups to check available RAM. If GLib 2.64 is available, then it would be much better to use GMemoryMonitor instead, which is much more sophisticated. This requires low-memory-monitor to be installed. low-memory-monitor uses PSI notifications from the kernel to eliminate need for wakeups.
Attachments
Michael Catanzaro
Comment 1 2024-01-31 07:31:15 PST
*** Bug 264036 has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 2 2024-01-31 07:31:33 PST
Currently we have a handrolled MemoryPressureMonitor used only by the Linux ports WPE and GTK. Both ports already depend on GLib, which has its own GMemoryMonitor. We might as well depend on logic that is already available to us. Benefits: * The current code attempts to access /sys/fs/cgroup, but this will almost always fail because bubblewrap sandbox is now mandatory if not running inside flatpak, and this location is not accessible in either or bubblewrap and flatpak sandboxes * GMemoryMonitor has various backends including one that uses xdg-desktop-portal, escaping the above limitation * It can become smarter in the future without requiring changes in WebKit. E.g. there is a plan to switch from depending on low-memory-monitor to depending on systemd in https://gitlab.gnome.org/GNOME/glib/-/issues/2931 * It's used by lots of applications rather than WebKit alone, and we don't have to maintain it The downside is the GMemoryMonitor API currently does nothing if low-memory-monitor is not running. This should be available on all desktops nowadays, but might be missing on embedded devices. Having a fallback to our existing MemoryPressureMonitor wouldn't hurt. But this problem would also go away if GMemoryMonitor were to use systemd instead.
Note You need to log in before you can comment on or make changes to this bug.