SSD Endurance
etbe.coker.com.au
etbe.coker.com.au
[1]: https://www.kernel.org/doc/html/latest/admin-guide/blockdev/...
I did some benchmarks in my laptop and for heavy compilation tasks that may occasionally spike the memory usage over the amount of RAM memory compression was not beneficial compared with using SSD for swap.
The picture changes if one needs encrypted storage and cannot use hardware encryption on SSD. The software encryption will tax CPU on roughly same scale as lz4 and lz4 is still faster overall for read/write combination.
On my laptop (i7-1165G7, DDR4 3200 MHz) lz4 decompression is ~3000 MB/s, compression is ~485 MB/s (on my 3960X desktop it’s ~1.5x that) (numbers from lzbench). Zram by default uses one stream per CPU, so theoretical max is (I think) 8x those for the laptop and, well, a lot more for the Threadripper. Non-Optane SSDs only really have a potential advantage in sequential writing. Max throughput aside, Zram will generally have better latency (and thus likely IOPS as well), and better consistency since most SSDs get their max performance from DRAM caches.
In the end, though, quibbling over synthetic numbers doesn’t matter much if you have benchmarked your actual use case. I don’t know what “not beneficial” means (the same? 10x worse?), but part of my original point was that
However, I did benchmark using stress-ng my laptop with Samsung 980 PRO SSD and when the stressors had to use swap, using zram or zswap was like 5%-15% slower than the real swap according to bogo ops counters that the tool reported. And the more CPU was taxed during the tests, the slower zram became while CPU utilization has not affected the real swap.
…part of my original point was that Zram will resolve the SSD endurance problems.
[1] - https://www.reddit.com/r/Fedora/comments/rzvhyg/default_luks...
Be aware that on-disk hardware encryption should generally not be trusted. It is not auditable or trivially verifiable. Some years back there were some revelations that some drive firmware encryption was woefully deficient. So much so that whereas Windows previously would treat on-disk encryption as sufficient, Microsoft stopped relying on it entirely.
But this is a development machine and I figured out that surprisingly non-trivial overhead of LUKS encryption in Linux is not worth it. On the plus side wake up from hibernation is very fast and to mitigate the risk of the above I configured the laptop to hibernate shortly after suspend.
But it really depends on what NVMe devices you use, I've seen cheap ones bottleneck at 30MB/s when doing continuous writes with no downtime.
RAM is getting so cheap and easy to get that in recent years I only really use swap on laptops. Using a CPU core for compression isn't a big deal in a laptop because you usually have 4 cores and only 1 of them in use most of the time.
Some of the heuristics designed to minimize pathological contention latency seem to implicitly assume that the swapping subsystem--both in its ability to help free space, and the latency it introduces when loading and evicting pages--will help mitigate the chance tasks will get caught in a tight contention loop. IOW, the I/O latency of swap effectively induces back pressure on load, helping operations freeing pages to progress faster than operations consuming pages. (Predictably, the faster your swap, the less well this works. When people began putting swap on SSDs, heuristics had to be retuned.)
Arguably the root of the problem is the legacy of overcommit. Even though it can be nominally disabled, many aspects of the kernel were designed with the notion that the only direction to move under memory pressure is forward, relying on the promise of the OOM killer eventually freeing up enough memory to maintain forward progress on the current operation, rather than unwinding and returning a failure condition. The dynamic seems similar to buffer bloat.
Windows, that does not have fork, does not suffer from this.
For example, if you hibernate a Linux machine, then boot it up and immediately re-hibernate, there should be barely any memory to write out (since very little will have changed since the last hibernation). Yet the written data is the whole image with no regards for the fact most of the data is already on disk and doesn't need to be rewritten.
Funny enough, this plays very well with RAID10: with each leg made of 2 different brands, a firmware failure will not affect you.
Just back sure they all use the same block size.
Generally speaking I dont think macOS as a whole dont put much thought into SSD Endurance. That is a problem because you cant swap your SSD on Mac.
I suspect Apple might have tweaked SSD firmware to behave better in various ways and increase endurance or performance near the end of the ssd's life, because if they hadn't I think we'd be seeing a flurry of people complaining about SSD failures by now.
In the before times, when I was a SunOS/Solaris admin in the 1990s we used to have a rule of thumb handed down from the boss that swap should be 2x physical memory but in the intervening years this seems like massive overkill. The Debian installer gave it 1Gb of swap as a default. Probably not enough to get you into trouble if something decided to go truly rogue but you can always hit the off switch.
I did toy with the idea of giving it 200Gb of swap but watching the process monitor with the dev environments running and a few VMs I struggle to break 64Gb of memory usage. It is running hybrid disks and not SSDs though.
If I ever bother to put SSDs in it (unlikely) I guess I'll think about it again but swap seems almost irrelevent on a workstation now. On a server...would probably have to get a new rule of thumb.
I'm typing this on a Windows system with 32GB of memory and an idle swap file. What I currently have open would probably fit into 16GB. But at the same time, I have over 30GB swapped out right now. 2x physical memory is about right for my desktop, when accounting for web browsers and electron apps and other programs the soak up gobs of memory and leave that data alone for days or weeks on end. Then there's the committed but unused memory on top of that, representing another 20GB of page file I need to have just to make it happy.
And then I have linux servers with 1-4 gigabytes of swap that use either none at all or a couple hundred megabytes of it.
Laptops would be a different story I guess.
My 980 Pro 1TB has about 3 PBW (about 5 times its rated warranty) and it still operates great.
The only time I've seen a significant part of write load coming from /var/log is when the systemd-journald log database or a database server replication log or rollback log is there.
etc.
For writing, you have to wait for the slow one.
Not sure how useful it is, but this is what btrfs/zfs people say
I would argue though that at this point most other filesystems have this, but they're not as ergonomic/obviously built in. LVM has integrity checking at the volume level (if you give drives to the pool instead of giving the pool an already-RAIDed device), mdraid has dm-integrity. The options are there but not quite as discoverable.
Also note that hard drives have had internal error detection and correction codes for decades, so SSDs doesn't change things much. Probably most checksum errors are misplaced writes and missing writes.
Also I use snapshots too.
A VM with a BTRFS filesystem running on a host using BTRFS gives serious write amplification. But if the real storage is SSD then it's not too bad.