https://hoytech.com/vmtouch/

[root@localhost ~]# git clone git://github.com/hoytech/vmtouch.git
正克隆到 'vmtouch'...
remote: Counting objects: 296, done.
remote: Total 296 (delta 0), reused 0 (delta 0), pack-reused 296
接收对象中: 100% (296/296), 285.79 KiB | 24.00 KiB/s, 完成.
处理 delta 中: 100% (144/144), 完成.
检查连接... 完成。
[root@localhost ~]# cd vmtouch
[root@localhost vmtouch]# make
cc -Wall -O2 -g -o vmtouch vmtouch.c
pod2man --section 8 --center "System Manager's Manual" --release " " vmtouch.pod > vmtouch.8 [root@localhost vmtouch]# make install
mkdir -p /usr/local/bin /usr/local/man/man8
install -m 0755 vmtouch /usr/local/bin/vmtouch
install -m 0644 vmtouch.8 /usr/local/man/man8/vmtouch.8
[root@localhost vmtouch]# /usr/local/bin/vmtouch
/usr/local/bin/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 <size> max file size to touch
-p <range> 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 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 <size> max file size to touch
-p <range> 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
[root@localhost vmtouch]# vmtouch -t /data
Files: 193
Directories: 7
Touched Pages: 46138 (180M)
Elapsed: 6.6931 seconds
[root@localhost vmtouch]# vmtouch -t /data/test/t.MYD
Files: 1
Directories: 0
Touched Pages: 1 (4K)
Elapsed: 0.000242 seconds
[root@localhost vmtouch]# vmtouch -e /data/test/t.MYD
Files: 1
Directories: 0
Evicted Pages: 1 (4K)
Elapsed: 7.7e-05 seconds
[root@localhost vmtouch]# vmtouch -e /data
Files: 193
Directories: 7
Evicted Pages: 46138 (180M)
Elapsed: 0.027778 seconds

[root@localhost vmtouch]# vmtouch -e /data/test/t.MYD -v
  Evicting /data/test/t.MYD

  Files: 1
  Directories: 0
  Evicted Pages: 1 (4K)
  Elapsed: 0.000181 seconds

Portable file system cache diagnostics and control

vmtouch is a tool for learning about and controlling the file system cache of unix and unix-like systems. It is BSD licensed so you can basically do whatever you want with it.

Quick install guide:

$ git clone https://github.com/hoytech/vmtouch.git
$ cd vmtouch
$ make
$ sudo make install

What is it good for?

  • Discovering which files your OS is caching
  • Telling the OS to cache or evict certain files or regions of files
  • Locking files into memory so the OS won't evict them
  • Preserving virtual memory profile when failing over servers
  • Keeping a "hot-standby" file-server
  • Plotting filesystem cache usage over time
  • Maintaining "soft quotas" of cache usage
  • Speeding up batch/cron jobs
  • And much more...

Examples

Example 1

How much of the /bin/ directory is currently in cache?

$ vmtouch /bin/
Files: 92
Directories: 1
Resident Pages: 348/1307 1M/5M 26.6%
Elapsed: 0.003426 seconds

Example 2

How much of big-dataset.txt is currently in memory?

$ vmtouch -v big-dataset.txt
big-dataset.txt
[ ] 0/42116 Files: 1
Directories: 0
Resident Pages: 0/42116 0/164M 0%
Elapsed: 0.005182 seconds

None of it. Now let's bring part of it into memory with tail:

$ tail -n 10000 big-dataset.txt > /dev/null

Now how much?

$ vmtouch -v big-dataset.txt
big-dataset.txt
[ oOOOOOOO] 4950/42116 Files: 1
Directories: 0
Resident Pages: 4950/42116 19M/164M 11.8%
Elapsed: 0.006706 seconds

vmtouch tells us that 4950 pages at the end of the file are now resident in memory.

Example 3

Let's touch the rest of /big-dataset.txt/ and bring it into memory (pressing enter a few times to illustrate the animated progress bar you will see on your terminal):

