複製鏈接
請複製以下鏈接發送給好友

iozone

鎖定
iozone是一個文件系統的benchmark工具,可以測試不同的操作系統中文件系統的讀寫性能。 可以測試 Read, write, re-read,re-write, read backwards, read strided, fread, fwrite, random read, pread, mmap, aio_read, aio_write 等等不同的模式下的硬盤的性能。 測試的時候請注意,設置的測試文件的大小一定要大過你的內存(最佳為內存的兩倍大小),不然linux會給你的讀寫的內容進行緩存。會使數值非常不真實。
外文名
iozone
含    義
文件系統的benchmark工具
用    途
測操作系統中文件系統的讀寫性能

iozone安裝

首先從官方下載最新的iozone源碼包,然後編譯適合自己target的執行文件。
#tar iozone3_347.tar
#cd iozone3_347/src/current
#make linux (直接執行make 有幫助選項)

iozone常用參數

-a 全面測試,比如塊大小它會自動加
-i N 用來選擇測試項, 比如Read/Write/Random 比較常用的是0 1 2,可以指定成-i 0 -i 1 -i2.這些別的詳細內容請查man
0=write/rewrite
1=read/re-read
2=random-read/write
3=Read-backwards
4=Re-write-record
5=stride-read
6=fwrite/re-fwrite
7=fread/Re-fread
8=random mix
9=pwrite/Re-pwrite
10=pread/Re-pread
11=pwritev/Re-pwritev
12=preadv/Re-preadv
-r block size 指定一次寫入/讀出的塊大小
-s file size 指定測試文件的大小
-f filename 指定測試文件的名字,完成後會自動刪除(這個文件必須指定你要測試的那個硬盤中)
-F file1 file2... 指定多線程下測試的文件名
批量測試項:
-g -n 指定測試文件大小範圍,最大測試文件為4G,可以這樣寫 -g 4G
-y -q 指定測試塊的大小範圍
輸出:
下面是幾個日誌記錄的參數.好像要輸出成圖象進行分析,需要指定-a的測試才能輸出
-R 產生Excel到標準輸出
-b 指定輸出到指定文件上. 比如 -Rb ttt.xls

iozone測試實例

#./iozone -a -n 512m -g 4g -i 0 -i 1 -i 5 -f /mnt/iozone -Rb ./iozone.xls
測試結果圖片 測試結果圖片
注:進行全面測試.最小測試文件為512M直到測試到4G.測試read,write,和Strided Read.測試的地方在mnt下。生成Excel的文件.
./iozone -i 0 -i 1 -f /iozone.tmpfile -Rab /test-iozone.xls -g 8G -n 4G -C
結果分析:
使用這條測試命令測試NAS後,我對下邊產生的Execl文件中的一段表進行下解釋,很簡單的:
Writer Report
-
-
-
-
-
-
4
8
16
32
64
32768
5300
8166
12726
16702
24441
65536
5456
8285
9630
16101
18679
131072
5539
6968
9453
13086
14136
262144
5088
7092
9634
11602
14776
524288
5427
9356
10502
13056
13865
1048576
6061
9625
11528
12632
13466
在Execl文件中的這段表,它説明了這個表單是關於write的測試結果,左側一列是測試文件大小(Kbytes),
最上邊一行是記錄大小,中間數據是測試的傳輸速度。舉例説明,比如表中的“5300”,意思是測試文件大小為
32M,以記錄大小為4K來進行傳輸,它的傳輸速度為5300 Kbytes/s

iozone測試的定義

