如何判断文件是否在linux的内存中缓存?

con*_*ull 11 linux memory caching file

基本上我的问题是,有没有人知道用于检查linux中的缓冲区缓存的实用程序?

slm*_*slm 9

看一下linux-ftools.这套工具专门用于分析缓冲区和缓存.它包括以下工具:

  • fincore
  • fadvise
  • fallocate

在这3个工具中,将向您显示缓冲区和缓存中的文件列表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 
...
Run Code Online (Sandbox Code Playgroud)