cachestat(8)

πŸ“¦
version 0.36.1 Β· 2 versions
, in centos-stream 10, centos-stream 9

πŸ’– cachestat(8) β€” the page cache vibe check πŸ’–

Okay bestie, so this is cachestat, from the Linux System Manager's Manual. It's a little eBPF/bcc tool that tells you how your Linux page cache is doing β€” hits, misses, the whole situation. Think of it as a wellness check for your memory, and you're the one holding the clipboard. πŸŽ€


✨ NAME ✨

cachestat β€” statistics for linux page cache hit/miss ratios. Uses Linux eBPF/bcc. That's the whole identity, no cap.


🌸 SYNOPSIS 🌸

cachestat [-T] [interval [count]]

Short, sweet, iconique.


πŸ’… DESCRIPTION πŸ’…

So what it actually does: it traces four kernel functions and prints per-second summaries. Very demure, very mindful. It's genuinely useful for general workload characterization, and for spotting patterns in operation usage over time. Like, what is your system actually doing all day? This tells you. πŸ”₯

How does it do it? By tracing kernel page cache functions using dynamic tracing β€” which is the important bit β€” and it will need updating to match any changes to these functions. So if the kernel moves, the script breaks, and you're the one fixing it. Edit the script to customize which functions are traced. You have the power. πŸ‘‘

And because this uses BPF, only the root user can use this tool. Sorry to the non-root girlies, this one's not for you. 😭


🧚 REQUIREMENTS 🧚

  • CONFIG_BPF
  • bcc

Both of them. Non-negotiable, bestie.


πŸ¦‹ EXAMPLES πŸ¦‹

Print summaries every second:

# cachestat

Print summaries every second with timestamp:

# cachestat -T

Print output every five seconds, three times:

# cachestat 5 3

Print output with timestamp every five seconds, three times:

# cachestat -T 5 3

See the pattern? It's giving learn the flags once, use them forever. πŸ’œ


⭐ FIELDS ⭐

This is the part where you learn what all the little words mean. Pay attention, this is the good part. πŸ“

  • TIME β€” Timestamp. Literally just what time it is.
  • HITS β€” Number of page cache hits. The wins. 🌈
  • MISSES β€” Number of page cache misses. The L's. πŸ’€
  • DIRTIES β€” Number of dirty pages added to the page cache.
  • HITRATIO β€” The hit ratio as a percentage. The main character number, honestly.
  • 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 β€” Cached amount of data in current page cache taken from /proc/meminfo.

πŸ”₯ OVERHEAD πŸ”₯

Okay so, real talk. This traces various kernel page cache functions and maintains in-kernel counts, which are asynchronously copied to user-space. While the rate of operations can be very high (>1G/sec), we can have up to 34% overhead. Bestie. 34%. That's a lot of overhead. 😭

But β€” it's still a relatively efficient way to trace these events, and so the overhead is expected to be small for normal workloads. Key words: normal workloads. Measure in a test environment. Please. For me. πŸ™ˆ


🫢 SOURCE 🫢

This is from bcc.

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. It's like bonus content, and we love bonus content. ✨


πŸ’– OS πŸ’–

Linux. Obviously. πŸ’…


πŸ‘‘ STABILITY πŸ‘‘

Unstable β€” in development. She's still growing, she's still figuring herself out, and honestly? Same. πŸ¦‹


🌸 AUTHOR 🌸

Allan McAleavy β€” the icon who made this happen. Respect. 🫑


πŸŽ€ SEE ALSO πŸŽ€

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

Heads up bestie: this is a USER COMMANDS page from 2016-01-30, so if something looks ancient, that's because it is. Still slays though. πŸ’œ

That's the whole page, periodt. Go forth and check your cache. πŸ’…βœ¨

πŸ“¦ where this page comes from