Depending on the available RAM, what value of swappiness is recommended?

I recently looked at it on the htop. For me, the installed system with 16 GB of RAM does not use a swap partition at the default 60 swappiness value. From this point of view, what about using SSDs?

i would say 10 :slight_smile:

My current workstation is using a swappiness of 5.

➜  ~ inxi -Cm
Memory:    RAM: total: 62.69 GiB used: 4.89 GiB (7.8%) 
CPU:       Info: 8-Core model: Intel Core i9-9900K bits: 64 type: MT MCP cache: L2: 16 MiB 
           Speed: 800 MHz min/max: 800/5000 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 
           4: 800 5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11: 800 12: 800 13: 800 14: 800 
           15: 800 16: 800 

As LInux is using RAM for file cache there’s several factors to consider.

  • vfs_cache_pressure
  • swapfile
  • swappiness
  • dirty_bytes
  • dirty_ratio
  • max_user_watches

You may gain extra knowledge by reading the following article on the Arch Wiki

https://wiki.archlinux.org/title/Improving_performance

2 Likes

16 GB is the minimum RAM where you should use a value of 10?

This is also worth reading.

1 Like

should there be a minimal value for some amount of ram ? personal always used is 10… when standard is much higher… some distro’s do 20 but some also say 0 is bad ,

I use 20 and also have set up zram with zram-generator.

https://wiki.archlinux.org/title/Improving_performance#zram_or_zswap

1 Like

0 is VERY bad, because OOM handling in Linux can be funny and when you dont have swap space can lead to the system just crashing if you disable it. If youre a decktop user with something like 32gb or more you “usually” wont ever see this but it could happen if a program misbehaves.

I personally like to have 2 tiers of swap. I use ZRam set to 1/2 my disk swap space as the main swap then if the system hits a particularly high memory pressure situation it will swap to disk. Ive also found that systems with smaller amounts of RAM can benefit from this sort of approach.

something to also keep in mind is that if you set the swappiness too low you may not start swapping till its too late if you do need to. I had inkscape at one point brutalizing my ram and it ended up just crashing the system because at a swappiness of 10 the system didnt start swapping in time to save the situation.

1 Like