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 π«Άπ
π¦ where this page comes from
- debian bookworm: bpfcc-tools 0.26.0+ds-1 Β· Apache-2.0
- debian trixie: bpfcc-tools 0.31.0+ds-7 Β· Apache-2.0
- ubuntu jammy: bpfcc-tools 0.18.0+ds-2 Β· Apache-2.0
- ubuntu noble: bpfcc-tools 0.29.1+ds-1ubuntu7 Β· Apache-2.0
- ubuntu questing: bpfcc-tools 0.31.0+ds-7ubuntu2 Β· Apache-2.0
- ubuntu resolute: bpfcc-tools 0.35.0+ds-1ubuntu2 Β· Apache-2.0
- ubuntu stonking: bpfcc-tools 0.35.0+ds-1ubuntu4 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms