This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Features:
Small memory usage
bustd
seems to use less memory than other lean process killers, 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/
Check the README.md for more info on this comparison!
Small CPU usage
bustd
uses adaptive sync times between each of its memory polls and at every memory poll, checks the system memory status through the sysinfo
syscall.
Other process killers usually read and parse from /proc/meminfo
, which is believed to be at least an order of magnitude slower than the sysinfo
syscall (source).
As sysinfo
doesn't have sufficiently accurate free system memory metrics, we use pressure stall information to know precisely when the system is out of memory and prone to thrashing. More on this later.
Able to lock its memory pages
bustd
uses mlockall
to lock all pages mapped into its address space.
This allows bustd
to not have its memory sent to swap so as to remain responsive during scenarios of stressed memory.
In order to fully commit to this concept, bustd
constantly reuses two buffers that amount to 150 bytes throughout its entire main loop, avoiding any new heap allocations whatsoever.
Checks for Pressure Stall Information (PSI)
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, but this is adjustable through command-line options.
It's worth noting that, for performance reasons, the PSI figures are only checked when the sysinfo
reading of free system memory are sufficiently low (15% memory left, currently).
Objective
bustd
doesn't particularly aim to replace or be better than any other OOM killer out there. I'm making this project as a hobby to delve deeper into how OOM killers work and how Linux deals with this sort of thing in general.
Suggestions?
As this is quite a recent work in progress, I'm eager to know if anyone has suggestions for any features it should implement!
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/rust/commen...