Menu Close
Red Hat Training
A Red Hat training course is available for RHEL 8
Chapter 19. Improving system performance with zswap
You can improve system performance by enabling the zswap
kernel feature.
19.1. What is zswap
This section explains what zswap
is and how it can lead to system performance improvement.
zswap
is a kernel feature that provides a compressed RAM cache for swap pages. The mechanism works as follows: zswap
takes pages that are in the process of being swapped out and attempts to compress them into a dynamically allocated RAM-based memory pool. When the pool becomes full or the RAM becomes exhausted, zswap
evicts pages from compressed cache on an LRU basis (least recently used) to the backing swap device. After the page has been decompressed into the swap cache, zswap
frees the compressed version in the pool.
- The benefits of
zswap
- significant I/O reduction
- significant improvement of workload performance
In Red Hat Enterprise Linux 8, zswap
is enabled by default.
Additional resources
19.2. Enabling zswap at runtime
You can enable the zswap
feature at system runtime using the sysfs
interface.
Prerequisites
- You have root permissions.
Procedure
Enable
zswap
:# echo 1 > /sys/module/zswap/parameters/enabled
Verification step
Verify that
zswap
is enabled:# grep -r . /sys/kernel/debug/zswap duplicate_entry:0 pool_limit_hit:13422200 pool_total_size:6184960 (pool size in total in pages) reject_alloc_fail:5 reject_compress_poor:0 reject_kmemcache_fail:0 reject_reclaim_fail:13422200 stored_pages:4251 (pool size after compression) written_back_pages:0
Additional resources
19.3. Enabling zswap permanently
You can enable the zswap
feature permanently by providing the zswap.enabled=1
kernel command-line parameter.
Prerequisites
- You have root permissions.
-
The
grubby
orzipl
utility is installed on your system.
Procedure
Enable
zswap
permanently:# grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="zswap.enabled=1"
- Reboot the system for the changes to take effect.
Verification steps
Verify that
zswap
is enabled:# cat /proc/cmdline BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-372.9.1.el8.x86_64 root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet zswap.enabled=1
Additional resources