So no, my experience with swap isn't that it's invisible with SSD.
So no, my experience with swap isn't that it's invisible with SSD.
I've had good experience with linux's multi-generation LRU feature, specifically the /sys/kernel/mm/lru_gen/min_ttl_ms feature that triggers OOM-killer when the "working set of the last N ms doesn't fit in memory".
Enables Multi-Gen LRU (improved page reclaim and caching policy).
Prevents thrashing, improves loading speeds under low ram conditions.
Requires kernel 6.1+.
Has dramatic effect especially on slower HDDs.
For slower HDDs, consider 1000 instead of 300 for min_ttl_ms.
sudo tee /etc/tmpfiles.d/mglru.conf <<EOF
w- /sys/kernel/mm/lru_gen/enabled - - - - y
w- /sys/kernel/mm/lru_gen/min_ttl_ms - - - - 300
EOFOn my 8gb M1 Mac, I can have a ton of tabs open and it'll swap with minimal slowdown. On the other hand, running a 4k external display and a small (4gb) llm is at best horrible and will sometimes require a hard reset.
I've seen similar with different combinations of software/hardware.
Dirty buffer should also be tuned (limited), absolutely. Default is 20% of RAM, (with 5 second writeback and 30 second expire intervals), which is COMPLETELY insane. I limit it to 64 MB max usually, with 1 second writeback and 3 second expire intervals.