cachestat(8) | System Manager's Manual | cachestat(8) |
cachestat - Measure page cache hits/misses. Uses Linux ftrace.
cachestat [-Dht] [interval]
This tool provides basic cache hit/miss statistics for the Linux page cache.
Its current implementation uses Linux ftrace dynamic function profiling to create custom in-kernel counters, which is a workaround until such counters can be built-in to the kernel. Specifically, four kernel functions are counted:
It is possible that these functions have been renamed (or are different logically) for your kernel version, and this script will not work as-is. This was written for a Linux 3.13 kernel, and tested on a few others versions. This script is a sandcastle: the kernel may wash some away, and you'll need to rebuild.
This program's implementation can be improved in the future when other kernel capabilities are made available. If you need a more reliable tool now, then consider other tracing alternatives (eg, SystemTap). This tool is really a proof of concept to see what ftrace can currently do.
WARNING: This uses dynamic tracing of kernel functions, and could cause kernel panics or freezes. Test, and know what you are doing, before use. It also traces cache activity, which can be frequent, and cost some overhead. The statistics should be treated as best-effort: there may be some error margin depending on unusual workload types.
Since this uses ftrace, only the root user can use this tool.
CONFIG_FUNCTION_PROFILER, which you may already have enabled and available on recent kernels, and awk.
This tool currently uses ftrace function profiling, which provides efficient in-kernel counters. However, the functions profiled are executed frequently, so the overheads can add up. Test and measure before use. My own testing showed around a 2% loss in application performance while this tool was running.
This is from the perf-tools collection.
Also look under the examples directory for a text file containing example usage, output, and commentary for this tool.
Linux
Unstable - in development.
Brendan Gregg
2014-12-28 | USER COMMANDS |