llcstat(8)
π llcstat(8) β¨ NAME β¨
okay so llcstat is the tool that summarizes CPU cache references and cache misses by process π§. it's Linux eBPF/bcc based, so it's giving low-level and iconic π
π SYNOPSIS π
llcstat [-h] [-c SAMPLE_PERIOD] [duration]
πΈ DESCRIPTION πΈ
bestie, so llcstat instruments CPU cache references and cache misses on the system side π and summarizes them by PID and CPU. these events mean different things on different architectures. on x86-64, they mean misses and references to LLC π¦. this is lowkey super useful for finding and debugging performance issues caused by a bad cache hit rate ππ₯
here's how it works: it samples the matching events defined in uapi/linux/perf_event.h, namely PERF_COUNT_HW_CACHE_REFERENCES and PERF_COUNT_HW_CACHE_MISSES, using BPF perf event tracing β¨. every time an event gets sampled, the attached BPF program records the PID and the CPU ID where it happened, then stores it in table. main character energy π
this makes use of a Linux 4.9 feature (BPF_PROG_TYPE_PERF_EVENT) π
β οΈ since this uses BPF, only the root user can use this tool π no cap, sudo or bust.
π§ REQUIREMENTS π§
you'll need CONFIG_BPF and bcc π
β¨ OPTIONS β¨
-hβ pulls up the usage message π-c SAMPLE_PERIODβ samples one in this many cache reference and cache miss events π―-tβ summarizes cache references and misses by PID/TID π- duration β how long to trace, in seconds β±οΈ
π EXAMPLES π
bestie wants 1 in 100 events, traced for 20 seconds? it's giving:
# llcstat -c 100 20
π¦ FIELDS π¦
PIDβ process ID πͺͺNAMEβ process name π«ΆCPUβ CPU ID π₯οΈREFERENCEβ number of cache reference events πMISSβ number of cache miss events πHIT%β cache hit ratio π₯
π SOURCE π
this is from bcc π
https://github.com/iovisor/bcc
also look in the bcc distribution for a companion _examples.txt file. it has example usage, output, and commentary for this tool, so it's a must-read πβ¨
π· OS π·
Linux π§
π₯Ί STABILITY π₯Ί
Unstable β still in development π§ so vibe check before you rely on it for anything important π
π AUTHOR π
Teng Qin π©βπ»π«Ά
π¦ SEE ALSO π¦
perf can be used as a generic event counter tool too π an example for LLC:
# perf top -e cache-misses -e cache-references -a -ns
pid,cpu,comm
bestie that's the whole tea βπ this page is from the USER COMMANDS section, dated 2015-08-18, and it's all about llcstat(8) π stay cute, stay curious, and go catch those cache misses π§β¨π
π¦ 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