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

在linux中,如何判断文件是否缓存在内存中?,linux,file,memory,caching,Linux,File,Memory,Caching,本质上,我的问题是,有人知道在linux中检查缓冲区缓存的实用程序吗?。这套工具是专门为分析缓冲区和缓存而设计的。它包括以下工具: 芬科 发夹 休闲 在这三种工具中,显示缓冲区和缓存中文件列表的工具是fincore $ fincore [options] files... --pages=false Do not print pages --summarize When comparing multiple files, print a summary re

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

。这套工具是专门为分析缓冲区和缓存而设计的。它包括以下工具:

  • 芬科
  • 发夹
  • 休闲
在这三种工具中,显示缓冲区和缓存中文件列表的工具是
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 
...

我不完全确定你是否在问我认为你在问的问题,但可能会对你有所帮助。只需键入
vmtouch[要检查缓存中是否存在的文件或文件夹]

不幸的是,默认情况下,这些工具在大多数linux发行版中都不可用(我检查了Ubuntu和SuSE,我手头没有redhat)。linux内核不缓存文件,而是缓存块。一个文件可能由许多块组成,其中一些块可能被缓存,而另一些块可能不被缓存。你到底想完成什么?