systemd / zram-generator

Systemd unit generator for zram devices
MIT License
575 stars 48 forks source link

Feature: Dynamic zram devices #187

Closed axet closed 7 months ago

axet commented 11 months ago

Hello!

zram-generator allocating zram device once at boot time aiming to replace swap device.

But on systems with booth swap file and zram enabled zram-generator can allocate zram devices dynamically depend on memory requirements of system to allow low memory condition handled properly.

For example when system run on low memory condition, zram can slow down system significantly because most of the memory can be allocated to the zram swap it self. But zram-generator can check current memory conditions and decide to add zram device if system running out of zram space, or remove zram device causing swapping out zram pages into swap file, when system running out of memory due to many zram devices allocated?

It can work same as swapspace (https://github.com/Tookmund/Swapspace) daemon works and add / remove swap devices when needed.

axet commented 11 months ago

I wrote it based on swapspace code here: https://gitlab.com/axet/zramspace

yeedatoy commented 3 months ago

You don't want use swap and zram together. If you use swap and zram, swap acts as cache for zram compressing evicted memory pages before they can reach zram, rendering it counterproductive and at best ineffective, at worst having a huge negative effect. Zram is superior to swap and swap should be completely disabled when implementing zram in a system that already uses zswap