In essence the Page Cache is a part of Virtual File System (VFS) which main purpose, as you can guess, is improving IO latency of read and write operations.
In computing, a page cache, sometimes also called disk cache, is a transparent cache for the pages originating from a secondary storage device such as a hard disk drive (HDD) or a solid-state drive (SSD).
The operating system keeps a page cache in otherwise unused portions of the main memory (RAM), resulting in quicker access to the contents of cached pages and overall performance improvements.
Based on the above, what are the tools that already exists in order to monitoring the page cache? I wish to monitor usage, hits, and especially the dirty pages.
OS version is RHEL 7.X.
In
/proc/meminfo
you have a number of memory parameters for the system. In particular, the relevant values should beCached:
(Memory used by the page cache) andDirty:
(not just those of the page cache)For a given process, you should look at
/proc/$PID/smaps
You can find more information about the different fields on https://www.kernel.org/doc/html/latest/filesystems/proc.html
A simpler solution would be to simply monitor the column
cache
offree -w
, which outputs the memory used by the page cache and slabs.For RedHat the company offer one solution (I do not have permission to copy it here).
If you are OK to compile and implement from source on your platform you can try one tool named cachestat which is intended to do exactly what you want. But it is for Ubuntu, so you need to build it.
You can use
cachestat
andcachetop
to show both global and by-process cache hit/miss ratio.You can easily install them in RHEL 7 by issuing
yum install bcc-tools
. Among the dependencies you will find thekernel-devel
packages, whose headers must match your currently running kernel. If the two tools abort with a message similar tomodprobe: FATAL: Module kheaders not found
, update your kernel and reboot.Here you can find other very useful performance tools.