When running memory heavy projects inside the VM, the default swap configuration / sizing is not convenient as the machine slows down considerably with swap in/out operations.
The default-installed zram-config package is only avoiding disk-backed memory swapping (which is proper for embedded systems or flash storage) thus not quite addressing the needs of large projects. Instead we need to allow swapping out to disk inactive large processes, at least temporarily until the memory usage is back to lower levels.
Soutions:
install by default the dynamic swapper daemon (package swapspace) -- we had good experience with it
replace using zram with zswap which not only compresses in memory but also evicts pages from RAM to real swap backends
Quoting Wikipedia page for zswap:
The maximum size of the memory pool used by zswap is configurable through the sysfs parameter max_pool_percent, which specifies the maximum percentage of total system RAM that can be occupied by the pool. The memory pool is not preallocated to its configured maximum size, and instead grows and shrinks as required. When the configured maximum pool size is reached as the result of performed swapping, or when growing the pool is impossible due to an out-of-memory condition, swapped pages are evicted from the memory pool to a swap device on the least recently used (LRU) basis. This approach makes zswap a true swap cache, as the oldest cached pages are evicted to a swap device once the cache is full, making room for newer swapped pages to be compressed and cached
When running memory heavy projects inside the VM, the default swap configuration / sizing is not convenient as the machine slows down considerably with swap in/out operations.
The default-installed
zram-config
package is only avoiding disk-backed memory swapping (which is proper for embedded systems or flash storage) thus not quite addressing the needs of large projects. Instead we need to allow swapping out to disk inactive large processes, at least temporarily until the memory usage is back to lower levels.Soutions:
swapspace
) -- we had good experience with itzram
withzswap
which not only compresses in memory but also evicts pages from RAM to real swap backendsQuoting Wikipedia page for
zswap
:References: