Swap: Difference between revisions
Artoria2e5 (talk | contribs) |
Artoria2e5 (talk | contribs) →Adjusting swap usage behaviour: It's more of a process(anon page):cache ratio |
||
| Line 141: | Line 141: | ||
== Adjusting swap usage behaviour == | == Adjusting swap usage behaviour == | ||
[https://docs.kernel.org/admin-guide/sysctl/vm.html#swappiness Swappiness] controls how aggressibely swap space is used. By default, Linux uses a swappiness value of 60. Higher values will make the kernel prefer swapping out idle processes | [https://docs.kernel.org/admin-guide/sysctl/vm.html#swappiness Swappiness] controls how aggressibely swap space is used, specifically how to free up memory when needed. By default, Linux uses a swappiness value of 60. Higher values will make the kernel prefer swapping out idle processes over dropping caches. Conversely lower values will try to avoid swapping as much as possible, keeping processes in RAM unless absolutely necessary. An optimal value is workload dependent and will will require experimentation. | ||
{{file|/etc/nixos/configuration.nix|nix| | {{file|/etc/nixos/configuration.nix|nix| | ||
| Line 151: | Line 151: | ||
}} | }} | ||
You can see your current swappiness level by <code>cat /proc/sys/vm/swappiness</code>. | You can see your current swappiness level by <code>cat /proc/sys/vm/swappiness</code>. The lowest accepted value is "0" while the maximum value is "200". The lowest sane value is "1" ("0" causes the system to not scan for unused anonymous pages, i.e. memory freed by processes, at all). | ||
For more on tuning the swap, start with [https://wiki.archlinux.org/title/Swap#swappiness ArchWiki]'s description. | |||
== ZFS and swap == | == ZFS and swap == | ||