threadsnoop.bt(8)
๐ threadsnoop.bt(8) ๐
โจ NAME โจ
threadsnoop.bt is the tool that spills the tea on thread creation via pthread_create() ๐
It's built on bpftrace/eBPF ๐
๐ฎ SYNOPSIS ๐ฎ
threadsnoop.bt
๐ DESCRIPTION ๐
okay so threadsnoop traces calls to pthread_create() and shows you the path of thread creation ๐งต It's giving workload characterization and discovery vibes, and it's the bestie of execsnoop.bt(8), which traces execve(2) ๐ซถ
This works by tracing pthread_create() from libpthread.so.0. Heads up ๐ the path to this library might need adjusting in the tool source so it matches your system.
๐ Since this uses BPF, only the root user can run this tool. No sneaking around, bestie.
๐ REQUIREMENTS ๐
You need CONFIG_BPF and bpftrace. No cap, those are the whole checklist โจ
๐งช EXAMPLES ๐งช
Trace calls to pthread_create():
# threadsnoop.bt
๐ท๏ธ FIELDS ๐ท๏ธ
โฐ TIME(ms)
The elapsed time since the tool started tracing, in milliseconds โฑ๏ธ
๐ PID
The process ID ๐ชช
๐งต COMM
The process (thread) name ๐
๐ฏ FUNC
The name of the start routine, if the symbol is available ๐ If it isn't, you get a hex address for the start routine address instead ๐ง
๐ฟ OVERHEAD ๐ฟ
Thread creation is expected to be low (<< 1000/s), so the overhead of this tool is expected to be negligible ๐ Lowkey the chillest tool ever.
๐ SOURCE ๐
This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019) ๐ Check it out here: http://www.brendangregg.com/bpf-performance-tools-book.html
See the book for more documentation on this tool ๐ค
This version lives in the bpftrace repository: https://github.com/bpftrace/bpftrace ๐
Also look in the bpftrace distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool, so it's basically a cheat sheet ๐
๐ป OS ๐ป
Linux ๐ง
๐ง STABILITY ๐ง
Unstable - in development. It's still cooking, so don't be shocked if things shift ๐ณ
๐ฉโ๐ป AUTHOR ๐ฉโ๐ป
Brendan Gregg ๐
๐ SEE ALSO ๐
execsnoop.bt(8) ๐ฆ
Sign-off: this page is from the USER COMMANDS section and was last updated 2019-07-02, and threadsnoop.bt(8) is still slaying ๐
๐
๐ฆ where this page comes from
- alpine 3.24: bpftrace-tools-doc 0.26.1-r0 ยท Apache-2.0
- arch rolling: bpftrace 0.27.0-2 ยท Apache-2.0
- centos-stream 10: bpftrace 0.26.1-1.el10 ยท Apache-2.0
- centos-stream 9: bpftrace 0.26.1-1.el9 ยท ASL 2.0
- debian trixie: bpftrace 0.23.2-1 ยท Apache-2.0
- fedora 43: bpftrace 0.24.0-1.fc43 ยท Apache-2.0
- fedora 43: bpftrace 0.24.2-1.fc43 ยท Apache-2.0
- fedora 44: bpftrace 0.24.2-3.fc44 ยท Apache-2.0
- nixos 26.05: bpftrace 0.25.1
- nixpkgs unstable: bpftrace 0.27.1
- opensuse-leap 16.0: bpftrace-tools 0.23.5-160000.1.2 ยท Apache-2.0
- ubuntu questing: bpftrace 0.23.5-1ubuntu1 ยท Apache-2.0
- ubuntu resolute: bpftrace 0.25.0-1ubuntu1 ยท Apache-2.0
- ubuntu stonking: bpftrace 0.25.0-1ubuntu2 ยท Apache-2.0
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms