如何判断linux中是否缓存了一个文件?

时间:2021-01-03 16:42:20

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

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

2 个解决方案

#1


9  

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

看看linux-ftools。这套工具是专门设计来分析缓冲区和缓存的。它包括以下工具:

  • fincore
  • fincore
  • fadvise
  • fadvise
  • fallocate
  • fallocate

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

在这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 
...

#2


0  

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]

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

#1


9  

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

看看linux-ftools。这套工具是专门设计来分析缓冲区和缓存的。它包括以下工具:

  • fincore
  • fincore
  • fadvise
  • fadvise
  • fallocate
  • fallocate

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

在这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 
...

#2


0  

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]

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