如果不耐烦,请跳到下面的“问题”标题。

语境

我从事Unix(如)系统管理和基础结构开发的工作,但我认为程序员最好回答我的问题:o)

我想做的是学习如何使用iozone对文件系统(普通文件,托管卷,虚拟化文件,加密文件等)进行基准测试。作为练习,我对USB笔驱动器进行了基准测试,该笔驱动器将用作我的子弹(http://www.nslu2-linux.org/)中的系统磁盘,它们分别用vfat,ntfs,ext3,ext4和xfs格式化。测试产生了一些令人惊讶的结果,这些结果在下面发布。但是,结果之所以令我感到惊讶的原因很可能是因为我对iozone还是陌生的,并不真正知道如何解释这些数字。因此,这篇文章。

在我的测试中,iozone对11种不同的文件操作进行了基准测试,但仅对一种记录大小(4k,与所有测试文件系统的块大小匹配)进行了基准测试,并且仅对一种文件大小(512MB)进行了基准测试。文件系统记录大小和文件大小的单方面当然会给测试带来一些偏差。无论如何,下面列出了文件操作,每个操作都有我自己的简短解释:


初始写入:按顺序将新数据写入磁盘,定期使用文件
重写:将新数据按顺序添加到现有的常规文件中
读取:顺序读取数据,常规文件使用
重读:顺序重读数据(缓冲区测试,还是什么?)
反向读取:???
大步阅读:???
随机读取:非顺序读取,通常是数据库使用情况
随机写入:非顺序写入,通常是数据库使用情况
前导:读取特定位置的数据-用于索引数据库?
pwrite:在某个位置写入数据-用于索引数据库?
混合工作负载:(明显)


其中一些操作似乎很简单。我想初始写入,重写和读取都用于常规文件处理,包括让指针寻找直到到达某个块,然后顺序读取或写入(通常通过许多块),有时由于碎片而不得不向前跳一点文件。重新读取测试(我想)的唯一目标是缓冲区测试。同时,随机读/写是典型的数据库操作,其中指针必须在收集数据库记录的同一文件中从一个地方跳到另一个地方,例如在连接表时。

那么问题是什么?

到目前为止,一切都很好。我对上述假设的任何更正表示赞赏,尽管它们似乎是相当常识。现在是一个真正的问题:为什么您要进行反向阅读?大步读什么?有人告诉我,“位置”操作pread和pwrite用于索引数据库,但是为什么不简单地将索引保存在内存中呢?还是那实际上发生了什么,然后一旦给定了特定的索引,前置词就可以方便地跳转到记录的确切位置?您还使用pread / pwrite做什么?

综上所述,到现在为止,我觉得我只能以一半的方式解释我的碘结果。我或多或少知道为什么随机操作中的高数字将使一个数据库成为一个好的文件系统,但是为什么我需要以相反的顺序读取文件,一个好的步伐告诉我什么呢?这些操作的典型应用程序用途是什么?

奖金问题

问了这个,这是一个奖金问题。作为给定文件系统的管理员,他从有经验的程序员那里学会了如何解释我的文件系统基准测试;)-是否有人对如何对文件系统的实际使用进行分析提出建议?尽管很费时间,但尝试使用文件系统记录(块)大小是微不足道的。关于给定文件系统中文件的大小和分布,“查找”是我的朋友。但是我该怎么做才能获得对实际文件系统调用(如read(),pwrite()等)的计数?

同样,对于其他资源对文件系统测试结果的影响的任何评论,例如处理器能力以及RAM容量和速度的作用,我也将不胜感激。例如,当我想在带有266 MHz ARM Intel XScale处理器和32/8的子弹中使用pendrive时,在装有1.66Ghz Atom处理器和2 gig DDR2 RAM的计算机上进行此测试有什么不同? MB SD /闪存RAM?

架构思维文档?

因为我不想重复太多,所以我也不想问别人,因此,如果这些问题不能以简短的方式回答,我将不胜感激与其他文档的链接,重要的是它解释了上述文件操作实际上是做什么的(我可以考虑使用API​​),但是本文档从体系结构上讲,也就是说,它解释了这些操作通常在现实生活中的应用中将如何使用。

检测结果

对。我答应了我相当谦虚的USB pendrive文件系统测试的结果。我的主要期望是写入结果通常较差(由于闪存驱动器的性质,其块大小通常比实际管理它的文件系统大,这意味着要写入较小的更改,必须重写相对大量的未更改数据),读取效果不错。主要要点是:


vfat在所有操作上都做得非常好,除了有点晦涩(无论如何对我来说)反向读取和跨步读取。我猜缺少功能会消除很多记帐功能。
ntfs在重写(追加)和读取操作上很烂,因此不适合常规文件操作。它还吸收了pread操作,使其不适合索引数据库。
令人惊讶的是,ext3和ext4在所有操作上略胜一筹,它们在初始写入,重写,读取,随机写入和pwrite操作上很烂,使它们不适合常规文件使用以及强烈更新的数据库。但是,ext4是随机读取和预读的精通工具,使其成为某些静态数据库(?)的极佳候选者。 ext3和ext4在晦涩的反向读取和跨步读取操作上均得分很高,无论这意味着什么。
无与伦比的全面测试冠军是xfs,它的唯一弱点似乎是反向阅读。在初始写入,重写,读取,随机写入和pwrite方面,它是最好的选择,使其成为常规文件使用以及(强烈更新的)数据库的极佳候选者。在重读,随机读取和预读方面,它是第二名,使其成为(某种程度上是静态的)数据库的不错选择。跨步阅读也很不错-不管怎么说!


欢迎对这些结果的解释发表任何评论!数字在下面列出(出于长度的原因有些削减),其中一个是iozone测试套件。文件系统类型,均在标准4GB Verbatim Pendrive(橙色;)上进行了测试,并停靠在带有N450 1.66Ghz Atom CPU和2GB DDR2 667Mhz RAM,运行Linux 3.2.0-24 x86内核的Samsung N105P笔记本电脑中进行加密交换(是的,我知道,我应该安装64位Linux,并清楚保留交换!)。

问候,
托斯滕

PS。写完这篇文章后,我发现Debian NSLU2发行版显然不支持xfs。我的问题仍然存在!

-vfat-

Iozone: Performance Test of File I/O
        Version $Revision: 3.397 $
    Compiled for 32 bit mode.
    Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
             Al Slater, Scott Rhine, Mike Wisner, Ken Goss
             Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
             Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
             Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
             Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
             Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.
             Ben England.

Run began: Mon Jun  4 14:23:57 2012

Record Size 4 KB
File size set to 524288 KB
Command line used: iozone -l 1 -u 1 -r 4k -s 512m -F /mnt/iozone.tmp
Output is in Kbytes/sec
Time Resolution = 0.000002 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
Min process = 1
Max process = 1
Throughput test with 1 process
Each process writes a 524288 Kbyte file in 4 Kbyte records

Children see throughput for  1 initial writers  =   12864.82 KB/sec
Parent sees throughput for  1 initial writers   =    3033.39 KB/sec

Children see throughput for  1 rewriters    =   25271.86 KB/sec
Parent sees throughput for  1 rewriters     =    2876.36 KB/sec

Children see throughput for  1 readers      =  685333.00 KB/sec
Parent sees throughput for  1 readers       =  682464.06 KB/sec

Children see throughput for 1 re-readers    =  727929.94 KB/sec
Parent sees throughput for 1 re-readers     =  726612.47 KB/sec

Children see throughput for 1 reverse readers   =  458174.00 KB/sec
Parent sees throughput for 1 reverse readers    =  456910.21 KB/sec

Children see throughput for 1 stride readers    =  351768.00 KB/sec
Parent sees throughput for 1 stride readers     =  351504.09 KB/sec

Children see throughput for 1 random readers    =  553705.94 KB/sec
Parent sees throughput for 1 random readers     =  552630.83 KB/sec

