Author Topic: Linux: to swap or not to swap?  (Read 6087 times)

0 Members and 1 Guest are viewing this topic.

Offline alm

  • Super Contributor
  • ***
  • Posts: 2881
  • Country: 00
Re: Linux: to swap or not to swap?
« Reply #75 on: April 23, 2023, 10:54:19 pm »
There is no shortage, so why even evict rarely used (hint: there is not such thing as unused memory that is claimed/in use by an application) if it isn't necessary?

Because for most workloads more cache is better. Some pages might only be necessary when you shut down your computer, or for remote access which you use once per month.

Keep in mind that without swap, the kernel doesn't need to keep track of which pages are used regulary and which not.
I feel like I'm repeating myself, but no this is not how it works. The kernel will still evict pages and need to keep track of which to evict, the eviction will just be limited to file backed pages. So instead of swapping out that anonymous memory allocated by a backup program that runs during the night, it might evict a font or shared library that you haven't used recently.

Offline magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: Linux: to swap or not to swap?
« Reply #76 on: April 23, 2023, 11:07:57 pm »
(hint: there is no such thing as unused memory that is claimed/in use by an application)
In a perfect world ;)

Keep in mind that without swap, the kernel doesn't need to keep track of which pages are used regulary and which not.
Still does. From a router with no swap support at all:
Code: [Select]
# cat /proc/meminfo
MemTotal:         126324 kB
MemFree:           96604 kB
Buffers:            2172 kB
Cached:             8808 kB
SwapCached:            0 kB
Active:             9816 kB
Inactive:           4456 kB
Active(anon):       4372 kB
Inactive(anon):       92 kB
Active(file):       5444 kB
Inactive(file):     4364 kB
blah blah
 

Online NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9018
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Linux: to swap or not to swap?
« Reply #77 on: April 25, 2023, 01:52:22 am »
For well over 10 years, every PC I set up didn't have swap. Never had any problem with it.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline olkipukki

  • Frequent Contributor
  • **
  • Posts: 790
  • Country: 00
Re: Linux: to swap or not to swap?
« Reply #78 on: April 30, 2023, 09:40:47 pm »
So the question is, is a swap partition necessary for a desktop/workstation use, 64GB+ RAM and a Linux 6.x kernel?
On 64GB machine I keep a swap 'just in case' of 1/2 size of RAM.
Usually, couple VMs runs at same time, although a swap used rarely.

... and what would be any issue with not having any swap?
Trying to hibernate 256GB RAM Linux didn't end up well  >:D
 

Offline SiliconWizardTopic starter

  • Super Contributor
  • ***
  • Posts: 14475
  • Country: fr
Re: Linux: to swap or not to swap?
« Reply #79 on: May 01, 2023, 02:34:14 am »
For well over 10 years, every PC I set up didn't have swap. Never had any problem with it.

That's also my experience, with the disclaimer - that I stated - that I haven't been running Linux for real, heavy workstation use, hence the question more aimed at this use case.
My uses have mostly been on a laptop (which has 'light' use) and a headless box that I use for development purposes. In both cases, no swap, and never had any trouble with it.

But this time, it would be for 'heavy' workstation use, and typically putting the machine in standby when not in use (no hibernation as I said), so potentially relatively long up times.

My conclusion so far is what has been said a few posts ago - I'm going to activate a swap partition on a small dedicated SATA SSD, that will also be used for cache files and otherwise content that changes frequently, so that I limit the wear on the much more expensive, NVMe SSDs that I have.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf