Skip to content

Commit 72dfbb4

Browse files
committed
Additional zram + swap tuning
1 parent c7f7e83 commit 72dfbb4

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
# Compressed swap in RAM, sized the way Fedora has shipped it since F34: all of
2-
# memory, capped at 8G. Fedora weighed the worry that incompressible pages would
3-
# tie up RAM against five years of desktops reporting no trouble from it, which
4-
# is more field evidence than we could gather on our own.
5-
#
6-
# The cap is what bounds the downside. A browser-heavy desktop can drive zstd
7-
# down near 1.1:1, where the device backs far less than it advertises, and 8G
8-
# keeps that bounded on any machine large enough to notice. The disk swapfile
9-
# sits behind it at pri=0 for everything past that.
10-
#
11-
# Fedora spells this zram-fraction = 1.0 with max-zram-size = 8192; both keys
12-
# are deprecated in favour of zram-size, which computes the same numbers.
1+
# Compressed swap in RAM. zstd averages around 3:1, so even a full device
2+
# occupies roughly a third of RAM. Any smaller cap spills reclaim to the disk
3+
# swapfile, which on encrypted installs pages back through LUKS.
134
[zram0]
14-
zram-size = min(ram, 8192)
5+
zram-size = ram
156
compression-algorithm = zstd
167

17-
# Above the pri=0 that omarchy-hibernation-setup gives the disk swapfile, so
18-
# zram absorbs everything until it's full.
8+
# Above the pri=0 that omarchy-hibernation-setup gives the disk swapfile.
199
swap-priority = 100

‎etc/sysctl.d/99-omarchy-sysctl.conf‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ net.ipv4.tcp_mtu_probing=1
77
# Anything above 100 tells the kernel that evicting an anonymous page is
88
# cheaper than dropping a page-cache page it would have to re-read from disk.
99
# With a compressed RAM device that is true, so the disk-era default of 60
10-
# leaves the page cache starved.
11-
vm.swappiness=180
10+
# leaves the page cache starved. Stop at 150: every page swapped still costs
11+
# a compression now and a decompression on fault-back.
12+
vm.swappiness=150
13+
14+
# Halve the eagerness to drop dentry/inode cache, which is costly to rebuild
15+
# and can't spill to zram. Not lower: 0 can OOM.
16+
vm.vfs_cache_pressure=50
1217

1318
# Read one page per swap-in fault. The default of 8 pays for a seek that zram
1419
# doesn't have, and every extra page costs a separate decompression.
@@ -21,3 +26,11 @@ vm.watermark_boost_factor=0
2126
# Keep ~1.25% of memory free instead of 0.1%, so kswapd reclaims in the
2227
# background rather than letting allocations stall in direct reclaim.
2328
vm.watermark_scale_factor=125
29+
30+
# Cap dirty pages at 64M/256M instead of the default 10%/20% of RAM, which
31+
# lets gigabytes of writeback pile up and flush in stalling bursts.
32+
vm.dirty_background_bytes=67108864
33+
vm.dirty_bytes=268435456
34+
35+
# With bursts bounded above, the flusher can wake every 15s instead of 5s.
36+
vm.dirty_writeback_centisecs=1500

‎etc/tmpfiles.d/omarchy-zswap.conf‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Arch's kernel enables zswap by default, which in front of swap-on-zram just
2+
# double-compresses pages and breaks zramctl accounting. Boot-only (w!), so
3+
# flipping it on by hand for an experiment sticks until reboot.
4+
w! /sys/module/zswap/parameters/enabled - - - - N

0 commit comments

Comments
 (0)