Write: 測試向一個新文件寫入的性能。當一個新文件被寫入時,不僅僅是那些文件中的數據需要被存儲,還包括那些用於定位數據存儲在存儲介質的具體位置的額外信息。這些額外信息被稱作“元數據”。它包括目錄信息,所分配的空間和一些與該文件有關但又並非該文件所含數據的其他數據。拜這些額外信息所賜,Write的性能通常會比Re-write的性能低。
Re-write: 測試向一個已存在的文件寫入的性能。當一個已存在的文件被寫入時,所需工作量較少,因為此時元數據已經存在。Re-write的性能通常比Write的性能高。
Read: 測試讀一個已存在的文件的性能。
Re-Read: 測試讀一個最 近讀過的文件的性能。Re-Read性能會高些,因為操作系統通常會緩存最 近讀過的文件數據。這個緩存可以被用於讀以提高性能。
Random Read: 測試讀一個文件中的隨機偏移量的性能。許多因素都可能影響這種情況下的系統性能,例如:操作系統緩存的大小,磁盤數量,尋道延遲和其他。
Random Write: 測試寫一個文件中的隨機偏移量的性能。同樣,有許多因素可能影響這種情況下的系統性能,例如:操作系統緩存的大小,磁盤數量,尋道延遲和其他。
Random Mix: 測試讀寫一個文件中的隨機偏移量的性能。許多因素可能影響這種情況下的系統性能運作,例如:操作系統緩存的大小,磁盤數量,尋道延遲和其他。這個測試只有在吞吐量測試模式下才能進行。每個線程/進程運行讀或寫測試。這種分佈式讀/寫測試是基於round robin 模式的。最好使用多於一個線程/進程執行此測試。
Backwards Read: 測試使用倒序讀一個文件的性能。這種讀文件方法可能看起來很可笑,事實上,有些應用確實這麼幹。MSC Nastran是一個使用倒序讀文件的應用程序的一個例子。它所讀的文件都十分大(大小從G級別到T級別)。儘管許多操作系統使用一些特殊實現來優化順序讀文件的速度,很少有操作系統注意到並增強倒序讀文件的性能。
Record Rewrite: 測試寫與覆蓋寫一個文件中的特定塊的性能。這個塊可能會發生一些很有趣的事。如果這個塊足夠小(比CPU數據緩存小),測出來的性能將會非常高。如果比CPU數據緩存大而比TLB小,測出來的是另一個階段的性能。如果比此二者都大,但比操作系統緩存小,得到的性能又是一個階段。若大到超過操作系統緩存,又是另一番結果。
Strided Read: 測試跳躍讀一個文件的性能。舉例如下:在0偏移量處讀4Kbytes,然後間隔200Kbytes,讀4Kbytes,再間隔200Kbytes,如此反覆。此時的模式是讀4Kbytes,間隔200Kbytes並重復這個模式。這又是一個典型的應用行為,文件中使用了數據結構並且訪問這個數據結構的特定區域的應用程序常常這樣做。
許多操作系統並沒注意到這種行為或者針對這種類型的訪問做一些優化。同樣,這種訪問行為也可能導致一些有趣的性能異常。一個例子是在一個數據片化的文件系統裏,應用程序的跳躍導致某一個特定的磁盤成為性能瓶頸。
Fwrite: 測試調用庫函數fwrite()來寫文件的性能。這是一個執行緩存與阻塞寫操作的庫例程。緩存在用户空間之內。如果一個應用程序想要寫很小的傳輸塊,fwrite()函數中的緩存與阻塞I/O功能能通過減少實際操作系統調用並在操作系統調用時增加傳輸塊的大小來增強應用程序的性能。
這個測試是寫一個新文件,所以元數據的寫入也是要的。
Frewrite:測試調用庫函數fwrite()來寫文件的性能。這也是一個執行緩存與阻塞寫操作的庫例程。是緩存在用户空間之內。如果一個應用程序想要寫很小的傳輸塊,fwrite()函數中的緩存與阻塞I/O功能可以通過減少實際操作系統調用並在操作系統調用時增加傳輸塊的大小來增強應用程序的性能。
這個測試是寫入一個已存在的文件,由於無元數據操作,測試的性能會高些。
Fread:測試調用庫函數fread()來讀文件的性能。這是一個執行緩存與阻塞讀操作的庫例程。緩存在用户空間之內。如果一個應用程序想要讀很小的傳輸塊,fwrite()函數中的緩存與阻塞I/O功能能通過減少實際操作系統調用並在操作系統調用時增加傳輸塊的大小從而增強應用程序的性能。
幾個特殊測試:
Mmap:許多操作系統支持mmap()的使用來映射一個文件到用户地址空間。映射之後,對內存的讀寫將同步到文件中去。這對一些希望將文件當作內存塊來使用的應用程序來説很方便。一個例子是內存中的一塊將同時作為一個文件保存在於文件系統中。

iozone命令行參數

