6 ms·
Disables Swap and Zram, gets OOM killed, surprised pikachu face Joking aside, is there an actual legitimate reason to do this on a workstation? I understand wh
by utf_8x 2y ago
Disables Swap and Zram, gets OOM killed, surprised pikachu face
Joking aside, is there an actual legitimate reason to do this on a workstation? I understand why you would want to disable swap on something like a kubernetes cluster node but in my head, heaving at-least zram enabled is a good thing on a workstation so you *don't* get OOM killed... I call on thee, Linux wizards of HN, to help me understand the reasoning behind this.
- speedgoose 2y agoI have swap, zram, and systemd-oomd enabled on my self managed kubernetes nodes. It helps dealing with JVM powered or memory leaking software at low cost. I am not sure why you would disable those in many scenarios.
- moondev 2y agoFunny enough even Kubernetes supports running nodes with swap these days. My laptop has 64GB RAM and 1TB NVME, I run with swap off because I want all storage usable should ideally not be pressed for memory. I also have memory and storage allocation in my task bar to easily monitor the situation.
- callalex 2y agoUnfortunately, there is a huge amount of cargo-culted cruft lying around in various Linux-on-workstation-wiki guide sites that hasn’t been modernized since the 2000’s. I don’t normally like to rant without providing a solution, but this is a problem I see my friends bump up against all the time when I tell them it’s finally the year of the Linux desktop. When something goes wrong they land on the same search results that I did when I was a child and the advice just never got updated. There used to be a time where swapping out meant moving cogs and wheels full of heavy rocks and RAM frequencies could be approximated by waving a stick until it made whistling noises. At that time suddenly dealing with memory swap made the system unusably unresponsive (I mean unusable, not just frustrating or irritating). Advice about disabling swap and zram came from that time for “resource constrained” systems. Unfortunately the meme will never die because the wikis and now regurgitated LLM drivel will just never let it go because nobody has gotten around to fixing it.
- tjoff 2y agoThis is OS-agnostic. I love the old fact that you should have twice the amount of swap as your RAM size. I could rant but, no. Just don't. Today, don't buy a computer (regardless of size) with less than 32 GB of ram. Yes, this applies to fruity products as well. Part from making it a more enjoyable experience it will also extend the usable life of the computer immensely. (The weird crap about apple computers not needing as much RAM comes from iOS vs. android and is for different reasons, does not apply to real computers)
- hhh 2y agoI don’t understand the sentiment. People should analyze what they actually use and what the need is. Sure, I bought a 64gb ram macbook because I like toys and don’t want to think about it, but for 80% of my workload 8gb is fine, and for my partner it’s fine for 100%.
- tjoff 2y ago8 GB can, even in this electron world, barely work. But it won't tomorrow. Buying something with 8 GB today is wasting an otherwise perfectly good computer. And when your partner gets a new computer, for whatever reason, the old one can easily live on for many many years. But it's utility will be limited if it only has 8 GB of ram. The product in the article is only 8 years old but already stretching its usefulness for no good reason.
- deleted 2y ago[deleted]
- sampo 2y ago> I love the old fact that you should have twice the amount of swap as your RAM size. With a 32GB memory, 256GB ssd-disk laptop, it would be really weird to set up 64GB of the disk for swap.
- tjoff 2y ago
- webdevver 2y agocompiling clang on ubuntu 20.04, the link step used up all my ram and started swapping on the nvme. htop froze, so i hit ctrl-c, but nothing happened. no mouse movement, no ssh'ing in, just totally hard-locked. i ended up having to physically powercycle the machine. after that i turned off swap so that it killed the process rather than the machine (and remembered to pass -DLLVM_PARALLEL_LINK_JOBS=1)
- jcelerier 2y agoUse easyoom or systemd-oomd
- chronogram 2y agoOn my SBCs and VPSs I use a cache-heavy zram setup with LZ4 and `vm.page-cluster=0` being the most important changes to the default, and cache pressure and swappiness both to 200 off the top of my head, and things like only doing foreground IO when the background write buffer is full. This type of swapping is fast, and is easy on the CPU, and gives a lot of extra disk cache on this type of low performing storage. I disable disk schedulers because they haven't been necessary and would just add overhead. This means there's a lot of available RAM capacity, that there's a hefty read cache to avoid the SD card, that when there are disk writes on writable storage it can still read from it, and with the lack of clustering and the speed of decompression there's no swapping lag whenever a page needs to be swapped back. This swap early, swap often is the complete opposite of the OOM-prevention swapping you used to use on disks, which was slow and interrupted IO whereas LZ4 in RAM is fast and doesn't interrupt IO. I have been using this setup since 2022 and have not had any issues but I don't compile anything on those setups, though I see no reason why it would not be safer than compiling without zram at all.
- laweijfmvo 2y agocould you please write a ELI5 guide that I could follow on my tiny VPS? It's debian-based. Thanks!
- chronogram 2y agoOf course! Just touching these files should be everything you need: /etc/sysctl.d/99-240716-vm.conf vm.dirty_background_ratio = 1 vm.dirty_ratio = 100 vm.page-cluster = 0 vm.swappiness = 200 vm.vfs_cache_pressure = 1 dirty_background_ratio = starts background writing when it's at least 1% of available mem; dirty_ratio = starts force writing when all avail (not total) ram is full; page-cluster = swap in only what's needed; swappiness = lower means swapping is expensive higher signals swapping is cheap; vfs_cache_pressure = lower keeps more dentries and inodes in memory. /etc/udev/rules.d/99-240716-ioschedulers.rules ACTION=="add|change", KERNEL=="mmcblk[0-9]*|nvme[0-9]*|sd[a-z]*", ATTR{queue/scheduler}="none" Removes schedulers from typical local writeable storage. /etc/systemd/zram-generator.conf [zram0] zram-size = ram compression-algorithm = lz4 Might have to install systemd-zram-generator if it doesn't already exist.
- black_puppydog 2y agoPersonally, for a long time I disabled swap and made sure that I had an OOM killer running. This was always in a setup where I'd have ample RAM for my everyday tasks, and was doing numerics. Running OOM would invariably mean two things: 1. I had a bug in my scripts, which typically meant I'd accidentally materialized a huge sparse matrix or some such, and thus 2. The system wouldn't go "just a little" OOM but rather consume memory an order of magnitude over the actual system's capacity. And it would not recover. In that scenario, the system would typically start swath-thrashing so hard that I'd just cold reboot. An OOM daemon fixed that and let me iron out my bugs.
- nucleardog 2y agoDon't know if it's "legitimate", but I've got 64GB of RAM. Allocating 16/32/64/128GB of NVME storage to swap is mostly just a waste of disk space for me. When I had swap enabled, it was constantly showing 0 used. (Not "pretty much none", literally "0.0".) Further, if I'm trying to use more than 64GB of RAM... I'm fine with things getting OOM killed. I don't know that I've ever had anything OOM-killed when something wasn't clearly misbehaving. (I count Chrome eating 50GB of RAM because I haven't closed any tabs all week as me clearly misbehaving for the purposes of this discussion.) And as far as zram... I guess same sorta arguments. I'm not running out of RAM, so why use up CPU cycles (and presumably battery power)? why use up brain cycles setting that up? Until I've maxed out my system's RAM, I'd rather just throw more RAM at it.
- laweijfmvo 2y agoI have access to a build machine with 256GB of RAM and it suffers from OOM killing during certain builds unless I allocate like 2GB of swap
- nucleardog 2y agoYeah I'm not trying to say "64GB is enough for anyone!" so much as "I have way more RAM than I realistically need for my workloads." I've got all the things I need open right now and `free` shows I've got 40GB of RAM available. If your workloads involve using more RAM than you have you can... add more RAM, use swap/zram/etc, or just not do that thing. Absolutely makes sense to me to throw some swap into the mix. I'd probably do the same if it were an infrequent use case (otherwise preferring to just add more RAM). But also absolutely makes sense to me to not have any swap enabled on this machine right now.
- tracker1 2y agoSimilar opinion here on my destop. I was running 128gb, only exceeded 64gb a handful of times. That said, my RAM started causing lots of issues (thought my ssd was going bad). I only bought 64gb to replace it with as I felt the extra cost wasn't worth it to maintain, also likely to upgrade early-mid next year.
- 2y ago
- burnte 2y ago> Disables Swap and Zram, gets OOM killed, surprised pikachu face On a machine with FOUR GIGABYTES OF RAM at that.