$ vmtouch -vt big-dataset.txt
big-dataset.txt
[OOo oOOOOOOO] 6887/42116
[OOOOOOOOo oOOOOOOO] 10631/42116
[OOOOOOOOOOOOOOo oOOOOOOO] 15351/42116
[OOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 19719/42116
[OOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 24183/42116
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 28615/42116
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 31415/42116
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 36775/42116
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo oOOOOOOO] 39431/42116
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 42116/42116 Files: 1
Directories: 0
Touched Pages: 42116 (164M)
Elapsed: 12.107 seconds

Example 4

We have 3 big datasets, a.txtb.txt, and c.txt but only 2 of them will fit in memory at once. If we have a.txtand b.txt in memory but would now like to work with b.txt and c.txt, we could just start loading up c.txt but then our system would evict pages from both a.txt (which we want) and b.txt (which we don't want).

So let's give the system a hint and evict a.txt from memory, making room for c.txt:

$ vmtouch -ve a.txt
Evicting a.txt Files: 1
Directories: 0
Evicted Pages: 42116 (164M)
Elapsed: 0.076824 seconds

Example 5

Daemonise and lock all files in a directory into physical memory:

vmtouch -dl /var/www/htdocs/critical/

What other people are saying

People have found lots of uses for vmtouch over the years. Here are a few links in no particular order:

Articles

Real-world sightings

Instagram

Discussion about instagram's usage of vmtouch:

Stack-overflow and friends

OS packages/ports

Non-english

  • Spanish: 1
  • French: 1 2
  • Chinese: 1 2 3 4 5 6
  • Russian: 1 2 3
  • Polish: 1

Misc

Other tools

There are also lots of mentions on twitter using the #vmtouch hash-tag

Have another link? Please let me know!

Author

vmtouch is copyright (c) 2009-2016 Doug Hoyte and contributors.

Contributors are listed in CHANGES.

vmtouch - the Virtual Memory Toucher的更多相关文章

  1. 初识virtual memory

    一.先谈几个重要的东西 virtual memory是一个抽象概念,书上的原文是"an abstraction of main memory known as virtual memory& ...

  2. php编译 :virtual memory exhausted: Cannot allocate memory

    有时候用vps建站时需要通过编译的方式来安装主机控制面板.对于大内存的VPS来说一般问题不大,但是对于小内存,比如512MB内存的VPS来说,很有可能会出现问题,因为编译过程是一个内存消耗较大的动作. ...

  3. reds Virtual Memory

    Virtual Memory technical specification This document details the internals of the Redis Virtual Memo ...

  4. ADDM Reports bug:Significant virtual memory paging was detected on the host operating system

    查看ADDM(数据库版本为ORACLE 10.2.0.5.0)报告时,发现其中有个结论非常不靠谱:Significant virtual memory paging was detected on t ...

  5. Linux Process Virtual Memory

    目录 . 简介 . 进程虚拟地址空间 . 内存映射的原理 . 数据结构 . 对区域的操作 . 地址空间 . 内存映射 . 反向映射 .堆的管理 . 缺页异常的处理 . 用户空间缺页异常的校正 . 内核 ...

  6. Cache and Virtual Memory

    Cache存储器:电脑中为高速缓冲存储器,是位于CPU和主存储器DRAM(DynamicRandonAccessMemory)之间,规模较小,但速度很高的存储器,通常由SRAM(StaticRando ...

  7. is running beyond physical memory limits. Current usage: 2.0 GB of 2 GB physical memory used; 2.6 GB of 40 GB virtual memory used

    昨天使用hadoop跑五一的数据,发现报错: Container [pid=,containerID=container_1453101066555_4130018_01_000067] GB phy ...

  8. 编译时:virtual memory exhausted: Cannot allocate memory

    一.问题 当安装虚拟机时系统时没有设置swap大小或设置内存太小,编译程序会出现virtual memory exhausted: Cannot allocate memory的问题,可以用swap扩 ...

  9. Virtual Memory PAGE TABLE STRUCTURE

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION The basic mechanism f ...

随机推荐

  1. ANDROID_MARS学习笔记_S01原始版_021_MP3PLAYER001_下载mp3文件

    一.简介 1.在onListItemClick()中new Intent,Intent以存储序列化后的mp2Info对象作为参数,启动serivce 2.DownloadService在onStart ...

  2. USB Type-C 应用面临安全性考验,USB-IF 将推动新认证机制

    USB 应用已经达到空前盛况,横跨电脑.移动设备.周边设备.影音器材等范畴,是一个极为普遍常见的界面.进入 USB Type-C 世代由于一并推动 USB-PD,过去没有严格执行的认证要求,基于安全性 ...

  3. 从 C++ 到 Qt(命令行编译)good

    从 C++ 到 Qt 转载自:http://hi.baidu.com/cyclone/blog/item/8f8f08fa52d22f8758ee9006.html Qt 是 C++ 的库,Qt在an ...

  4. RunTime报错的一个原因,以及截图

    const char * handle; handle = m_conn->openFile(szRemoteFile,"writeOnly","createTru ...

  5. sdut2536字母哥站队(dp)

    简单DP  说是简单 还是推了好一会 推出来觉得好简单 保留当前i的最小值 dp[i] = min(dp[i],dp[j]+i-j-1) j<i #include <iostream> ...

  6. windows权限错误

    1.installer "内部错误 2203 C:\WINDOWS\Installer\354787.ipi,-2147287035” 用户的local\Temp目录没有system权限 2 ...

  7. POJ 2513 Colored Sticks 解题报告

    第一次接触欧拉回路.虽然在离散数学里学过,敲代码还是第一次. 本题是说端点颜色相同的两根木棒可连接,能否将所有的木棒连成一条直线. 将颜色视为节点v,将木棒视为边e,构成图G.如果能找到一条一笔画的路 ...

  8. [转] 舞蹈链(Dancing Links)——求解精确覆盖问题

    转载自:http://www.cnblogs.com/grenet/p/3145800.html 精确覆盖问题的定义:给定一个由0-1组成的矩阵,是否能找到一个行的集合,使得集合中每一列都恰好包含一个 ...

  9. windows下nginx安装、配置与使用

    目前国内各大门户网站已经部署了Nginx,如新浪.网易.腾讯等:国内几个重要的视频分享网站也部署了Nginx,如六房间.酷6等.新近发现Nginx 技术在国内日趋火热,越来越多的网站开始部署Nginx ...

  10. BrnShop开源网上商城第六讲:扩展视图功能

    在正式讲解扩展视图功能以前,我们有必要把视图的工作原理简单说明下.任何一个视图都会被翻译成一个c#类,并保存到指定的位置,然后被编译.这也就是为什么能在视图中包含c#代码片段的原因.下面我们通过一个项 ...