c++ - 如何排除linux系统的读写缓存进行磁盘性能测试?
高洛峰
高洛峰 2017-04-17 13:24:08
0
5
1052

想测试一下我的ssd硬盘能达到多少的iops,但是读写的时候因为linux系统会自动将读写操作进行cache,也就没法真实的验证性能了,有没有办法可以把这个特性先关闭? 写操作还好办,可以每次写入之后调用fsync强制写入磁盘,读取有类似的方法么?
补充一下,我不是想直接用现有的工具进行测试,我是自己写了一个读写io的程序(c++),想测试一下对应的iops

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(5)
巴扎黑

I haven’t found a way to completely close it. The read cache can be temporarily cleared by echo 3 > /proc/sys/vm/drop_caches

洪涛

crontab
0 */1 * * * root sync && echo 3 > /proc/sys/vm/drop_caches

迷茫

Add parameters after the dd command. You can Google for details. Or, the test data is twice the memory

刘奇

hdparm -W
hdparm -t

Ty80

time dd if=/dev/zero of=test bs=64k count=512 oflag=dsync
Parameter explanation:
if input file
of output file
bs The number of bytes read and written at one time
count The number of times the data block is written, it can also be set to 512.
oflag=dsync forces writing to the physical hard disk every time, that is, not writing to the cache, but writing directly to the hard disk
After execution, a 32M (64*512) test file will be generated in the current directory.
The solid state drive reaches 70MB/second, and the mechanical hard drive is estimated to be about 2MB/second.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template