cpudist(8)
β¨ 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) ππ
π¦ where this page comes from
- alpine 3.24: bcc-doc 0.36.1-r1 Β· Apache-2.0
- nixpkgs unstable: bcc 0.37.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms