bustd: Available memory or bust!

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

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:

¹: 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:

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

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

  • 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
  • Notification sending and general notification customization settings
Issues

Collection of the latest Issues

mmstick

mmstick

1

Should this be achieved by making this service a DBus service offering signals that a user session service can watch and give notify-rust notifications with?

sigmaSd

sigmaSd

4

Is it a good idea to make https://github.com/vrmiguel/bustd/blob/22470c4b351527ff75e0c4e71a55f0c675a21614/src/monitor.rs#L64 configurable ?

I personally have a pc that's very constrained on resource so I'm using bustd with that setting changed to 5, or else the killing of process happens earlier that I want. But my pc is old so I don't know how frequent this use-case is.

One obvious problem of making it configurable , is if the user sets a value like 100% it might theoretically kill all his session? maybe there should a be an acceptable range.

Versions

Find the latest versions by id

Information - Updated Jun 20, 2022

Stars: 165
Forks: 8
Issues: 4

Repositories & Extras

pancurses is a curses library for Rust that supports both Linux and Windows

by abstracting away the backend that it uses

pancurses is a curses library for Rust that supports both Linux and Windows

Native Rust library for managing Linux Control Groups (cgroups)

This crate, curently, only supports the original, V1 hierarchy

Native Rust library for managing Linux Control Groups (cgroups)

The Rust spidev seeks to provide full access to the Linux spidev

The following is not an exhaustive demonstration of the Spidev

The Rust spidev seeks to provide full access to the Linux spidev

a minimal Linux kernel module written in rust

A recent build of Rust (latest nightly)

a minimal Linux kernel module written in rust

Rust Linux Worker

The Service executes arbitrary Linux commands on behalf of clients

Rust Linux Worker

Direct, unsafe Rust bindings for Linux's perf_event_open system call

This crate exports unsafe Rust wrappers for Linux system calls for accessing

Direct, unsafe Rust bindings for Linux's perf_event_open system call

A safe, sane Rust interface to libseccomp on Linux

Note: This is not a high-level interface; most functions/methods in this library directly correspond to a libseccomp function

A safe, sane Rust interface to libseccomp on Linux

A transparent TCP to SOCKSv5/HTTP proxy on Linux written in Rust

Transparent TCP proxy with iptables -j REDIRECT or nft redirect to

A transparent TCP to SOCKSv5/HTTP proxy on Linux written in Rust

Linux-Device-Driver-Rust

This is a twain Repo of Linux-Device-Driver is a long time work in which I rewrite all examples in

Linux-Device-Driver-Rust

Simple, performant hot-reloading for Rust

Requires Rust nightly and only works on Linux and Windows for now

Simple, performant hot-reloading for Rust
Facebook Instagram Twitter GitHub Dribbble
Privacy