All Projects → hakavlad → memavaild

hakavlad / memavaild

Licence: MIT license
Improve responsiveness during heavy swapping: keep amount of available memory

Programming Languages

python
139335 projects - #7 most used programming language
Roff
2310 projects
Makefile
30231 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to memavaild

diyC
A simple educational linux container runtime.
Stars: ✭ 87 (+200%)
Mutual labels:  cgroups
docker-advance-training-exercise
Materials for Docker Advanced training
Stars: ✭ 14 (-51.72%)
Mutual labels:  cgroups
navio
Navio is a program to create and manage linux containers. This project exists only for study purposes, so feel free to contribute :)
Stars: ✭ 14 (-51.72%)
Mutual labels:  cgroups
potd
A high scalable low to medium interactive SSH/TCP honeypot using Linux Namespaces, capabilities, seccomp, cgroups designed for OpenWrt and IoT devices.
Stars: ✭ 28 (-3.45%)
Mutual labels:  cgroups

memavaild

CodeQL Total alerts Packaging status

Improve responsiveness during heavy swapping: keep amount of available memory.

"If you actually tried to use the memory it says in MemAvailable, you may very well already get bad side effects as the kernel needs to reclaim memory used for other purposes (file caches, mmap'ed executables, heap, …). Depending on the workload, this may already cause the system to start thrashing."

Benjamin Berg

Default behavior: the control groups specified in the config (user.slice and system.slice) are swapped out when MemAvailable is low by reducing memory.high (values change dynamically). memavaild tries to keep about 3% available memory.

Effects: tasks are performed at less I/O and memory pressure (and this may be detected by PSI metrics). At the same time, performance may be increased in tasks that requires heavy swapping, especially in I/O bound tasks. Using memavaild has no effect without swap space.

Requirements

  • Python 3.3+
  • systemd with unified cgroup hierarchy

How to enable unified cgroup hierarchy

Unified cgroup hierarchy is enabled by default on Fedora 31+. On other distros pass systemd.unified_cgroup_hierarchy=1 to the kernel boot cmdline.

Known problems

  • The documentation is terrible (no config keys description, for example);
  • The ZFS ARC cache is memory-reclaimable, like the Linux buffer cache. However, in contrast to the buffer cache, it currently does not count to MemAvailable (see openzfs/zfs#10255). Don't use memavaild with ZFS;
  • Seems like memavaild violates the second rule: memavaild manipulates the attributes of cgroups created by systemd (memavaild changes memory.high values).

Install

For Arch Linux there's an AUR package

Use your favorite AUR helper. For example,

$ yay -S memavaild
$ sudo systemctl enable --now memavaild.service

memavaild-git is also available.

To install on Debian and Ubuntu-based systems:

It's easy to build a deb package with the latest git snapshot. Install build dependencies:

$ sudo apt install make fakeroot

Clone the latest git snapshot and run the build script to build the package:

$ git clone https://github.com/hakavlad/memavaild.git && cd memavaild
$ deb/build.sh

Install the package:

$ sudo apt install --reinstall ./deb/package.deb

Start and enable memavaild.service after installing the package:

$ sudo systemctl enable --now memavaild.service

On other distros:

Install:

$ git clone https://github.com/hakavlad/memavaild.git && cd memavaild
$ sudo make install
$ sudo systemctl enable --now memavaild.service

Uninstall:

$ sudo make uninstall

How to configure

Edit the config (/etc/memavaild.conf or /usr/local/etc/memavaild.conf) and restart the service.

Demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].