Skip to content

3.5 RAM, swap and OOM handling

D3vil0p3r edited this page May 29, 2023 · 4 revisions

On traditional GNU/Linux system, especially for graphical workstations, when allocated memory is overcommitted, the overall system's responsiveness may degrade to a nearly unusable state before either triggering the in-kernel OOM-killer or a sufficient amount of memory got free (which is unlikely to happen quickly when the system is unresponsive, as you can hardly close any memory-hungry applications which may continue to allocate more memory). The behaviour also depends on specific setups and conditions, returning to a normal responsive state may take from a few seconds to more than half an hour, which could be a pain to wait in serious scenario like during a conference presentation.

Sometimes a user may prefer OOM daemon to SysRq because with kernel OOM-killer you cannot prioritize the process to (or not) terminate. One of these daemons used in Athena is NoHang, a sophisticated OOM handler written in Python, with optional PSI support, more configurable than earlyoom deamon. Source: https://github.com/hakavlad/nohang

Athena OS replaces zswap by zram in order to improve the performance. zswap operates as a compressed RAM cache and neither requires (nor permits) extensive userspace configuration, whereas zram is a kernel module which can be used to create a compressed block device in RAM. zswap works in conjunction with a swap device while zram does not require a backing swap device.

Since zram behaves differently than disk swap, in order to take full potential of the zram advantages, Athena has been configured with the following parameters:

vm.swappiness = 180
vm.watermark_boost_factor=0
vm.watermark_scale_factor = 125
vm.page-cluster=0

For checking if zswap has been disabled correctly, run cat /sys/module/zswap/parameters/enabled. For checking if zram has been enabled correctly, run zramctl or swapon --show or sudo systemctl status systemd-zram-setup@zramN.service (replace N by the correct number).

Source: https://wiki.archlinux.org/title/Zram