Children see throughput for 1 mixed workload    =  549812.50 KB/sec
Parent sees throughput for 1 mixed workload     =  547645.03 KB/sec

Children see throughput for 1 random writers    =   19958.66 KB/sec
Parent sees throughput for 1 random writers     =    2752.23 KB/sec

Children see throughput for 1 pwrite writers    =   13355.57 KB/sec
Parent sees throughput for 1 pwrite writers     =    3119.04 KB/sec

Children see throughput for 1 pread readers     =  574273.31 KB/sec
Parent sees throughput for 1 pread readers  =  572121.97 KB/sec


-ntfs-

Iozone: Performance Test of File I/O
        Version $Revision: 3.397 $
    Compiled for 32 bit mode.
    Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
             Al Slater, Scott Rhine, Mike Wisner, Ken Goss
             Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
             Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
             Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
             Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
             Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.
             Ben England.

Run began: Mon Jun  4 13:59:37 2012

Record Size 4 KB
File size set to 524288 KB
Command line used: iozone -l 1 -u 1 -r 4k -s 512m -F /mnt/iozone.tmp
Output is in Kbytes/sec
Time Resolution = 0.000002 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
Min process = 1
Max process = 1
Throughput test with 1 process
Each process writes a 524288 Kbyte file in 4 Kbyte records

Children see throughput for  1 initial writers  =   11153.75 KB/sec
Parent sees throughput for  1 initial writers   =    2848.69 KB/sec

Children see throughput for  1 rewriters    =    8723.95 KB/sec
Parent sees throughput for  1 rewriters     =    2794.81 KB/sec

Children see throughput for  1 readers      =   24935.60 KB/sec
Parent sees throughput for  1 readers       =   24878.74 KB/sec

Children see throughput for 1 re-readers    =  144415.05 KB/sec
Parent sees throughput for 1 re-readers     =  144340.90 KB/sec

Children see throughput for 1 reverse readers   =   76627.60 KB/sec
Parent sees throughput for 1 reverse readers    =   76362.93 KB/sec

Children see throughput for 1 stride readers    =  367293.25 KB/sec
Parent sees throughput for 1 stride readers     =  366002.25 KB/sec

Children see throughput for 1 random readers    =  505843.41 KB/sec
Parent sees throughput for 1 random readers     =  500556.16 KB/sec

Children see throughput for 1 mixed workload    =  553075.56 KB/sec
Parent sees throughput for 1 mixed workload     =  551754.97 KB/sec

Children see throughput for 1 random writers    =    9747.23 KB/sec
Parent sees throughput for 1 random writers     =    2381.89 KB/sec

Children see throughput for 1 pwrite writers    =   10906.05 KB/sec
Parent sees throughput for 1 pwrite writers     =    1931.43 KB/sec

Children see throughput for 1 pread readers     =   16730.47 KB/sec
Parent sees throughput for 1 pread readers  =   16194.80 KB/sec


-ext3-

Iozone: Performance Test of File I/O
        Version $Revision: 3.397 $
    Compiled for 32 bit mode.
    Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
             Al Slater, Scott Rhine, Mike Wisner, Ken Goss
             Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
             Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
             Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
             Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
             Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.
             Ben England.

Run began: Sun Jun  3 16:05:27 2012

Record Size 4 KB
File size set to 524288 KB
Command line used: iozone -l 1 -u 1 -r 4k -s 512m -F /media/verbatim/1/iozone.tmp
Output is in Kbytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
Min process = 1
Max process = 1
Throughput test with 1 process
Each process writes a 524288 Kbyte file in 4 Kbyte records

Children see throughput for  1 initial writers  =    3704.61 KB/sec
Parent sees throughput for  1 initial writers   =    3238.73 KB/sec

Children see throughput for  1 rewriters    =    3693.52 KB/sec
Parent sees throughput for  1 rewriters     =    3291.40 KB/sec

Children see throughput for  1 readers      =  103318.38 KB/sec
Parent sees throughput for  1 readers       =  103210.16 KB/sec

Children see throughput for 1 re-readers    =  908090.88 KB/sec
Parent sees throughput for 1 re-readers     =  906356.05 KB/sec

Children see throughput for 1 reverse readers   =  744801.38 KB/sec
Parent sees throughput for 1 reverse readers    =  743703.54 KB/sec

Children see throughput for 1 stride readers    =  623353.88 KB/sec
Parent sees throughput for 1 stride readers     =  622295.11 KB/sec

Children see throughput for 1 random readers    =  725649.06 KB/sec
Parent sees throughput for 1 random readers     =  723891.82 KB/sec

Children see throughput for 1 mixed workload    =  734631.44 KB/sec
Parent sees throughput for 1 mixed workload     =  733283.36 KB/sec

Children see throughput for 1 random writers    =     177.59 KB/sec
Parent sees throughput for 1 random writers     =     137.83 KB/sec

Children see throughput for 1 pwrite writers    =    2319.47 KB/sec
Parent sees throughput for 1 pwrite writers     =    2200.95 KB/sec

Children see throughput for 1 pread readers     =   13614.82 KB/sec
Parent sees throughput for 1 pread readers  =   13614.45 KB/sec


-ext4-

Iozone: Performance Test of File I/O
        Version $Revision: 3.397 $
    Compiled for 32 bit mode.
    Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
             Al Slater, Scott Rhine, Mike Wisner, Ken Goss
             Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
             Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
             Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
             Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
             Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.
             Ben England.

Run began: Sun Jun  3 17:59:26 2012

Record Size 4 KB
File size set to 524288 KB
Command line used: iozone -l 1 -u 1 -r 4k -s 512m -F /media/verbatim/2/iozone.tmp
Output is in Kbytes/sec
Time Resolution = 0.000005 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
Min process = 1
Max process = 1
Throughput test with 1 process
Each process writes a 524288 Kbyte file in 4 Kbyte records

Children see throughput for  1 initial writers  =    4086.64 KB/sec
Parent sees throughput for  1 initial writers   =    3533.34 KB/sec

Children see throughput for  1 rewriters    =    4039.37 KB/sec
Parent sees throughput for  1 rewriters     =    3409.48 KB/sec

Children see throughput for  1 readers      = 1073806.38 KB/sec
Parent sees throughput for  1 readers       = 1062541.84 KB/sec

Children see throughput for 1 re-readers    =  991162.00 KB/sec
Parent sees throughput for 1 re-readers     =  988426.34 KB/sec

Children see throughput for 1 reverse readers   =  811973.62 KB/sec
Parent sees throughput for 1 reverse readers    =  810333.28 KB/sec

Children see throughput for 1 stride readers    =  779127.19 KB/sec
Parent sees throughput for 1 stride readers     =  777359.89 KB/sec

Children see throughput for 1 random readers    =  796860.56 KB/sec
Parent sees throughput for 1 random readers     =  795138.41 KB/sec

Children see throughput for 1 mixed workload    =  741489.56 KB/sec
Parent sees throughput for 1 mixed workload     =  739544.09 KB/sec

Children see throughput for 1 random writers    =     499.05 KB/sec
Parent sees throughput for 1 random writers     =     399.82 KB/sec

Children see throughput for 1 pwrite writers    =    4092.66 KB/sec
Parent sees throughput for 1 pwrite writers     =    3451.62 KB/sec

Children see throughput for 1 pread readers     =  840101.38 KB/sec
Parent sees throughput for 1 pread readers  =  831083.31 KB/sec


-xfs-

Iozone: Performance Test of File I/O
        Version $Revision: 3.397 $
    Compiled for 32 bit mode.
    Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
             Al Slater, Scott Rhine, Mike Wisner, Ken Goss
             Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
             Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
             Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
             Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
             Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer.
             Ben England.

Run began: Mon Jun  4 14:47:49 2012

Record Size 4 KB
File size set to 524288 KB
Command line used: iozone -l 1 -u 1 -r 4k -s 512m -F /mnt/iozone.tmp
Output is in Kbytes/sec
Time Resolution = 0.000005 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
Min process = 1
Max process = 1
Throughput test with 1 process
Each process writes a 524288 Kbyte file in 4 Kbyte records

