{"id":17991709,"url":"https://github.com/hakavlad/memavaild","last_synced_at":"2025-03-25T23:32:25.517Z","repository":{"id":145292788,"uuid":"220536168","full_name":"hakavlad/memavaild","owner":"hakavlad","description":"Improve responsiveness during heavy swapping: keep amount of available memory","archived":false,"fork":false,"pushed_at":"2021-05-03T03:52:48.000Z","size":90,"stargazers_count":42,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-20T23:01:49.903Z","etag":null,"topics":["cgroups"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hakavlad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-08T19:41:19.000Z","updated_at":"2025-03-18T13:38:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"e29b941b-bfd8-4e15-b4b1-ea3461072091","html_url":"https://github.com/hakavlad/memavaild","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fmemavaild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fmemavaild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fmemavaild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fmemavaild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hakavlad","download_url":"https://codeload.github.com/hakavlad/memavaild/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245562284,"owners_count":20635896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgroups"],"created_at":"2024-10-29T19:23:33.511Z","updated_at":"2025-03-25T23:32:25.479Z","avatar_url":"https://github.com/hakavlad.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\n# memavaild\n\n![CodeQL](https://github.com/hakavlad/memavaild/workflows/CodeQL/badge.svg)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/hakavlad/memavaild.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/hakavlad/memavaild/alerts/)\n[![Packaging status](https://repology.org/badge/tiny-repos/memavaild.svg)](https://repology.org/project/memavaild/versions)\n\nImprove responsiveness during heavy swapping: keep amount of available memory.\n\n\u003e \"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.\"\n\n— [Benjamin Berg](https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/3VNHWVRSGPYCFC6LUCNGUBUPSLZJT7OE/)\n\nDefault 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.\n\nEffects: 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.\n\n## Requirements\n\n- Python 3.3+\n- systemd with unified cgroup hierarchy\n\n## How to enable unified cgroup hierarchy\n\nUnified cgroup hierarchy is enabled by default on Fedora 31+. On other distros pass `systemd.unified_cgroup_hierarchy=1` to the kernel boot cmdline.\n\n## Known problems\n- The documentation is terrible (no config keys description, for example);\n- 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](https://github.com/openzfs/zfs/issues/10255)). Don't use `memavaild` with ZFS;\n- Seems like `memavaild` violates [the second rule](https://systemd.io/CGROUP_DELEGATION/): `memavaild` manipulates the attributes of cgroups created by systemd (`memavaild` changes `memory.high` values).\n\n## Install\n\n#### For Arch Linux there's an [AUR package](https://aur.archlinux.org/packages/memavaild/)\n\nUse your favorite [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers). For example,\n```bash\n$ yay -S memavaild\n$ sudo systemctl enable --now memavaild.service\n```\n[memavaild-git](https://aur.archlinux.org/packages/memavaild-git/) is also available.\n\n#### To install on Debian and Ubuntu-based systems:\n\nIt's easy to build a deb package with the latest git snapshot. Install build dependencies:\n```bash\n$ sudo apt install make fakeroot\n```\n\nClone the latest git snapshot and run the build script to build the package:\n```bash\n$ git clone https://github.com/hakavlad/memavaild.git \u0026\u0026 cd memavaild\n$ deb/build.sh\n```\n\nInstall the package:\n```bash\n$ sudo apt install --reinstall ./deb/package.deb\n```\n\nStart and enable `memavaild.service` after installing the package:\n```bash\n$ sudo systemctl enable --now memavaild.service\n```\n\n#### On other distros:\n\nInstall:\n```bash\n$ git clone https://github.com/hakavlad/memavaild.git \u0026\u0026 cd memavaild\n$ sudo make install\n$ sudo systemctl enable --now memavaild.service\n```\n\nUninstall:\n```bash\n$ sudo make uninstall\n```\n\n## How to configure\n\nEdit the config (`/etc/memavaild.conf` or `/usr/local/etc/memavaild.conf`) and restart the service.\n\n## Demo\n\n- `stress -m 9 --vm-bytes 99G` without full freezing (with swap on zram): https://www.youtube.com/watch?v=DJq00pEt4xg. This is an old demo that demonstrates how memavaild can keep available memory.\n- `stress -m 8 --vm-bytes 32G` with no freeze: `prelockd` + `memavaild` + `nohang-desktop` + `zram`, system on HDD: https://www.youtube.com/watch?v=veY606v57Hk\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakavlad%2Fmemavaild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakavlad%2Fmemavaild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakavlad%2Fmemavaild/lists"}