From b6cae7e72f203862565208bb8a2e6aa82cd4c3b8 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Tue, 6 Feb 2024 17:25:24 +0400 Subject: [PATCH] Add Zram config --- etc/sysctl.d/tileos.conf | 5 +++++ etc/udev/rules.d/30-zram.rules | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 etc/udev/rules.d/30-zram.rules diff --git a/etc/sysctl.d/tileos.conf b/etc/sysctl.d/tileos.conf index eba0192..64709e1 100644 --- a/etc/sysctl.d/tileos.conf +++ b/etc/sysctl.d/tileos.conf @@ -68,3 +68,8 @@ vm.dirty_background_bytes = 134217728 # The kernel flusher threads will periodically wake up and write old data out to disk. This # tunable expresses the interval between those wakeups, in 100'ths of a second (Default is 500). vm.dirty_writeback_centisecs = 1500 + +# The sysctl swappiness parameter determines the kernel's preference for pushing anonymous pages or page cache to disk in memory-starved situations. +# A low value causes the kernel to prefer freeing up open files (page cache), a high value causes the kernel to try to use swap space, +# and a value of 100 means IO cost is assumed to be equal. +vm.swappiness = 100 diff --git a/etc/udev/rules.d/30-zram.rules b/etc/udev/rules.d/30-zram.rules new file mode 100644 index 0000000..cf3ba27 --- /dev/null +++ b/etc/udev/rules.d/30-zram.rules @@ -0,0 +1,22 @@ +# Prefer to recompress only huge pages. This will result in additional memory +# savings, but may slightly increase CPU load due to additional compression +# overhead. +ACTION=="add", KERNEL=="zram[0-9]*", ATTR{recomp_algorithm}="algo=lz4 priority=1", \ + RUN+="/sbin/sh -c echo 'type=huge' > /sys/block/%k/recompress" + +TEST!="/dev/zram0", GOTO="zram_end" + +# Since ZRAM stores all pages in compressed form in RAM, we should prefer +# preempting anonymous pages more than a page (file) cache. Preempting file +# pages may not be desirable because a process may want to access a file at any +# time, whereas if it is preempted, it will cause an additional read cycle from +# the disk. +SYSCTL{vm.swappiness}="150" + +# Optimal value for games, so sets not too aggressive, but also not too weak +# kswapd behavior, as described there: +# https://www.reddit.com/r/linux_gaming/comments/vla9gd/comment/ie1cnrh/ +SYSCTL{vm.watermark_scale_factor}="125" +SYSCTL{vm.watermark_boost_factor}="0" + +LABEL="zram_end"