Children see throughput for  1 initial writers  =   21854.47 KB/sec
Parent sees throughput for  1 initial writers   =    3836.32 KB/sec

Children see throughput for  1 rewriters    =   29420.40 KB/sec
Parent sees throughput for  1 rewriters     =    3955.65 KB/sec

Children see throughput for  1 readers      =  624136.75 KB/sec
Parent sees throughput for  1 readers       =  614326.13 KB/sec

Children see throughput for 1 re-readers    =  577542.62 KB/sec
Parent sees throughput for 1 re-readers     =  576533.42 KB/sec

Children see throughput for 1 reverse readers   =  483368.06 KB/sec
Parent sees throughput for 1 reverse readers    =  482598.67 KB/sec

Children see throughput for 1 stride readers    =  537227.12 KB/sec
Parent sees throughput for 1 stride readers     =  536313.77 KB/sec

Children see throughput for 1 random readers    =  525219.19 KB/sec
Parent sees throughput for 1 random readers     =  524062.07 KB/sec

Children see throughput for 1 mixed workload    =  561513.50 KB/sec
Parent sees throughput for 1 mixed workload     =  560142.18 KB/sec

Children see throughput for 1 random writers    =   24118.34 KB/sec
Parent sees throughput for 1 random writers     =    3117.71 KB/sec

Children see throughput for 1 pwrite writers    =   32512.07 KB/sec
Parent sees throughput for 1 pwrite writers     =    3825.54 KB/sec

Children see throughput for 1 pread readers     =  525244.94 KB/sec
Parent sees throughput for 1 pread readers  =  523331.93 KB/sec

最佳答案

我唯一需要深入了解文件系统性能的时间是在Windows系统上。无论您使用什么操作系统/文件系统,总原则都适用。

你为什么要反向阅读?

程序运行时,它读取块987654,然后使用该数据确定需要块123456。这可能在联接上发生:您的Db可能正在使用表1上的索引来从表2中选择记录(使用索引)。拣配操作可能以表1的顺序发生(与表2的顺序相反)。

使用两个键时,单个表选择可能会发生类似情况。

大步读什么?

读取每个第N个块读取块12345600,然后块12345700,然后块12345800的跨度为100。想象一下一个包含许多列和/或大列的表。该表可能具有需要几个文件系统块来保存数据的行。通常,数据库会将这些数据组织到每行的一条记录中,每条记录都占用几个顺序的文件系统块。如果您的数据库行占据了10个文件系统块,并且您选择了两列,则可能只需要读取该10个块记录中的第1个和第6个块。然后,您需要查询块10001、10006、10011、10016、10021、10026-跨度为5。

有人告诉我,“位置”操作pread和pwrite用于索引数据库,但是为什么不简单地将索引保存在内存中呢?

索引的大小可能超过合理的RAM使用量。或者,您先前的用法将其他索引或数据称为ram,导致未使用的索引从文件系统/ db缓存中移出。

还是那实际上发生了什么,然后一旦给定了特定的索引,前置词就可以方便地跳转到记录的确切位置?是的,这可能就是您的数据库正在执行的操作。

您还使用pread / pwrite做什么?

一些数据文件具有预定义的“有趣”位置。这可能是B树索引的根,表头,日志/日志尾或其他内容,具体取决于您的Db实现。 pread / rwrite用于测试重复跳到设置的特定位置而不是位置的均匀随机混合的性能。

链接?

对于所有主流OS,都存在可以捕获每个OS文件系统操作的系统utilities。我认为它们在* NIX系统上可能被命名为DTRACE或pTAP或pTRACE。您可以使用来自这些监视器的大量数据(经过智能筛选)来查看系统中的磁盘访问模式。

那么一般的经验法则是,对于Db的使用,淫秽的RAM数量会有所帮助。然后,所有索引始终都驻留在RAM中。

关于filesystems - 反向/跨步/扩展和pwrite的典型应用程序有哪些用途?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10897790/

10-14 04:14