descriptionSuper lightweight process killer daemon for Linux
homepage URLhttp://github.com/vrmiguel/bustd
repository URLhttps://github.com/vrmiguel/bustd.git
ownervrmiguel99@gmail.com
last changeMon, 30 Oct 2023 22:22:38 +0000 (30 19:22 -0300)
last refreshWed, 24 Apr 2024 09:17:34 +0000 (24 11:17 +0200)
content tags
add:
README.md

bustd: Available memory or bust!

bustd is a lightweight process killer daemon for out-of-memory scenarios for Linux!

Features

Small memory usage!

bustd seems to use less memory than some other lean daemons such as earlyoom:

$ ps -F -C bustd
UID          PID    PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
vrmiguel  353609  187407  5   151     8   2 01:20 pts/2    00:00:00 target/x86_64-unknown-linux-musl/release/bustd -V -n

$ ps -F -C earlyoom
UID          PID    PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
vrmiguel  350497    9498  0   597   688   6 01:12 pts/1    00:00:00 ./earlyoom/

¹: RSS stands for resident set size and represents the portion of RAM occupied by a process.

²: Compared when bustd was in this commit and earlyoom in this one. bustd compiled with musl libc and earlyoom with glibc through GCC 11.1. Different configurations would likely change these figures.

Small CPU usage

Much like earlyoom and nohang, bustd uses adaptive sleep times during its memory polling. Unlike these two, however, bustd does not read from /proc/meminfo, instead opting for the sysinfo syscall.

This approach has its up- and downsides. The amount of free RAM that sysinfo reads does not account for cached memory, while MemAvailable in /proc/meminfo does.

The sysinfo syscall is one order of magnitude faster, at least according to this kernel patch (granted, from 2015).

As bustd can't solely rely on the free RAM readings of sysinfo, we check for memory stress through Pressure Stall Information.

bustd will try to lock all pages mapped into its address space

Much like earlyoom, bustd uses mlockall to avoid being sent to swap, which allows the daemon to remain responsive even when the system memory is under heavy load and susceptible to thrashing.

Checks for Pressure Stall Information

The Linux kernel, since version 4.20 (and built with CONFIG_PSI=y), presents canonical new pressure metrics for memory, CPU, and IO. In the words of Facebook Incubator:

PSI stats are like barometers that provide fair warning of impending resource
shortages, enabling you to take more proactive, granular, and nuanced steps
when resources start becoming scarce.

More specifically, bustd checks for how long, in microseconds, processes have stalled in the last 10 seconds. By default, bustd will kill a process when processes have stalled for 25 microseconds in the last ten seconds.

Packaging

Arch Linux

Available on the Arch User Repository

Gentoo

Available on the GURU project

Pop!_OS

Available on the Pop!_OS PPA (outdated)

Building

Requirements:

git clone https://github.com/vrmiguel/bustd
cd bustd && cargo run --release

The -n, --no-daemon flag is useful for running bustd through an init system such as systemd.

Prebuilt binaries

Binaries are generated at every commit through GitHub Actions

TODO

shortlog
2023-10-30 Vinícius R... Speed up procfs scanningmaster
2023-06-03 Vinícius R... Several `utils`-related little refactorings
2023-06-03 Vinícius R... uname: skip use of `str_from_u8`
2023-06-03 Vinícius R... Use `memchr` in `str_from_u8`
2023-06-03 Vinícius R... Update dependencies
2022-12-05 Vinícius MiguelMerge pull request #17 from eminence/procfs_update
2022-12-04 Andrew ChinUpdate to latest procfs
2022-05-12 Vinícius Rodrigues... Add the `safe_ffi` macro
2022-05-12 Vinícius Rodrigues... Remove unneeded turbofishes
2022-05-12 Vinícius Rodrigues... Small code improvements
2022-05-11 Vinícius Rodrigues... Refactor `LinuxVersion`, ensure user is running on...
2022-05-11 Vinícius Rodrigues... Simplify implementation of `Uname::parse_version`
2022-05-11 Vinícius Rodrigues... impl Display for LinuxVersion
2022-05-11 Vinícius Rodrigues... Improve docs, add simple tests for `str_from_u8`
2022-02-28 Vinícius MiguelREADME: add Packaging section
2022-02-24 Vinícius Rodrigues... Add description and categories to Cargo.toml
...
tags
2 years ago v0.1.1
heads
5 months ago master
2 years ago ignore-glob
2 years ago mem-eater
2 years ago psi