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源碼包,然後編譯適合自己target的執行檔案。
#tar iozone3_347.tar
#cd iozone3_347/src/current
#make linux (直接執行make 有幫助選項)

常用參數

-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 -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

測試的定義

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()的使用來映射一個檔案到用戶地址空間。映射之後,對記憶體的讀寫將同步到檔案中去。這對一些希望將檔案當作記憶體塊來使用的應用程式來說很方便。一個例子是記憶體中的一塊將同時作為一個檔案保存在於檔案系統中。

命令行參數

接下來解釋每個參數的用法。
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

相關詞條

熱門詞條

聯絡我們