Cache is a very important part of the computer hardware to give superfast response time.
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:
To make it executable, run:
chmod +x cachestat
Finally run it:
If you get a lot of misses, you should probably run diagnostics.
This article is contributed by Suprotik Dey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Initializing and Cache Mechanism in Linux Kernel
- fc-cache command in Linux with Examples
- Difference Between APT, APT-GET, APT-CACHE and APT-CONFIG
- Linux Virtualization : Linux Containers (lxc)
- Difference Between Arch Linux and Kali Linux
- How to find time taken by a command/program on Linux Shell?
- Terminal Mail and Linux Security Mail
- Linux Virtualization - Chroot Jail
- Linux Kernel Module Programming: Hello World Program
- Formatted text in Linux Terminal using Python
- Some useful Linux Hacks
- Daily life Linux Commands
- Basic Linux Commands for day to day life
- How to add "graphics.h" C/C++ library to gcc compiler in Linux
- Working with Magic numbers in Linux
- Reset a lost Linux administrative password and Explanation
- dup() and dup2() Linux system call
- Encrypt/Decrypt Files in Linux using Ccrypt
- Linux File Hierarchy Structure
- mindepth and maxdepth in Linux find() command for limiting search to a specific directory.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.