Why doesn't Ubuntu use memory compression by default?

Like zram or something else? Windows and other Linux distros use it.

3 Likes

even macOS does. Well great defaults didn’t arrive in Ubuntuland yet. But no worries, here’s my scripts for defaults that are more like you want to: https://github.com/alexmyczko/autoexec.bat/tree/master/config.sys

You want the script with the name zram. (there are two, the Ubuntu one is only for Ubuntu, the Debian one is for Debian, but works on Ubuntu as well, and allows you to later switch to Debian, live right from your Ubuntu)

Ooh i checked your link, disabling phased updates is generally bad, but that’s off-topic.

How is it bad? I found having systems in different state for up to a month, non accessible web pages with automatic bug reports worse. Mind you I am not running a single computer with Ubuntu…

So far apart from two issues (gdb broken and nautilus) not much that was an issue.

in my testing, the best low memory approach for desktop linux is:
1 enable swapspace for dynamic swap sizing
2 use zswap and add the modern modules
3 enable MGLRU which is not activated in the Ubuntu standard kernels yet
4 disable systemd oomd because it is still very silly for desktops.

But which of those should be defaults?
(1) is the default for Macos and Windows. I think it could be enabled on installs where the / partition is > 100 GB.
(2) is mature and works well with (1)
(3) is only a matter of time. MGLRU is so well tested and so beneficial I was surprised that it is not yet the default.
(4) Fedora and Ubuntu are committed to systemd-oomd and my pessimistic view that it will never work very well is not widely shared. Currently the default configurations stop it from basically doing anything since this is less harmful than allowing it to kill things, which was the experience that 22.04 users were confronted with, which in my opinion is a tacit acceptance that is broken. With (3) the kernel management of low memory seems so dramatically improved that an effectively disabled systemd-oomd doesn’t matter, I guess.

1 Like

I am also not using systemd-oomd but nohang instead, long before oomd without systemd from
fb became a thing.

Nice reply, thanks! But i was looking more into core developers or smh like that into the resons why Ubuntu doesn’t actually configure this. It seems to be a good feature and widely accepted by modern operating systems.

I didn’t know about swapspace, it seems good, not sure how practical. User-space oomd might possibly be better than kernel oomd, i don’t know. I think it was made to provide better customization of what to be killed than what the kernel allows. Either way it’s not useless.

MGLRU seems like an improvement that should be on by default in the next Ubuntu release.

About zswap, there is also zram, which seems to have a new option CONFIG_ZRAM_WRITEBACK. It writes to backing device, but it needs to be set up with some options. We all know Ubuntu can do that. I’ve red somewhere that zram is made in a way that allows it to compress a little bit better than zswap, but that’s up to the developers. All of this doesn’t matter nowadays cause zram is not enabled by default in the first place.

earlyoom is another option that works well in my experience.

The most confusing thing about {zswap, zram} is that there is also {zswap, zram}.

MG LRU works great in certain cases, like Android / ChromeOS (where it was originally designed for), desktop as well, but the Ubuntu generic kernel is… well… generic, it runs also on servers, cloud, even some embedded devices. One of the concerns that was raised in an early upstream patch set (https://lore.kernel.org/lkml/YHcpzZYD2fQyWvEQ@cmpxchg.org/) was that this feature is provided as a run-time option, giving the kernel two page-reclaim mechanisms, and MGLRU is not the upstream default at the moment, so it’s still not used everywhere. At this time it’s likely much more stable, but still not the upstream default.

So, with all of the above, for the Ubuntu generic kernel we decided to make this option available (it can be turned on via /sys/kernel/mm/lru_gen/enabled), but not enabled by default to avoid risk of regressions in some special non-so-well-tested scenarios.

What would be nice to have maybe is a user-space package that turns on by default all these nice desktop-oriented settings in the kernel (at boot time or at run-time when booting the system), something like linux-desktop-settings or similar, and MGLRU could be one of these options. Something to think about…

6 Likes

Yes please, pursue this with your colleagues! You probably know Ubuntu and its flavours are widely used for desktop. Why generic kernel default for Ubuntu Desktop? Why not optimised for desktop? Why trying to be one thing to rule all server and desktop? That’s insane - dividing and compromising for both cases.

@timatgca @mystiquewolf FYI, mantic kernels now will have MGLRU enabled by default:

2 Likes