6 ms·
RAM isn't user friendly in Linux. Ubuntu Desktop is the most popular distro by far by Google Trends, but it doesn't even come with RAM compression set up out of
by flashback2199 3y ago
RAM isn't user friendly in Linux. Ubuntu Desktop is the most popular distro by far by Google Trends, but it doesn't even come with RAM compression set up out of the box, so as soon as you run out of memory the UI totally locks up until the task killer kills a process, which always takes minutes in my experience. Pop OS does come with RAM compression set up, which is Ubuntu based, but then you're stuck on xorg instead of Wayland right now, because they decided to make their own DE from scratch in Rust for some strange reason, which isn't available yet. You can set up RAM compression yourself, but when macOS and Windows both have it standard, coming to Linux as a newbie so you install Ubuntu Desktop and your whole system locks up as soon as you run out of physical RAM, it's really odd and unexpected. I'm not even sure who would want to run a desktop distro without RAM compression.
- yjftsjthsd-h 3y agoI'm pretty sure what you're calling RAM compression is swapping to zram, in which case the answer is that Some people prefer to not swap at all because that will still make things janky in comparison to just killing things when you're out of memory. (I would endorse earlyoom for that)
- vlovich123 3y agoI’ve heard this position multiple times, and yet every single benchmark I’ve seen repeated by teams of engineers in multiple contexts fails to replicate this fear. Zswap really is something that should just always be enabled.
- yjftsjthsd-h 3y agoHow would you benchmark that?
- vlovich123 3y agoFor example, at Oculus they ran both performance benchmarks in a lab and collected feedback data from field telemetry. Now of course, it’s always possible some performance counter was overlooked / the degradation requires a specific workload to show, but the lack of ability to show any evidence of a difference implies that you probably are unlikely to see it given that the detractors were very vocal and engineering at big corps tends to be more stasis driven. I saw this also repeated at Apple (not Zswap since not Linux, but similar idea of compressing pages) and Android.
- dmacvicar 3y agoFor me it solved most of these lockups when using heavy ram apps (Electron, Firefox + Teams, etc) and keeps the system responsive. I am happy with it and plan to keep it enabled. I have no data to validate except that I don't remember having to SysRq key + F some app for a long time.
- flashback2199 3y agoMy point was that as a new user the default experience is unfriendly and saying that I have to understand the nuance between different ram related packages in order to talk about it is just proving my point.
- yjftsjthsd-h 3y agoI'm not saying that a new user should need to understand the nuance, I'm questioning whether your understanding of the underlying problem is accurate. I do agree that it's a poor experience for the system to freeze up under excess memory pressure, I just think the correct fix is less swap combined with earlyoom.
- deleted 3y ago[deleted]
- flashback2199 3y agoGah I am so tired of explaining this in this thread: As the system begins running out of memory, it starts using more of the zram. The zram is compressed which uses CPU and slows the system down enough to notice it during which time I notice and begin closing apps. The alternative, without zram, is it's super fast right until I run out of memory then bam my whole system locks up. Zram also effectively makes the total available ram larger because zram swap is actually useable whereas swap to disk is so slow the system basically locks up when you start depending on it as if it were ram. Just try it dammit! It takes a few mins to set up and open enough stuff to see the effects.
- MrDrMcCoy 3y agoIn addition to swap on zram, there's also zswap. zswap is not quite as good as swap on zram, but almost certainly is better suited to systems that you want to have be able to hibernate.
- ihattendorf 3y agoI don't see how RAM compression helps address the machine locking up when it'll still lock up when the compressed RAM is used up. It just buys you a little more time. Also, Fedora has had zram enabled by default for a few years now along with systemd-oomd (which can sometimes be too aggressive at killing processes in its default configuration, but is configurable).
- IshKebab 3y agoYeah you'd think it would make no difference but in my experience it does help a little. Don't ask me why. But yeah even with zram my laptop still hard reboots 80% of the time when it runs out of RAM. No idea how people expect the Linux Desktop to ever be popular when it can't even get a basic thing like not randomly rebooting your computer right.
- mxmlnkn 3y agosystemd-oomd is also default since Ubuntu 22.04. I remember it vividly because it effectively kept killing X when RAM filled up instead of sanely killing the process that last filled up the RAM, which is either gcc or firefox in my case. Absolutely user-unfriendly default configuration. I removed it and reinstalled earlyoom, which I have been using for years with a suitable configuration. I can only concur, RAM behavior isn't user-friendly on Ubuntu.
- konstantinua00 3y agoI second the earlyoom recomendation it's a lifesaver
- khimaros 3y agopersonally, i run my systems without swap, and kernel OOM behavior has been adequate.
- pxtail 3y agoThank you for mentioning earlyoom - I'll install and try it because current behavior of total, complete lockup without ability to do anything besides reset with the hardware button infuriates me unbelievably. I really don't comprehend how something like this is possible and default behavior in 2023 in OS marketed as 'desktop' and 'casual/user friendly'
- olddustytrail 3y agoAs the other comment says (but kind of hides) install earlyoom and point the config at whatever you reckon is the main culprit. It only needs done once and you can forget about it. Edit: I should add, this is advice for desktops. If it's a server either resize or fix your service.
- outworlder 3y agoRAM compression is not magic. It does allow you to save RAM and might prevent you from hitting swap for a while longer, but it won't save you if your working set is just too large and/or difficult to compress. Apps like web browsers with multiple tabs open might be easier to compress, a game with multiple different assets that are already in a variety of compressed formats, less so. The Linux Kernel also has a bunch of optimizations (Kernel same-page merging, for example, among others) that do not require compression(although you could argue that same-page merging _is_ a form of compression). The system is not supposed to 'lock up' when you run out of physical RAM. If it does, something is wrong. It might become slower as pages are flushed to disk but it shouldn't be terrible unless you are really constrained and thrashing. If the Kernel still can't allocate memory, you should expect the OOMKiller to start removing processes. It should not just 'lock up'. Something is wrong. > which always takes minutes in my experience It should not take minutes. Should happen really quickly once thresholds are reached and allocations are attempted. What is probably happening is that the system has not run out of memory just yet but it is very close and is busy thrashing the swap. If this is happening frequently you may need to adjust your settings (vm.overcommit, vm.admin_reserve_kbytes, etc). Or even deploy something like EarlyOOM (https://github.com/rfjakob/earlyoom https://github.com/rfjakob/earlyoom). Or you might just need more RAM, honestly. I have always found Linux to behave far more gracefully than Windows (OSX is debatable) in low memory conditions, and relatively easy to tune. Windows is a swapping psycho and there's little you can do. OSX mostly does the right thing, until it doesn't.
- flashback2199 3y agoDidn't say it was magic. System slows down more as you use more RAM compression, so you have time to respond and close some apps. Without it I find I often am working at a thousand miles an hour, not noticing anything amiss, and then suddenly, brick wall, out of memory and I can't do anything at all.
- MrDrMcCoy 3y agoSame page merging only works for KVM, as that's the only case that enables it without intervention that nothing else supports. It's MADVISE for everything non-KVM, and no applications are compiled with support for telling the kernel "hey, it's OK to dedupe me". The only way to get KSM to work with userspace applications is to use LD_PRELOAD to inject the necessary bits (https://github.com/unbrice/ksm_preload https://github.com/unbrice/ksm_preload) or to use a custom kernel that has a patch and extra daemon to globally enable KSM for everything (https://codeberg.org/pf-kernel/uksmd https://codeberg.org/pf-kernel/uksmd). I really wish this was a standard, configurable sysctl. There are many container environments (and heck, even browsers) that would benefit from this, and I cannot see any real downside.