安装 Vmtouch
- $ git clone https://github.com/hoytech/vmtouch
- $ cd vmtouch
- $ make
- $ sudo make install
使用 Vmtouch
- vmtouch 命令语法
- $ vmtouch
- vmtouch: no files or directories specified
- vmtouch v1.0.2 - the Virtual Memory Toucher by Doug Hoyte
- Portable file system cache diagnostics and control
- Usage: vmtouch [OPTIONS] ... FILES OR DIRECTORIES ...
- Options:
- -t touch pages into memory
- -e evict pages from memory
- -l lock pages in physical memory with mlock(2)
- -L lock pages in physical memory with mlockall(2)
- -d daemon mode
- -m max file size to touch
- -p use the specified portion instead of the entire file
- -f follow symbolic links
- -h also count hardlinked copies
- -w wait until all pages are locked (only useful together with -d)
- -v verbose
- -q quiet
2. 一些使用的例子
由于 vmtouch 直接支持目录级查询,所以使用起来简单得多了。
- $ vmtouch /tmp/
- vmtouch: WARNING: skipping non-regular file: /tmp/ssh-GgJnCEkWMQC2/agent.1068
- Files: 17
- Directories: 7
- Resident Pages: 4780/4780 18M/18M 100%
- Elapsed: 0.001006 seconds
如果需要查看更详细信息,可以使用 -v 参数。
- $ vmtouch -v /tmp/
- $ vmtouch -v ~/Downloads/phoronix-test-suite_6.0.1_all.deb
- /home/neo/Downloads/phoronix-test-suite_6.0.1_all.deb
- [ ] 0/132
- Files: 1
- Directories: 0
- Resident Pages: 0/132 0/528K 0%
- Elapsed: 0.000117 seconds
- $ vmtouch -vt ~/Downloads/phoronix-test-suite_6.0.1_all.deb
- /home/neo/Downloads/phoronix-test-suite_6.0.1_all.deb
- [OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 132/132
- Files: 1
- Directories: 0
- Touched Pages: 132 (528K)
- Elapsed: 0.007935 seconds
- $ vmtouch -ve ~/Downloads/phoronix-test-suite_6.0.1_all.deb
- Evicting /home/neo/Downloads/phoronix-test-suite_6.0.1_all.deb
- Files: 1
- Directories: 0
- Evicted Pages: 132 (528K)
- Elapsed: 0.000109 seconds
更多关于 vmtouch 使用的具体信息,你可以参考官网:https://hoytech.com/vmtouch/
如果你还有更多 Linux 下查看 Cache 或 Buffer 占用的方法,请直接留言告诉我们哟!
(编辑:ASP站长网)
|