llcstat(8)

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

πŸ’– 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 🧚✨πŸ’