The Wayback Machine - https://web.archive.org/web/20240226070630/https://www.geeksforgeeks.org/see-cache-statistics-linux/
Open In App
Related Articles

How to see cache statistics in Linux?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
Cache is a very important part of the computer hardware to give superfast response time. Cache Performance When the processor needs to read or write a location in main memory, it first checks for a corresponding entry in the cache. If the processor finds that the memory location is in the cache, a cache hit has occurred and data is read from cache If the processor does not find the memory location in the cache, a cache miss has occurred. For a cache miss, the cache allocates a new entry and copies in data from main memory, then the request is fulfilled from the contents of the cache. The performance of cache memory is frequently measured in terms of a quantity called Hit ratio.
Hit ratio = hit / (hit + miss) =  no. of hits/total accesses
To monitor the performance of your cache, linux provides some excellent library: Cachestat. Cachestat is not directly available, it is deprecated by linux. Cachestat uses the perf tools, which is a part of linux-tools library. To install perf-tools, open terminal and run:
sudo apt-get install linux-tools-common linux-tools-generic
Then, to install cachestat, run:
wget https://raw.githubusercontent.com/brendangregg/perf-tools/master/fs/cachestat
To make it executable, run:
chmod +x cachestat
Finally run it:
sudo ./cachestat
If you get a lot of misses, you should probably run diagnostics.

Last Updated : 31 Jan, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads