naptime.bt(8)

πŸ“¦ version 0.17.0, in debian bookworm

πŸ’€ naptime.bt β€” from the System Manager's Manual, section 8 πŸŽ€

okay bestie, picture this: it's naptime.bt and it is literally the sleep detective of your system. ✨


🌸 NAME 🌸

naptime.bt β€” trace voluntary sleep calls. πŸ›Œ Uses bpftrace/eBPF, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

naptime.bt

that's it. that's the whole thing. she takes no arguments and she does not need them. πŸ’…


✨ DESCRIPTION ✨

so this tool traces application sleeps, right? like, it's the girl who catches your code taking a lil nap when it should be working. super useful for debugging high latency that might be caused by deliberate sleeps tucked into your application routines β€” especially admin scripts, because we all know those scripts love a good snooze. 😴

the way it works? it traces the nanosleep(2) syscall using the syscall tracepoints. tracing the syscall, tracing the nap. iconic behavior honestly. πŸ”₯

πŸ’€ heads up bestie: since this uses BPF, only the root user can use this tool. root only. no exceptions, no workarounds, that's the vibe.

🧚 REQUIREMENTS 🧚

  • CONFIG_BPF
  • bpftrace

both of them. together. it's giving power couple. πŸ’–


🌈 EXAMPLES 🌈

Trace application sleeps via nanosleep(2):

# naptime.bt

that's the whole incantation. run it as root, watch the naps roll in. πŸ“


πŸ‘‘ FIELDS πŸ‘‘

okay so when the output comes through, here's what each column is serving you:

  • TIME β€” a timestamp in HH:MM:SS format. clock in, bestie. ⏰
  • PPID β€” parent process ID. the mom, essentially.
  • PCOMM β€” parent process name.
  • PID β€” the sleeping process ID. the actual napper. 😴
  • COMM β€” the sleeping process name.
  • SECONDS β€” the requested duration of the sleep. how long the nap was supposed to last. πŸ›Œ

πŸ’œ OVERHEAD πŸ’œ

nanosleep(2) calls are expected to be low frequency (<< 100/s), so the overhead of this tool is expected to be negligible. she's lightweight, she's polite, she does not eat your CPU. we love a low-maintenance icon. ✨


πŸ“š 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. πŸ“–

this version is 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. πŸŽ€


🐧 OS 🐧

Linux. obviously. πŸ’…


⚠️ STABILITY ⚠️

Unstable - in development. so like, she's growing, she's evolving, she's in her development era. treat her with love and maybe don't put her in production-critical vibes without knowing that. πŸ¦‹


πŸ’– AUTHOR πŸ’–

Brendan Gregg πŸ‘‘


🫢 SEE ALSO 🫢


and that's the whole page, bestie!! πŸŽ‰ this came out under the USER COMMANDS section of the manual, dated 2019-07-05, and it's page naptime.bt(8). go trace some sleeps, slay, and remember: naps are valid, but latency is not. πŸ’€πŸ’–βœ¨

πŸ“¦ where this page comes from