Pour accélérer la réactivité du PC, petite configuration en RAM ou disque SSD mieux vaut swaper le moins possible.
Environnement
PC sous Linux Debian 10 (Buster)
Description
Utilisation de zswap et compression lz4 pour compresser les données et les laisser en RAM le plus longtemps possible.
C.F https://www.kernel.org/doc/html/v4.18/vm/zswap.html
Mettre en place lz4
Dans /etc/initramfs-tools/modules
#LZ4 compression support for zswap
lz4
lz4_compress
Prendre en compte
# update-initramfs -u -k all
Mettre en place zswap
Dans /etc/default/grub ajouter les paramètres suivants à GRUB_CMDLINE_LINUX_DEFAULT=
zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=20 zswap.zpool=zbud
Prendre en compte
# update-grub
Vérification après redémarrage
# journalctl | grep zswap
mars 05 07:41:13 debian kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.19.0-3-amd64 root=UUID=78ec612e-d1d9-4c88-88ec-17d9b0815a8f ro quiet splash apparmor=1 security=apparmor radeon.pcie_gen2=0 btusb.enable_autosuspend=n zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=20 zswap.zpool=zbud
mars 05 07:41:13 debian kernel: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.19.0-3-amd64 root=UUID=78ec612e-d1d9-4c88-88ec-17d9b0815a8f ro quiet splash apparmor=1 security=apparmor radeon.pcie_gen2=0 btusb.enable_autosuspend=n zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=20 zswap.zpool=zbud
mars 05 07:41:13 debian kernel: zswap: loaded using pool lz4/zbud
# grep -R . /sys/module/zswap/parameters
/sys/module/zswap/parameters/same_filled_pages_enabled:Y
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/compressor:lz4
/sys/module/zswap/parameters/zpool:zbud
# free -ht
total used free shared buff/cache available
Mem:
3,6Gi 1,6Gi 166Mi 51Mi 1,8Gi 1,7Gi
Swap:
7,5Gi 0,0Ki 7,5Gi
Total:
11Gi 1,6Gi 7,6Gi
root@debian:/sys/kernel/debug/zswap# ls -la
total 0
drwxr-xr-x 2 root root 0 mars 7 11:05 .
drwx------ 33 root root 0 mars 7 11:05 ..
-r--r--r-- 1 root root 0 mars 7 11:05 duplicate_entry
-r--r--r-- 1 root root 0 mars 7 11:05 pool_limit_hit
-r--r--r-- 1 root root 0 mars 7 11:05 pool_total_size
-r--r--r-- 1 root root 0 mars 7 11:05 reject_alloc_fail
-r--r--r-- 1 root root 0 mars 7 11:05 reject_compress_poor
-r--r--r-- 1 root root 0 mars 7 11:05 reject_kmemcache_fail
-r--r--r-- 1 root root 0 mars 7 11:05 reject_reclaim_fail
-r--r--r-- 1 root root 0 mars 7 11:05 same_filled_pages
-r--r--r-- 1 root root 0 mars 7 11:05 stored_pages
-r--r--r-- 1 root root 0 mars 7 11:05 written_back_pages
root@debian:/sys/kernel/debug/zswap# cat *
0
0
10113024
0
0
0
0
38
4577
0
Avec utilisation un peu plus chargée: Chromium + Spotify + Molotov + Quodlibet + apt update
free -ht
total used free shared buff/cache available
Mem:
3,6Gi 2,0Gi 98Mi 174Mi 1,5Gi 1,2Gi
Swap:
7,5Gi 78Mi 7,4Gi
Total:
11Gi 2,1Gi 7,5Gi