![](/style/images/good.png)
![](/style/images/bad.png)
GitHub - vrmiguel/bustd: Process killer daemon for out-of-memory scenarios
source link: https://github.com/vrmiguel/bustd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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.
Building
Requirements:
- Rust toolchain
- Any C compiler
- Linux 4.20+ built with
CONFIG_PSI=y
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
- Allow for customization of the critical scenario (PSI cutoff)
- Command-line argument for disabling daemonization (useful for runnning
bustd
as a systemd service) - Command-line argument to enable killing the entire process group, not just the chosen process itself
- Allow the user to setup a list of software that
bustd
should never kill- In progress! A list of glob patterns of processes that
bustd
will not kill. - Example:
firefox | systemd-* | rustc
- In progress! A list of glob patterns of processes that
- Notification sending and general notification customization settings
Recommend
-
249
README OpenVPN -- A Secure tunneling daemon...
-
213
phpcd - PHP Completion Daemon Plugin for Vim/NeoVim
-
58
In a Linux world, whenever your database server crashes or gets terminated, you need to find its cause. There can be several reasons for this....
-
12
Non-uniform memory access meets the OOM killer Do you have machines with NUMA? That's non-uniform memory access, meaning that depending on which CPU your code is on, it might be faster to some bits of your RAM and slower to other...
-
3
Introduction(P2P – Process) In this document, I would like to explain the different scenarios in the procurement process. The procurement process starts from purchase requisition and ends with payment to the vendor. Hence this proces...
-
3
Interactive process killer for Linux and macOSAre you tired of running kill and pkill Linux commands every time you need to terminate a running Linux/macOS process?. Here I’ll introduce you to top interactive...
-
2
Andrej’s notes Yesterday I played with LXC a bit, and I liked it, as LXC provides a very lightweight isolation of processes, much like enchanced chroot. Howeve...
-
9
Sabine Stellmacher May 19, 2022 2 minute re...
-
5
This article describes the Linux out-of-memory (OOM) killer and how to find out why it killed a particular process. It also provides methods for configuring the OOM killer to better suit the needs of many different environments.
-
4
Out Of Memory (OOM) Killer to save your SSD and other processes. · GitHub Instantly share code, notes, and snippets. Out O...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK