cpudist(8)

πŸ“¦ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

✨ cpudist(8) ✨

System Manager's Manual πŸ’…

🌸 NAME 🌸

cpudist β€” on- and off-CPU task time, served as a histogram πŸ“Š

πŸŽ€ SYNOPSIS πŸŽ€

cpudist [-h] [-O] [-T] [-m] [-P] [-L] [-p PID] [-I] [-e] [interval]
[count]

πŸ’– DESCRIPTION πŸ’–

okay so this bad boy measures how long a task stays on the CPU before it gets descheduled, then shows you the times as a histogram πŸ“Š tasks that only last a super short time on the CPU can be a sign of excessive context-switches and poor workload distribution 😭 it might even point to a shared source of contention that keeps tasks switching in and out as stuff becomes available, like a mutex πŸ”’

it can also measure how long a task spends off-CPU before it gets scheduled again ✨ this is lowkey so helpful for spotting long blocking and I/O operations, or on the flip side, super short descheduling times caused by short-lived locks or timers 🧚

by default CPU idle time is excluded, and it's giving simple: it just excludes PID 0 πŸ™ˆ

this tool uses in-kernel eBPF maps to store the timestamps and the histogram, which is very efficient πŸ¦‹ but ngl the overhead can get significant for some workloads, so check out the OVERHEAD section πŸ‘€

⚠️ since this runs on BPF, only the root user can use this tool. no cap, it's root-only πŸ‘‘

🌈 REQUIREMENTS 🌈

CONFIG_BPF and bcc. ✨

πŸ¦‹ OPTIONS πŸ¦‹

  • -h β€” pull up the usage message πŸ“–
  • -O β€” measure off-CPU time instead of on-CPU time πŸŒ™
  • -T β€” slap timestamps onto the output ⏰
  • -m β€” show the histogram in milliseconds instead πŸ“
  • -P β€” get a histogram for each PID (tgid from the kernel's perspective) 🧚
  • -L β€” get a histogram for each TID (pid from the kernel's perspective) πŸ’œ
  • -p PID β€” only show this PID (filtered in kernel, so it's efficient) 🎯
  • -I β€” include CPU idle time (by default these get excluded) β˜•
  • -e β€” show the extension summary (average/total/count) πŸ“ˆ
  • interval β€” how many seconds between outputs ⏳
  • count β€” how many outputs you want πŸ”’

πŸ“ EXAMPLES πŸ“

Summarize task on-CPU time as a histogram:

# cpudist

Summarize task off-CPU time as a histogram:

# cpudist -O

Print 1 second summaries, 10 times:

# cpudist 1 10

Print 1 second summaries, using milliseconds as units for the histogram, and include timestamps on output:

# cpudist -mT 1

Trace PID 185 only, 1 second summaries:

# cpudist -p 185 1

Include CPU idle time:

# cpudist -I

Also show extension summary:

# cpudist -e

🫢 FIELDS 🫢

  • usecs β€” the microsecond range πŸ•
  • msecs β€” the millisecond range ⏱️
  • count β€” how many times a task event landed in this range 🎯
  • distribution β€” an ASCII bar chart showing the distribution (count column) πŸ“Š

πŸ”₯ OVERHEAD πŸ”₯

this traces scheduler tracepoints, and those can get super frequent 😭 eBPF has very low overhead and this tool uses in-kernel maps to stay efficient, but for some workloads the scheduler events can be frequent enough that the overhead becomes significant πŸ’€ measure it in a lab environment to quantify the overhead before you use it in the wild πŸ§ͺ

🌷 SOURCE 🌷

this is from bcc πŸ’–

https://github.com/iovisor/bcc

also look in the bcc distribution for a companion _example.txt file with example usage, output, and commentary for this tool πŸ“š

πŸŒ™ OS πŸŒ™

Linux 🐧

⭐ STABILITY ⭐

Unstable - in development. 🚧

πŸ‘‘ AUTHOR πŸ‘‘

Sasha Goldshtein, Rocky Xing 🫢

πŸ¦‹ SEE ALSO πŸ¦‹

pidstat(1), runqlat(8) ✨


bestie, that's the whole tea πŸ«– this page was from the USER COMMANDS section, dated 2016-06-28, and it's all about cpudist(8) πŸŽ€πŸ’œ