• Stars
    star
    202
  • Rank 193,691 (Top 4 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Process killer daemon for out-of-memory scenarios

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

  • 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

More Repositories

1

kindly

kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.
Rust
26
star
2

to-trash

fast, small and easy file trasher for *nix
Rust
24
star
3

buztd

lightweight and configurable process killer daemon for out-of-memory scenarios
Zig
23
star
4

unixstring

An FFI-friendly null-terminated byte string
Rust
21
star
5

taruga

Taruga is a work in progress single-header turtle graphics library written in C++11
C++
20
star
6

endless-trial

Bullet-hell-like 2D game
Rust
12
star
7

jacarex-old

(WIP) Interactive Regex tutorial and playground
Rust
11
star
8

sm64-analog-camera

Allows for analog camera control on Super Mario 64.
C
10
star
9

negate

Attribute macro that generates negated versions of`is_something` functions
Rust
9
star
10

ceceio

Embeddable tree-walk interpreter for a "mostly lazy" Lisp-like scripting language.
Rust
7
star
11

eggshells

Hobby Unix shells written in C++11, C99 and Rust.
6
star
12

lasercrab

Simple CPU-based raytracer in Rust
Rust
5
star
13

water

[Early WIP] A tiny and performant WebAssembly Text Format compiler
Rust
5
star
14

porquinho

Simplistic personal finances system
Rust
4
star
15

baleia

Command-line tool (and Telegram bot) to retrieve data about Raspberry Pis with implementations in C++11 and Go.
C++
4
star
16

slicedisplay

Simplistic Display implementation for Vecs and slices
Rust
3
star
17

say

Say gives the name of a number by grouping. E.g. 134 = "one hundred thirty four"
C++
3
star
18

repo-badger

Rust
3
star
19

steambot

A Telegram bot for browsing the Steam API
Rust
3
star
20

paradigm-shift-jekyll-theme

Jekyll version of Paradigm Shift by ajlkn/HTML5 UP.
CSS
3
star
21

theMatlabPlanimeter

Approximates a given area on an image with MATLAB.
MATLAB
3
star
22

bagel

Donut-like Slack bot for team integration
Rust
2
star
23

macabot

Rust
2
star
24

jacarex

Rust
2
star
25

gari

Rust
2
star
26

SimpleCalculusModule

A series of univariate calculus and polynomial-related functions.
Python
2
star
27

gravel

Rust
2
star
28

pgtemp

Manage temporary Postgres databases
Rust
2
star
29

sedboy

sed-like Telegram bot
Rust
2
star
30

inquire

Rust
2
star
31

incipio

Yet another small init system
Rust
2
star
32

desafio-letras

Rust
2
star
33

dodo-old

A to-do list application for your terminal
Rust
2
star
34

lipid

Find ports being listened to
Rust
1
star
35

orderbook

Rust
1
star
36

guana

guana is the gRPC User-Agent analyzer
Rust
1
star
37

battery-alert

Rust
1
star
38

particeps

Go
1
star
39

tokio-tutorial

Rust
1
star
40

Bool2NAND

Converts any given ternary boolean operation into a NAND-only form
Python
1
star
41

vrmiguel

1
star
42

pushy

A Vec-like stack-allocated buffer
Rust
1
star
43

to-trash-old

tt (To Trash) is being rewritten
Rust
1
star
44

tson

Parser for "typed" JSON
Rust
1
star
45

zish

Simplistic Unix shell in Zig
Zig
1
star
46

bomdiabot

Rust
1
star
47

ese

A lightweight dotenv-reading command runner
Rust
1
star
48

scheda

Rust
1
star
49

cargo-switch

Allows installing several versions of the same Cargo binary crate and switching between them easily
Rust
1
star
50

foobarbaz

Rust
1
star
51

fp-exercises

Haskell
1
star
52

anansi

[wip] Fast event-driven communication for Unix scripts
Rust
1
star
53

k-render

Simple C++11 software renderer.
C++
1
star
54

carcer

World's favorite `car/cdr` composition desugarer
Rust
1
star
55

rsh

Unix shell written in Rust.
Rust
1
star
56

miniShell

Implementation of a basic Unix shell written in C.
C
1
star
57

rol-baseado

Rust
1
star