接下來解釋每個參數的用法。
Usage: iozone [-s filesize_Kb] [-r record_size_Kb ] [-f [path]filename]
[-i ]它們都是什麼意思 ?
-a
用來使用全自動模式。生成包括所有測試操作的報告,使用的塊 大小從4k到16M,文件大小從64k到512M。
-A
使用mmap()文件。這將使用mmap()接口來創建並訪問所有測試用的臨時文件。一
些應用程序傾向於將文件當作內存的一塊來看待。這些應用程序對文件執行mmap()
調用,然後就可以以讀寫內存的方式訪問那個塊來完成文件I/O。
計算時間時將close()包括進來。This is useful only if you suspect that close() is
broken in the operating system currently under test. 對於NFS版本3測試而言這將會
很有用,同時它也能幫助我們識別nfs3_commit 是否正常工作。
-d #
穿過“壁壘”時微秒級的延遲。在吞吐量測試中所有線程或進程在執行測試前都必
須掛起在一道“壁壘”之前。通常來説,所有線程或進程在同一時間被釋放。這個
參數允許在釋放每個進程或線程之間有一定的延遲(微秒級)。Microsecond delay out of barrier. During the throughput tests all threads or processes are
forced to a barrier before beginning the test.
-D
對mmap文件使用msync(MS_ASYNC) 。這告訴操作系統在mmap空間的所有數據
需要被異步地寫到磁盤上。
-e
計算時間時將flush (fsync,fflush) 包括進來。
-E
用來進行一些擴展的測試。只在一些平台上可用。使用pread 接口。
-f filename
用來指定測試時使用的臨時文件的文件名。當使用unmount參數時這將很有用。測試時在每個測試之間進行unmount的話,測試使用的臨時文件在一個可以被卸載的文件夾中是很有必要的。卸載當前工作目錄是不可能的,因為Iozone進程運行於此。
-F filename filename filename …
指定吞吐量測試中每個臨時文件的文件名。文件名的數量應該和指定的進程或線程
數相同。
-g #
設置自動模式可使用的最大文件大小(Kbytes)。
-G
對mmap文件使用msync(MS_SYNC)。這告訴操作系統在mmap空間的所有數據
需要被同步地寫到磁盤上。
-h
顯示幫助。
-H #
使用POSIX異步I/O接口中的#號異步操作。Iozone使用POSIX 異步I/O接口,並使
用bcopy 從異步緩存拷貝迴應用程序緩存。一些版本的MSC NASTRAN就是這麼進
I/O操作的。應用程序使用這一技術以便異步I/O可以在一個庫中實現,而不需要
更改程序內模。
This technique is used by applications so that the async
I/O may be performed in a library and requires no changes to the applications internal model.
-i #
用來指定運行哪個測試。 (0=write/rewrite, 1=read/re-read, 2=random-read/write
3=Read-backwards, 4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite, 7=fread/Re-fread,
8=random mix, 9=pwrite/Re-pwrite, 10=pread/Re-pread, 11=pwritev/Re-pwritev, 12=preadv/Re-preadv).
總是需要先進行0號測試以便後面的測試有文件可以測試。
也支持使用-i # -i # -i # 以便可以進行多個測試。
-I
對所有文件操作使用VxFS VX_DIRECT 。告訴VXFS 文件系統所有對文件的操作將跨
過緩存直接在磁盤上進行。
-j #
設置訪問文件的跨度為 (# * 塊 大小). Stride read測試將使用這個跨度來讀塊 。
-J # (毫秒級)
在每個I/O操作之前產生指定毫秒的計算延遲。看 -X 和-Y來獲取控制計算延
遲的其他參數。
-k #
Use POSIX async I/O (no bcopy) with # async operations. Iozone will use POSIX async
I/O and will not perform any extra bcopys. The buffers used by Iozone will be handed to
the async I/O system call directly.
-K
在普通測試時生成一些隨機訪問。
-l #
Set the lower limit on number of processes to run. When running throughput tests this
option allows the user to specify the least number of processes or threads to start. This
option should be used in conjunction with the -u option.
-L #
Set processor cache line size to value (in bytes). Tells Iozone the processor cache line size.
This is used internally to help speed up the test.
-m
Tells Iozone to use multiple buffers internally. Some applications read into a single
buffer over and over. Others have an array of buffers. This option allows both types of
applications to be simulated. Iozone’s default behavior is to re-use internal buffers.
This option allows one to override the default and to use multiple internal buffers.
-M
Iozone will call uname() and will put the string in the output file.
-n #
為自動模式設置最小文件大小(Kbytes)。
-N
報告結果以毫秒每操作的方式顯示。
-o
寫操作是同步寫到磁盤的。 (O_SYNC). Iozone 會以O_SYNC 標誌打開文件。這強制所有寫操作完全寫入磁盤後才返回測試。
-O
報告結果以操作每秒的方式顯示。
-p
This purges the processor cache before each file operation. Iozone will allocate another
internal buffer that is aligned to the same processor cache boundary and is of a size that
matches the processor cache. It will zero fill this alternate buffer before beginning each test.
This will purge the processor cache and allow one to see the memory subsystem without
the acceleration due to the processor cache.
-P #
Bind processes/threads to processors, starting with this cpu #. Only available on some
platforms. The first sub process or thread will begin on the specified processor. Future processes or threads will be placed on the next processor. Once the total number of cpus is exceeded then future processes or threads will be placed in a round robin fashion.
-q #
設置自動模式下使用的最大塊大小(Kbytes) 。也可以通過-q #k ( Kbytes) 或 -q #m ( Mbytes) 或 -q #g ( Gbytes)。設置最小塊大小見 –y 。
-Q
Create offset/latency files. Iozone will create latency versus offset data files that can be
imported with a graphics package and plotted. This is useful for finding if certain offsets
have very high latencies. Such as the point where UFS will allocate its first indirect block.
One can see from the data the impacts of the extent allocations for extent based filesystems
with this option.
-r #
指定測試塊 大小,K字節。也可以通過-r #k (Kbytes) 或 -r #m (Mbytes) 或 -r #g (Gbytes).
-R
生成Excel報告. Iozone將生成一個兼容Excel的標準輸出報告。這個文件可以使用
Microsoft Excel打開,可以創建一個文件系統性能的圖表。注意:3D圖表是面向列
的。畫圖時你需要選擇這項因為Excel默認處理面向行的數據。
-s #
指定測試文件大小,K字節。也可以通過-s #k (Kbytes) 或 -s #m (Mbytes) 或 -s #g (Gbytes).
-S #
Set processor cache size to value (in Kbytes). This tells Iozone the size of the processor cache.
It is used internally for buffer alignment and for the purge functionality.
-t #
以吞吐量模式運行Iozone。這一選項允許用户指定測試時使用多少個線程或者進程。
-T
吞吐量測試時使用POSIX線程。僅在兼容POSIX線程的平台上可用。
-u #
Set the upper limit on number of processes to run. When running throughput tests this
option allows the user to specify the greatest number of processes or threads to start.
This option should be used in conjunction with the -l option.
-U mountpoint
在測試之間卸載並重新掛載掛載點。這保證了緩存cache不包含任何測試過的文件。
-v
顯示Iozone的版本號。
-V #
Specify a pattern that is to be written to the temporary file and validated for accuracy in
each of the read tests.
-w
當臨時文件使用完畢時不刪除它們。把它們留在文件系統中。
-W
讀或寫時鎖文件。
-x
關閉“stone-walling”. Stonewalling 是 Iozone內部使用的一種技術。它是在進行吞吐量測試時使用的。程序啓動所有線程或進程然後將它們暫停在“壁壘”前。
一旦它們都做好準備工作,它們將被同時釋放。當其中任何一個線程或進程完成工作,整個測試就終止了並計算到達這個點時所有I/O的吞吐量。這保證了整個測試進行時所有的進程和線程都是並行的。這個標誌位允許取消 stonewalling並看看會發生什麼。
-X filename
Use this file for write telemetry information. The file contains triplets of information:
Byte offset, size of transfer, compute delay in milliseconds. This option is useful if one has
taken a system call trace of the application that is of interest. This allows Iozone to replicate the I/O operations that this specific application generates and provide benchmark results for this file behavior. (if column 1 contains # then the line is a comment)
-y #
設置自動模式下使用的最小塊大小(Kbytes) 。也可以通過-y #k ( Kbytes) 或 -y #m ( Mbytes) 或 -y #g ( Gbytes)。設置最大塊大小見 –y 。
-Y filename
Use this file for read telemetry information. The file contains triplets of information:
Byte offset, size of transfer, compute delay in milliseconds. This option is useful if one has
taken a system call trace of the application that is of interest. This allows Iozone to replicate the I/O operations that this specific application generates and provide benchmark results for this file behavior. (if column 1 contains # then the line is a comment)
-z
Used in conjunction with -a to test all possible record sizes. Normally Iozone omits testing
of small record sizes for very large files when used in full automatic mode. This option forces
Iozone to include the small record sizes in the automatic tests also.
-Z