No storage (not even NVMe) can match the raw performance of RAM especially in writes. This storage hierarchy (L1 > L2 > L3 > RAM > bulk storage has been true for decades and probably will continue to be true for at least another decade.
@Whattteva Generally speaking, youāre not wrong. Your point that NVME is still an order of magnitude slower than RAM isnāt lost on me here. Nor I think on OP whoās tag line reads
Architect at Red Hat and long time Linux and Open Source user.
I think heās aware.
But, to @Steven_Ellisās point, the āpainā felt by swap is no where near as high when weāre talking about NVME. Just purely in terms of latency, NVME is an order of magnitude faster than spinning drives. Weāre talking 100s of microseconds vs 10s of milliseconds.
Regarding the issue at hand, the speed has nothing to do with the reason swap is off by default now.
When I deploy Linux VMs for XYZ application, I typically give them swap roughly equal to the amount of RAM I give them. If your webserver for an app suddenly gets hit hard, youād prefer your webapp start swapping to disk. The result is worse performance, but youāre still serving your data.
TrueNAS SCALE isnāt a simple web app, and itās not even a simple file server. Itās got all sorts of processes competing for RAM, whether it be SMB, KVM workloads, Kubernetes Apps, or the big one, ZFS ARC.
If you take a look at this thread: Dragonfish swap usage/high memory/memory leak issues - #62 by kris
Youāll find the reason swap was disabled has nothing to do with the relative speed of devices. It was a perfect storm of unpredictable, weird problems. In the case of what @Steven_Ellis did, it looks like a sane use of swap.
In my own limited testing before 24.04.2, I noticed that my system would start swapping for no reason, even though I had free memory, even though I had set swappiness=1
. Keep an eye on it.
Donāt always assume swap is a bad thing. Good virtual memory management means unused resources, for example a bunch of memory allocated to start up a service, gets swapped out when it is unused allowing more resources for new services or cache. I remember 15+ years ago watching traditional Unix admins freak out on Linux boxes because we were using some swap space, or that they thought no memory was āfreeā due to system cache.
Donāt disagree. In fact for some of my smaller service VMs I use zram based swap. I prefer my services to be reliable and donāt want OOM to get in the way.
Iām not saying it is lost on anyone. I started my post with my personal preference in my systems and the reply was mentioning that NVMe is a high performance storage. So I merely made a point that not even NVMe can compete in reads, let alone writes. If anyone wants to turn swap on, itās perfectly fine and their choice. Iām in no way against that. I simply donāt do it on my systems that have a large enough system RAM capacity.
I never even brought up spinners here. My original point still stands. Not even NVMe holds a candle in reads. I havenāt even mentioned sync writes, which all non-enterprise NVMeās will start to crawl on. And unfortunately, the majority of home users that come to the forums use non-enterprise drives with no PLP and usually also slower QLC-based ones due to cost efficiency.
Are we reading the same post here? The post even mentions the word performance like 2-3 times, which then lead to stability issues. It goes on to mention that the problem is compounded by people using crappy boot drives that wear out early and again, would lead to terrible performance due to the drive not having spare cells left. And as I stated above, majority of home users use these questionable type of drives. And itās apparently prevalent enough that ixSystems decided it best to just disable swap altogether.