Linux-ToolKit-ftools
Linux command line tools for fallocate, fincore, fadvise, etc.These are tools designed for working with modern linux system calls including, fincore, fallocate, fadvise, etc. We designed these primarily to work in high performance environments to determine information about the running kernel, improve system performance, and debug performance problems.
该工具最初发布于googlecode,采用C语言开发,但googlecode现在已经关闭了。可以从github上找到其代码,本站选用的是david415所链接的版本,执行 ./configure; make; make install 可以直接编译安装。
可能会因为Makefile.in中写死了使用低版本的automake工具,导致了即使有高版本的编译软件也不能通过,可以通过以下步骤解决:
执行aclocal,产生aclocal.m4文件
执行autoconf,生成configure文件
执行automake命令,产生Makefile.in: automake --add-missing
执行configure命令,生成Makefile文件
重新执行make 和 make install,一切顺利
= fincore =
使用linux-fincore查看Linux系统缓存了哪些文件
fincore version 1.3.0
fincore [options] files...
-s --summarize When comparing multiple files, print a summary report
-p --pages Print pages that are cached
-o --only-cached Only print stats for files that are actually in cache.
-g --graph Print a visual graph of each file's cached page distribution.
-S --min-size Require that each files size be larger than N bytes.
-C --min-cached-size Require that each files cached size be larger than N bytes.
-P --min-perc-cached Require percentage of a file that must be cached.
-h --help Print this message.
-L --vertical Print the output of this script vertically.
通常用法:执行 linux-fincore --pages=false --summarize --only-cached * 即可,其中*代表查看任意文件的cache。也可以指定某个目录/*,表示该目录中的所有文件。或指定某个具体的文件。
在使用的过程中发现的一些问题,直接执行 linux-fincore --pages=false --summarize --only-cached * 有时并不能完全显示所有的缓存。比如构造一个32GB大小的文本文件file1.csv,然后wc -l file1.csv,执行完毕后通过free可以看到系统cache已经有30多GB了,但执行上述linux-fincore命令却找不到file1.csv的cache记录,但是直接指定file1.csv文件名或其目录的话,是可以看到具体的缓存信息的:
# ./linux-fincore --pages=false --summarize --only-cached /home/freeoa/file1.csv
= fadvise =
Allows an application to to tell the kernel how it expects to use a file handle,so that the kernel can choose appropriate read-ahead and caching techniques for access to the corresponding file. This is similar to the POSIX version of the madvise system call, but for file access instead of memory access. The sys_fadvise64() function is obsolete and corresponds to a broken glibc API,sys_fadvise64_64() is the fixed version.
= fallocate =
fallocate() allows the caller to directly manipulate the allocated disk space for the file referred to by fd for the byte range starting at offset and continuing for len bytes.