vmtouch--the Virtual Memory Toucher

简介:

给大家介绍个好玩的工具--vmtouch,可以查看某个文件在内存的使用。下面是摘录其网站,有兴趣的童鞋可以自己研究下

下载源码wget http://hoytech.com/vmtouch/vmtouch.c

编译gcc -Wall -O3 -o vmtouch vmtouch.c

cp vmtouch /usr/local/bin/

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 bring the rest of big-dataset.txt 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.txt and b.txt in memory but would now like to work withb.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/





本文转自 taojin1240 51CTO博客,原文链接:http://blog.51cto.com/taotao1240/743249,如需转载请自行联系原作者

目录
相关文章
|
存储 缓存 自然语言处理
Elasticsearch 内存占用分析及 page cache 监控
Elasticsearch 内存占用相关知识,以及对 lucene 文件的 page cache 进行监控
4081 6
|
缓存 编译器
BOLT 二进制反馈优化技术
大型应用的代码往往达到数十甚至上百MB,这导致在程序执行时缓存机制无法充分利用,导致大量时间花费在CPU和内存链路上。通过对热点函数的布局进行优化,我们可以更好地利用CPU cache,从而获得较为可观的性能提升。针对这一问题,在编译技术上有PGO和Bolt两种解决办法,两者都是一种通过收集程序在运行时如跳转,调用关系,函数热度等执行信息,这些收集到的程序运行情况数据(profile data),可以更好地指导一些程序优化的策略,如是否对函数进行内联,以及对基本块和函数布局的排布来提高特定场景下的程序性能。
2052 2
BOLT 二进制反馈优化技术
|
Linux
如何看懂火焰图
如何看懂火焰图
1365 0
如何看懂火焰图
|
Linux 网络安全
详解Linux常见命令及终端使用技巧
本文主要详解Linux常见命令及终端使用技巧
2602 10
|
监控 调度 开发工具
IO神器blktrace使用介绍
## 前言 1. blktrace的作者正是block io的maintainer,开发此工具,可以更好的追踪IO的过程。 2. blktrace 结合btt可以统计一个IO是在调度队列停留的时间长,还是在硬件上消耗的时间长,利用这个工具可以协助分析和优化问题。 ## blktrace的原理 一个I/O请求的处理过程,可以梳理为这样一张简单的图: ![](http://image
18826 0
|
C++
如何使用MACS进行peak calling
MACS2是peak calling最常用的工具。 callpeak用法 这是MACS2的主要功能,因为MACS2的目的就是找peak,其他功能都是可有可无,唯独callpeak不可取代。
4079 0
|
缓存 Linux 开发工具
CentOS 7- 配置阿里镜像源
阿里镜像官方地址http://mirrors.aliyun.com/ 1、点击官方提供的相应系统的帮助 :2、查看不同版本的系统操作: 下载源1、安装wget yum install -y wget2、下载CentOS 7的repo文件wget -O /etc/yum.
239625 0
|
3月前
|
弹性计算 人工智能 API
部署AI网站-进阶配置
通过Open WebUI部署个人AI网站后,您可能还面临如下问题:希望使用DeepSeek R1模型对话问答时显示思考过程、 希望可以在AI网站上使用联网搜索、希望将AI网站分享给其他用户使用、希望在AI主页上使用多种模型等。本文将介绍如何通过相应配置,解决这些问题。
|
Web App开发 存储 数据可视化
Linux内存管理神器:smem工具
Linux内存管理神器:smem工具
1027 0
Linux内存管理神器:smem工具
|
编解码 JavaScript 算法
通过PHAsset获取的图片上传后变大和图像被旋转90度问题完美解决方案
通过PHAsset获取的图片上传后变大和图像被旋转90度问题完美解决方案
144 4