nefelim4ag / systemd-swap

Script for creating hybrid swap space from zram swaps, swap files and swap partitions.
GNU General Public License v3.0
550 stars 81 forks source link

Suggestion: update zram algo list in default config #185

Closed unquietwiki closed 3 years ago

unquietwiki commented 3 years ago

Kernel Version 4.19.x , Debian 10.,x

cat /sys/block/zram0/comp_algorithm
[lzo] lz4 lz4hc
vilgotf commented 3 years ago

Please post the content of your configuration files (/etc/systemd/swap.conf and /etc/systemd/swap.conf.d/*)

unquietwiki commented 3 years ago

Here you go. The default setting is zstd

#  This file is part of systemd-swap.
#
# Entries in this file show the systemd-swap defaults as
# specified in /usr/share/systemd-swap/swap-default.conf
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See swap.conf(5) and /usr/share/systemd-swap/swap-default.conf for details.

zswap_enabled=0
zswap_compressor=zstd
zswap_max_pool_percent=25
zswap_zpool=z3fold
zram_enabled=1
zram_size=$(( RAM_SIZE / 4 ))
zram_count=${NCPU}
zram_streams=${NCPU}
zram_alg=lz4hc
zram_prio=32767
#swapfc_enabled=0
#swapfc_force_use_loop=0
#swapfc_frequency=1
#swapfc_chunk_size=256M
#swapfc_max_count=32
#swapfc_min_count=0
#swapfc_free_ram_perc=35
#swapfc_free_swap_perc=15
#swapfc_remove_free_swap_perc=55
#swapfc_priority=50
#swapfc_path=/var/lib/systemd-swap/swapfc/
#swapfc_nocow=1
#swapfc_directio=1
#swapfc_force_preallocated=0
#swapd_auto_swapon=1
#swapd_prio=1024
vilgotf commented 3 years ago

The default setting is zstd for zswap but lz4hc for zram per your config. Does changing it to zstd resolve your issue?

unquietwiki commented 3 years ago

@vilgotf No, zstd was causing the problem; lz4hc resolved the issue.

unquietwiki commented 3 years ago

https://stackoverflow.com/questions/28635496/difference-lz77-vs-lz4-vs-lz4hc-compression-algorithms I found an explanation as to the different algorithms. Why the kernel on my Debian 10 install only has lz4-based options, I am not sure.

vilgotf commented 3 years ago

Yes, it seems that debian has enabled it for newer kernels[1] but seemingly not in the base kernel of debian 10. Since this seems to only affect Debian the current configuration will stay the same.

1: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=932722

unquietwiki commented 3 years ago

@vilgotf You may want to document this somewhere aside from GitHub issues, so you don't get repeat tickets on this. I know 4.19 kernels, in general, are a thing on cloud servers (this is one of those).