So, for typical desktop use (not talking about server use), assuming you're actually not running out of memory, whether this actually gets your better performance on average in any given, real-life situation (as is often claimed here and there) is almost undecidable. You can only cherry pick very specific situations for which it actually wouldOn average it will either improve performance by giving the kernel more options in how to most efficiently manage memory or just not make a difference. Only if you cherry pick very specific situations where the kernel gets it wrong might it negatively affect performance. Whether that's enough to warrant the effort and SSD storage to set up swap is up to the individual.then claim that whoever disables swap is an idiotThere's a difference between saying "you're wrong for disabling swap" and "you're wrong for disabling swap with the goal of improving performance".
The problem I have with swap is that I have applications open for several days before using them. With swap enabled, it takes time to activate those applications.
And what do you think would happen under the same memory pressure without swap?
Nothing. The pages would be readily available in RAM.
In a previous decade on a lousy 32-bit netbook, I recall (after checking free memory => used swap memory), I used a script to periodically turn off and back on the swap to force the system purge the swap file to recover system snappiness without the need to reboot. Unlike other OS's.
Can you even still do this now? (I'm in the swap minimal or even no swap camp)
sudo swapoff -a ; sudo swapon -a
You seem to think that without swap the kernel won't get rid of data in memory. It will, just only some types of data (file backed pages).
$ free -h
total used free shared buff/cache available
Mem: 62Gi 20Gi 9.1Gi 369Mi 33Gi 42Gi
Swap: 0B 0B 0B
Which it will also have to reload whenever the application becomes active again.
I remember twenty years ago when computers had maybe 64MB of memory that programs you hadn't used for a while had to be reloaded from hard drive, which took forever.
Which it will also have to reload whenever the application becomes active again.No. Why? The application data (code and whatever data structures it uses) is already in memory.
Code and and read only data sections are memory mapped into the process and treated mostly* like all other file-backed data - subject to eviction under memory pressure and then faulted-in when the process attempts to resume execution.
Correct, but only if there is not enough free memory for newly written malloc()'ed pages. It will then free up some buffer/cache pages.
In this situation, however, it will not:
No. Why? The application data (code and whatever data structures it uses) is already in memory. If the app is terminated and restarted, then yes, it will need to read from disk, unless the respective files, which are typically very small binaries, are cached.
The problem I have with swap is that I have applications open for several days before using them. With swap enabled, it takes time to activate those applications. There is more than enough memory in my system to work with so swap simply isn't necessary.
Code and and read only data sections are memory mapped into the process and treated mostly* like all other file-backed data - subject to eviction under memory pressure and then faulted-in when the process attempts to resume execution.I doubt that. But even if it is so, code is tiny. Most of the memory is taken by structures for which memory is allocated with malloc() and then written into. These cannot be evicted other than along with killing the process by the OOM killer.
Indeed. The kernel can not decide to discard data from memory at will because it doesn't know whether it is used or not.
File backed pages is another word for disk caching.
If swap affects GUI, maybe the system runs too many processes for its RAM (more likely) or it needs changing configuration (less likely) by limiting memory(1) with cgroups for offending services?
Probably a very common question, that has been answered numerous times. But one more time doesn't hurt, with possibly answers related to *recent* versions of Linux and various points of view.
So the question is, is a swap partition necessary for a desktop/workstation use, 64GB+ RAM and a Linux 6.x kernel?
What is the benefit in this particular case, and what would be any issue with not having any swap?
About SSD: You could mount /var and /tmp on a classic HD.
Sorry, but an application will need to mmap a file onto memory specifically for your case to work. This unlikely for most applications. From what I've seen most applications will load a file into memory, break it into structures and write it back on disk when it is done. An exception may be databases but that is more appropriate for servers that run a narrow range of applications.
Ofcourse you can resort to setting swapiness to 0 but not configuring a swap space is simply less work.
Whether on a HDD or a separate SSD as I suggested (for performance, even if that means a slightly shorter lifetime of this one which would essentially contain just temporary data.)
After that, I never, ever had any swap on any machine, unless I expect it to be short on ram for some reason like big builds, video edition, etc. I think is *way* better to have more ram if needed and at all possible.