|
11 | 11 | # Priority of the zram swap devices. |
12 | 12 | # It should be a number higher than the priority of your disk-based swap devices |
13 | 13 | # (so that the system will fill the zram swap devices before falling back to disk swap). |
14 | | - priority = 5; |
| 14 | + priority = 100; |
15 | 15 | # Maximum total amount of memory that can be stored in the zram swap devices (as a percentage of your total memory). |
16 | 16 | # Defaults to 1/2 of your total RAM. Run zramctl to check how good memory is compressed. |
17 | 17 | # This doesn’t define how much memory will be used by the zram swap devices. |
18 | 18 | memoryPercent = 50; |
19 | 19 | }; |
| 20 | + |
| 21 | + # Optimizing swap on zram |
| 22 | + boot.kernel.sysctl = { |
| 23 | + # vm.swappiness - Controls kernel preference for swapping (range: 0-200, default: 60) |
| 24 | + # For in-memory swap devices like zram/zswap, values above 100 are recommended. |
| 25 | + "vm.swappiness" = 180; |
| 26 | + |
| 27 | + # vm.watermark_boost_factor - Controls aggressiveness of memory reclaim (default: 15000) |
| 28 | + # Setting to 0 disables watermark boost, preventing premature memory reclamation. |
| 29 | + # This allows fuller memory utilization before the kernel starts reclaiming pages. |
| 30 | + "vm.watermark_boost_factor" = 0; |
| 31 | + |
| 32 | + # vm.watermark_scale_factor - Controls kswapd wakeup frequency (range: 1-1000, default: 10) |
| 33 | + # A higher value triggers background memory reclamation earlier (at 12.5% memory pressure). |
| 34 | + # Value 125 means kswapd becomes active when free memory drops below 1/125 of total memory, |
| 35 | + # balancing memory more proactively to prevent sudden swap storms at high swappiness values. |
| 36 | + "vm.watermark_scale_factor" = 125; |
| 37 | + |
| 38 | + # vm.page-cluster - Controls swap readahead (range: 0-6, default: 3) |
| 39 | + # 0 means read only 1 page (2^0) at a time, disabling readahead. |
| 40 | + # For low-latency devices like zram, readahead hurts performance by fetching unnecessary data. |
| 41 | + "vm.page-cluster" = 0; |
| 42 | + }; |
20 | 43 | } |
0 commit comments