On Mo, 12.08.19 09:40, Chris Murphy (lists@colorremedies.com) wrote:
How to do this automatically? Could there be a mechanism for the system and the requesting application to negotiate resources?
Ideally, GNOME would run all its apps as systemd --user services. We could then set DefaultMemoryHigh= globally for the systemd --user instance to some percentage value (which is taken relative to the physical RAM size). This would then mean every user app individually could use — let's say — 75% of the physical RAM size and when it wants more it would be penalized during reclaim compared to apps using less.
If GNOME would run all apps as user services we could do various other nice things too. For example, it could dynamically assign the fg app more CPU/IO weight than the bg apps, if the system is starved of both.
Right now the only lever to avoid swap, is to not create a swap partition at installation time. Or create a smaller one instead of 1:1 ratio with RAM. Or use a 1/4 RAM sized swap on ZRAM. A consequence of each of these alternatives, is hibernation can't be used. Fedora already explicitly does not support hibernation, but strictly that means we don't block release on hibernation related bugs. Fedora does still create a swap that meets the minimum size for hibernation, and also inserts the required 'resume' kernel parameter to locate the hibernation image at the next boot. So we kinda sorta do support it.
We could add a mode to systemd's hibernation support to only "swapon" a swap partition immediately before hibernating, and "swapoff" it right after coming back. This has been proposed before, but noone so far did the work on it. But quite frankly this feels just like taping over the fact that the Linux kernel is rubbish when it comes to swapping...
Another reality is, the example program, also doesn't have a good way of estimating the resources it needs. It has some levers, that just aren't being used by default, including -l option which reads "do not start new jobs if the load average is greater than N". But that's different than "tell me the box sizes you can use" and then the system supplying a matching box, and for the program to work within it.
As suggested above, I think DefaultMemoryHigh=75% would be an OK approach which would allow us adjust to the "beefiness" of a machine automatically.
Lennart
-- Lennart Poettering, Berlin