bsdcon / vagrant-docker-vm

:computer: Docker VM for Development (customized)
https://webdevops.io/projects/vagrant-docker-vm/
MIT License
0 stars 0 forks source link

Address heavy swapping with memory hungry projects #13

Open adyp opened 6 years ago

adyp commented 6 years ago

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:

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

References:

adyp commented 6 years ago

Testing with a memory allocator tool showed encouraging behaviour.