Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you tell whether a file is being cached in memory in linux?

Essentially my question is, does anyone know of a utility for inspecting the buffer cache in linux?

like image 923
convex hull Avatar asked Oct 17 '08 01:10

convex hull


2 Answers

Take a look at linux-ftools. This suite of tools is specifically designed to analyze the buffers and cache. It includes the following tools:

  • fincore
  • fadvise
  • fallocate

Of these 3 tools the one that will show you the list of files in the buffers & cache is fincore.

$ fincore [options] files...

  --pages=false      Do not print pages
  --summarize        When comparing multiple files, print a summary report
  --only-cached      Only print stats for files that are actually in cache.

root@xxxxxx:/var/lib/mysql/blogindex# fincore --pages=false --summarize --only-cached * 
stats for CLUSTER_LOG_2010_05_21.MYI: file size=93840384 , total pages=22910 , cached pages=1 , cached size=4096, cached perc=0.004365 
stats for CLUSTER_LOG_2010_05_22.MYI: file size=417792 , total pages=102 , cached pages=1 , cached size=4096, cached perc=0.980392 
stats for CLUSTER_LOG_2010_05_23.MYI: file size=826368 , total pages=201 , cached pages=1 , cached size=4096, cached perc=0.497512 
stats for CLUSTER_LOG_2010_05_24.MYI: file size=192512 , total pages=47 , cached pages=1 , cached size=4096, cached perc=2.127660 
...
like image 142
slm Avatar answered Oct 27 '22 15:10

slm


I'm not entirely sure if you're asking what I think you're asking, but vmtouch could be helpful to you. Just type vmtouch [file or folder you want to check for presence in cache]

like image 2
Highstaker Avatar answered Oct 27 '22 15:10

Highstaker