cachestat(8)

πŸ’– NAME πŸ’–

okay so meet cachestat πŸ¦‹, the tool that tracks Linux page cache hit/miss ratios. It's built on eBPF/bcc, so it's lowkey a whole vibe. ✨

🌸 SYNOPSIS 🌸

cachestat [-T] [interval [count]]

✨ DESCRIPTION ✨

bestie, this one traces four kernel functions and prints per-second summaries πŸ“Š. It's super useful for general workload characterization, and for spotting patterns in how operations get used over time. main character energy, honestly πŸ‘‘

okay so here's the tea πŸ«–: it works by tracing kernel page cache functions with dynamic tracing. That means it'll need updating if those functions ever change. If you want to customize which functions get traced, just edit the script πŸ’…

⚠️ Since this uses BPF, only the root user can use this tool. no cap, don't be mad at me πŸ™ˆ

πŸŽ€ REQUIREMENTS πŸŽ€

You'll need CONFIG_BPF and bcc. 🧚

πŸ“ EXAMPLES πŸ“

Print summaries every second πŸ•:

# cachestat

Print summaries every second with a timestamp ⏰:

# cachestat -T

Print output every five seconds, three times 🌈:

# cachestat 5 3

Print output with a timestamp every five seconds, three times πŸ’œ:

# cachestat -T 5 3

πŸ“š FIELDS πŸ“š

  • TIME β€” the timestamp ⏰
  • HITS β€” number of page cache hits 🎯
  • MISSES β€” number of page cache misses πŸ™ƒ
  • DIRTIES β€” number of dirty pages added to the page cache 🧹
  • HITRATIO β€” the hit ratio, as a percentage πŸ’―
  • READ_HIT% β€” read hit percent of page cache usage πŸ“–
  • WRITE_HIT% β€” write hit percent of page cache usage ✍️
  • BUFFERS_MB β€” buffers size, taken from /proc/meminfo πŸ§ƒ
  • CACHED_MB β€” amount of data currently in the page cache, taken from /proc/meminfo πŸ—‚οΈ

πŸ”₯ OVERHEAD πŸ”₯

ngl this part is a little dramatic 😭. It traces various kernel page cache functions and keeps in-kernel counts, which get asynchronously copied to user-space. The rate of operations can be very high (>1G/sec), and we can have up to 34% overhead. Still, it's a relatively efficient way to trace these events, so the overhead is expected to be small for normal workloads ✨.

πŸ§ͺ Measure in a test environment before you go wild on production, bestie.

🌈 SOURCE 🌈

This one comes 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 πŸ“.

πŸ’» OS πŸ’»

Linux 🐧

πŸ§ͺ STABILITY πŸ§ͺ

Unstable, it's still in development 🚧.

🫢 AUTHOR 🫢

Allan McAleavy πŸ’–

πŸ¦‹ SEE ALSO πŸ¦‹

https://github.com/brendangregg/perf-tools/blob/master/fs/cachestat

That's the whole tea, bestie 🍡✨ this page is from User Commands dated 2016-01-30, and it's all about cachestat(8) πŸ’œ stay curious and keep tracing 🫢πŸ’