swapin.bt(8)

πŸ“¦ version 0.17.0, in debian bookworm

πŸ’« swapin.bt(8) β€” the count-swapins-by-process baddie πŸ’«

okay bestie, so this is a page from the System Manager's Manual and it's all about swapin.bt, a lil bpftrace/eBPF tool that counts swapins by process. she's lowkey niche but highkey useful. let's get into it 🫢


✨ NAME ✨

swapin.bt β€” count swapins by process. Uses bpftrace/eBPF.


🌸 SYNOPSIS 🌸

swapin

that's it. that's the whole vibe. no flags, no drama πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she do? this tool counts swapins by process, which shows you which process is getting wrecked by swapping (if swap devices are even in use, that is). and ngl, that matters a lot, because if a process started swapping due to memory pressure on the system, that can explain a significant source of application latency. like, the "why is my app so slow" mystery? sometimes it's just this. 😭

the way it works is by tracing the swap_readpage() kernel function using dynamic instrumentation. real cute, real effective. but heads up: this tool may need maintenance to keep working if that function changes in later kernels. so if it breaks someday, that's why, no cap.

and since this uses BPF, only the root user can use this tool. root energy required, sorry bestie πŸ‘‘


πŸŽ€ REQUIREMENTS πŸŽ€

you're gonna need:

  • CONFIG_BPF
  • bpftrace

that's the whole guest list.


⭐ EXAMPLES ⭐

count swapins by process, showing per-second summaries:

# swapin.bt

obsessed. periodt.


πŸ’– FIELDS πŸ’–

three columns, three lil pieces of info, let's go:

  • 1st β€” the process name.
  • 2nd β€” the process ID.
  • 3rd β€” the count of swapins during that interval.

πŸ”₯ OVERHEAD πŸ”₯

good news: the rate of swapins should be low (it's bounded by swapin device IOPS), such that the overhead of this tool is expected to be negligible. so she's polite, she doesn't eat your CPU, she just vibes. ✨


🌈 SOURCE 🌈

this tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019):

http://www.brendangregg.com/bpf-performance-tools-book.html

see the book for more documentation on this tool, iykyk πŸ“š

this version lives in the bpftrace repository:

https://github.com/iovisor/bpftrace

also, look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. it's giving bonus content fr fr πŸ“


🧚 OS 🧚

Linux


πŸ’œ STABILITY πŸ’œ

Unstable β€” in development. she's a work in progress, and honestly? same.


πŸ‘‘ AUTHOR πŸ‘‘

Brendan Gregg


πŸ’€ SEE ALSO πŸ’€


and that's the whole page, bestie!! this one was from the USER COMMANDS section, dated 2019-07-05, and it goes by swapin.bt(8). thanks for reading my little manpage TED talk, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from