简体   繁体   English

linux中的磁盘读写性能

[英]Disk read/write perfomance in linux

I wanted to check the read/write performance of my disk.我想检查磁盘的读/写性能。 I am executing the below command to write into a file我正在执行以下命令以写入文件

time dd if=/dev/zero of=/home/test.txt bs=2k count=32k;

which gives about 400MB/s这给出了大约 400MB/s

For checking the read performance i have executed below commands.with and without 'of' parameter.为了检查读取性能,我在带有和不带有 'of' 参数的命令下执行。 There is a huge difference between those results这些结果之间存在巨大差异

time dd if=/home/test.txt of=/dev/zero bs=2k (gives about 2.8GB/s)

time dd if=/home/test.txt bs=2k  (9MB/s)

I read that "of=/dev/zero" is used to read data from some temp file while creating the file.我读到“of=/dev/zero”用于在创建文件时从某个临时文件中读取数据。

But why is it required while checking for read performance and why there is a huge difference in speed with and without "of=/dev/zero"但是为什么在检查读取性能时需要它,为什么在使用和不使用“of=/dev/zero”时速度会有巨大差异

/dev/zero is a special file. /dev/zero是一个特殊文件。 It's contents stem from a device driver.它的内容来自设备驱动程序。 All write operations on /dev/zero are guaranteed to succeed. /dev/zero上的所有写操作都保证成功。 A bit more about that here and here更多关于这里这里的信息

Without specifying of dd prints to stdout.不指定dd打印到标准输出。 Thus the data which the terminal receives has to be formatted and printed.因此终端接收的数据必须被格式化和打印。 The terminal you're using is very likely to bottleneck the performance of your drive.您使用的终端很可能会限制驱动器的性能。

Also if likely stands for input file, likewise of means output file.此外,如果可能代表输入文件,同样代表输出文件。

Edit:编辑:

Writing to /dev/zero can have unexpected results.写入/dev/zero可能会产生意想不到的结果。 I wouldn't say this is an accurate way of measuring read performance.我不会说这是衡量读取性能的准确方法。

You use HDD's and filesystem's caches on read operations.您在读取操作中使用 HDD 和文件系统的缓存。 Try oflag=direct flag.试试 oflag=direct 标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM