Accepting request 1000767 from home:archerallstars

1. To disable multi-zRAM device creation (based on the number of CPU cores) in the original script, as it's deprecated, can cause some issues, and is unnecessary since kernel 4.7.

See https://bugzilla.suse.com/show_bug.cgi?id=1185928 and https://github.com/Nefelim4ag/systemd-swap/issues/176

2. To change the zRAM compression algorithm from "lzo-rle" to "zstd", as it yields the highest compression ratio, hence the fastest to complete the task. Both compression ratio and speed are better than "lzo-rle". Therefore, changing the compression algorithm to "zstd" will benefit zRAM usage.

See https://www.reddit.com/r/Fedora/comments/mzun99/new_zram_tuning_benchmarks/

OBS-URL: https://build.opensuse.org/request/show/1000767
OBS-URL: https://build.opensuse.org/package/show/filesystems/systemd-zram-service?expand=0&rev=6
This commit is contained in:
David Sterba 2022-09-05 11:01:40 +00:00 committed by Git OBS Bridge
parent 87abc78bcd
commit 17a3ee006a
2 changed files with 9 additions and 35 deletions

View File

@ -1,16 +1,6 @@
#!/bin/bash #!/bin/bash
# get the number of CPUs
num_cpus=$(grep -c processor /proc/cpuinfo)
# set decremented number of CPUs
decr_num_cpus=$((num_cpus - 1))
# Switching off swap # Switching off swap
for i in $(seq 0 $decr_num_cpus); do swapoff /dev/zram0
if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then
swapoff /dev/zram$i
fi
done
rmmod zram rmmod zram

View File

@ -1,34 +1,18 @@
#!/bin/bash #!/bin/bash
# get the number of CPUs
num_cpus=$(grep -c processor /proc/cpuinfo)
# if something goes wrong, assume we have 1
[ "$num_cpus" != 0 ] || num_cpus=1
# set decremented number of CPUs
decr_num_cpus=$((num_cpus - 1))
# get the amount of memory in the machine # get the amount of memory in the machine
mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+') mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
mem_total=$((mem_total_kb * 1024)) mem_total=$((mem_total_kb * 1024))
# load dependency modules # load the dependency module
#modprobe zram zram_num_devices=$num_cpus modprobe zram
# Determine module parm
mod_parm=$(modinfo zram |grep parm |tr -s " " |cut -f2 -d ":")
modprobe zram $mod_parm=$num_cpus
# initialize the devices # initialize the device with zstd compression algorithm
for i in $(seq 0 $decr_num_cpus); do echo zstd > /sys/block/zram0/comp_algorithm;
echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize echo $mem_total > /sys/block/zram0/disksize
done
# Creating swap filesystems # Creating the swap filesystem
for i in $(seq 0 $decr_num_cpus); do mkswap /dev/zram0
mkswap /dev/zram$i
done
# Switch the swaps on # Switch the swaps on
for i in $(seq 0 $decr_num_cpus); do swapon -p 100 /dev/zram0
swapon -p 100 /dev/zram$i
done