threadsnoop.bt(8)

๐Ÿ“ฆ
version 0.27.0 ยท 3 versions
  • 0.27.0 ยท alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.14.0 ยท ubuntu jammy
  • 0.20.2 ยท ubuntu noble
, in alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

๐ŸŽ€ 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 ๐Ÿ’…๐ŸŒˆ