SPEC CPU 2006
基本的文件目錄結(jié)構(gòu)如下:
安裝步驟如下:
# apt-get install libgfortran3 numactl /*安裝必要組件*/
# cd $YOUR_FOLDER
# tar xzf cpu2006.tgz
# cd cpu2006
#? ./bin/relocate
# source $YOUR_FOLDER/cpu2006/shrc
配置我們的config文件,里面包含操作平臺/硬件/軟件信息,配合不同測試參數(shù)實現(xiàn)不同性能維度的測試嚎尤。我們在此用的配置文件是clover-linux64-amd64-gcc47.cfg诞仓,修改其中的硬件參數(shù)然后執(zhí)行runspe视哑。關(guān)于配置的具體參數(shù)和描述可以參考https://www.spec.org/cpu2006/Docs/config.html
# ./bin/runspec --config clover-linux64-amd64-gcc47.cfg--tune=base int /*--config指定運行的配置文件士袄,tune=base代表基本的性能衡量,還有peak可選胆绊,提供更多的配置編譯選擇
更多執(zhí)行參數(shù)參考:https://www.spec.org/cpu2006/Docs/runspec.html
常見問題:https://www.spec.org/cpu2006/Docs/faq.html
LMbench
LMbench包括一套針對不同操作系統(tǒng)的基準(zhǔn)測試工具了牛,包括上下文切換颜屠,本地通信辰妙,內(nèi)存帶寬和文件操作等。
安裝步驟如下:
# wget https://superb-sea2.dl.sourceforge.net/project/lmbench/development/lmbench-3.0-a9/lmbench-3.0-a9.tgz
# tar -xzvf lmbench-3.0-a9.tgz
# cd lmbench-3.0-a9/
# make results /*第一次執(zhí)行甫窟,彈出的配置選項可暫時用default值*/
# make rerun /*在執(zhí)行完第一次的初始化執(zhí)行后密浑,基本make result生成的配置文件再次測試*/
# make see /*查看結(jié)果,可以拷貝到excel上來進(jìn)行進(jìn)一步的分析和圖表呈現(xiàn)*/
執(zhí)行過程比較長粗井,需要耐心等待尔破。最后輸出的信息有兩個需要注意:
Using config in CONFIG.k-1 /*我們可以看到這次執(zhí)行用的上次的配置文件*/
Mon Jul 23 06:27:25 UTC 2018
Latency measurements
Mon Jul 23 06:29:54 UTC 2018
Calculating file system latency
Mon Jul 23 06:29:57 UTC 2018
Local networking
Mon Jul 23 06:31:07 UTC 2018
Bandwidth measurements
Mon Jul 23 06:33:54 UTC 2018
Calculating context switch overhead
Mon Jul 23 06:34:02 UTC 2018
Calculating effective TLB size
Mon Jul 23 06:34:02 UTC 2018
Calculating memory load parallelism
Mon Jul 23 06:34:03 UTC 2018
McCalpin's STREAM benchmark
Mon Jul 23 06:34:04 UTC 2018
Calculating memory load latency
Mon Jul 23 06:56:01 UTC 2018
Mailing results
../scripts/results: 37: ../scripts/results: mail: not found /*這個錯誤無需理會,看看具體的shell就只知道原因了*/
當(dāng)前的執(zhí)行目錄下查看測試結(jié)果浇衬,可以看到系統(tǒng)軟硬件環(huán)境參數(shù)懒构,輸出的具體內(nèi)存讀寫,文件系統(tǒng)讀寫等詳細(xì)信息
# vim results/x86_64-linux-gnu/k-1.2
基本的測試完畢之后耘擂,利用make see來查看工具自動生成的表格狀信息
# make see
cd results && make summary >summary.out 2>summary.errs
cd results && make percent >percent.out 2>percent.errs
# vim ./results/summary.out
IOzone
文件系統(tǒng)的基準(zhǔn)測試工具胆剧,用來模擬各種磁盤訪問操作,用戶可以自己定義文件塊大小醉冤,IO大小和訪問模式秩霍。比如針對數(shù)據(jù)中心場景的IO密集型操作,該工具可以用來模擬針對大文件的大數(shù)據(jù)塊的隨機(jī)訪問冤灾。
安裝步驟如下:
# wget http://www.iozone.org/src/current/iozone3_482.tar
# tar -xvf?iozone3_482.tar
# less?iozone3_482/src/current/makefile
# make linux-AMD64
Building iozone for Linux-AMD64
cc -c -O3 -Dunix -DHAVE_ANSIC_C -DASYNC_IO -DNAME='"linux-AMD64"' \
? ? ? ? -D__AMD64__ -DSHARED_MEM -Dlinux -D_LARGEFILE64_SOURCE \
? ? ? ? -DHAVE_PREAD? iozone.c -o iozone_linux-AMD64.o
cc -c -O3 -Dunix -DHAVE_ANSIC_C -DASYNC_IO -D_LARGEFILE64_SOURCE \
? ? ? ? -DSHARED_MEM -Dlinux? libbif.c -o libbif.o
cc -c -O3 -Dunix -Dlinux -DHAVE_ANSIC_C -DASYNC_IO \
? ? ? ? -D_LARGEFILE64_SOURCE? libasync.c? -o libasync.o
Building fileop for Linux-AMD64
cc -Wall -c -O3? fileop.c -o fileop_linux-AMD64.o
Building the pit_server
cc -c? pit_server.c? -o pit_server.o
cc? -O3? iozone_linux-AMD64.o libbif.o libasync.o \
? ? ? ? -lrt -lpthread -o iozone
cc? -O3 -Dlinux fileop_linux-AMD64.o -o fileop
cc? -O3 -Dlinux pit_server.o -o pit_server
root@k8s-cluster-1:/home/ubuntu/iozone/iozone3_482/src/current# ls *.o
fileop_linux-AMD64.o? iozone_linux-AMD64.o? libasync.o? libbif.o? pit_server.o
# ./iozone -h
在執(zhí)行前,我們先準(zhǔn)備一塊測試用volume辕近,基本步驟如下
# fdisk -l
Disk /dev/vda: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x49ec635a
Device? ? Boot Start? ? ? End? Sectors? Size Id Type
/dev/vda1? *? ? 2048 209715166 209713119? 100G 83 Linux
Disk /dev/vdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
利用lvm和mkfs進(jìn)行磁盤的劃分和初始化
# fdisk /dev/vdb
...
Command (m for help): n
Partition type
? p? primary (0 primary, 0 extended, 4 free)
? e? extended (container for logical partitions)
Select (default p): e
...
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk /dev/vdb
Command (m for help): p
Disk /dev/vdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7ae1a7eb
Device? ? Boot Start? ? ? End? Sectors Size Id Type
/dev/vdb1? ? ? ? 2048 20971519 20969472? 10G? 5 Extended
/dev/vdb5? ? ? ? 4096 20971519 20967424? 10G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
# pvcreate /dev/vdb5
? Physical volume "/dev/vdb5" successfully created
# vgcreate vg-demo /dev/vdb5
? Volume group "vg-demo" successfully created
# lvcreate -L 5GB -n lv-demo vg-demo
? Logical volume "lv-demo" created.
# lvdisplay
? --- Logical volume ---
? LV Path? ? ? ? ? ? ? ? /dev/vg-demo/lv-demo
? LV Name? ? ? ? ? ? ? ? lv-demo
? VG Name? ? ? ? ? ? ? ? vg-demo
? LV UUID? ? ? ? ? ? ? ? oL5t1V-mBiD-eeo1-Yd3z-nKf2-BeMW-npEy0t
? LV Write Access? ? ? ? read/write
? LV Creation host, time k8s-cluster-1, 2018-07-23 07:41:19 +0000
? LV Status? ? ? ? ? ? ? available
? # open? ? ? ? ? ? ? ? 0
? LV Size? ? ? ? ? ? ? ? 5.00 GiB
? Current LE? ? ? ? ? ? 1280
? Segments? ? ? ? ? ? ? 1
? Allocation? ? ? ? ? ? inherit
? Read ahead sectors? ? auto
? - currently set to? ? 256
? Block device? ? ? ? ? 252:0
# mkfs -t ext4 /dev/vg-demo/lv-demo
# mount /dev/vg-demo/lv-demo /var/demo
# mount | grep demo
/dev/mapper/vg--demo-lv--demo on /var/demo type ext4 (rw,relatime,data=ordered)
執(zhí)行測試韵吨,其中-b知道excel文件名,-R用于輸出excel移宅,-i指定訪問模式归粉,2是隨機(jī)讀寫,-f指定使用的文件漏峰,-r指定IO塊大小糠悼,這里是32kb,-s知道使用文件大小浅乔,這里是4.9g倔喂。其中需要注意的一點是benchmark使用的文件如果小于內(nèi)存大小將可能被緩存,從而測試的是內(nèi)存的吞吐量而不是磁盤系統(tǒng)的吞吐量靖苇,為了避免這種情況席噩,我們可以1)讓文件大小為兩倍內(nèi)存大小贤壁;2)mount的時候使用sync選項悼枢,這里我們用的前者
# ./iozone -b results.xls -R -i 0 -i 2 -f /var/demo/iozone.file -r 32 -s 4.9g
等待測試完畢
# ls -alh /var/demo/iozone.file
-rw-r----- 1 root root 2.7G Jul 23 07:58 /var/demo/iozone.file
# ls -alh /var/demo/iozone.file
-rw-r----- 1 root root 2.8G Jul 23 07:58 /var/demo/iozone.file
打開執(zhí)行目錄下的result.xls文件
netperf
安裝直接apt-get install netperf
netperf用于測試tcp/ip的網(wǎng)絡(luò)性能,支持unix docket和sctp脾拆。它基于client-server模式馒索,被測系統(tǒng)或設(shè)備作為server端運行netserver莹妒,client通過額外的一條控制連接來進(jìn)行配置,發(fā)包和獲取結(jié)果绰上,同實際的測試流量隔離開以確保測試結(jié)果的準(zhǔn)確性旨怠。netperf發(fā)出的流量主要分為兩類:1)bulk data;2)request/response渔期。這里有個缺陷是netperf目前只能基于一個socket進(jìn)行測試而無法支持多并發(fā)的session运吓。當(dāng)前用的版本是2.6.0,可以通過簡單的shell腳本將任務(wù)循環(huán)放入后臺來實現(xiàn)疯趟。
這里需要兩個設(shè)備拘哨,一個client,一個server信峻。
server端:
root@k-2:~# netserver -p 9999
Starting netserver with host 'IN(6)ADDR_ANY' port '9999' and family AF_UNSPEC
root@k-2:~# netstat -pan | grep 9999
tcp6? ? ? 0? ? ? 0 :::9999? ? ? ? ? ? ? ? :::*? ? ? ? ? ? ? ? ? ? LISTEN? ? ? 6163/netserver
client端(可以-c/-C來實現(xiàn)本地/遠(yuǎn)程CPU利用率的查看)倦青,這里我們-t指定的是TCP_CRR,實現(xiàn)連接/請求/回應(yīng)/終結(jié)等操作盹舞,每次交互都會重新建立鏈接产镐,http的keepalive功能是關(guān)閉的,主要用于http1.0/1.1模擬踢步。其他幾種主要的模式如下:
TCP_STREAM 基本的tcp大字節(jié)benchmark癣亚,屬于bulk data
UDP_STREAM 基本的udp測試
TCP_RR tcp交互響應(yīng)速率測試,主要用于http長連接(鏈接不拆除)和針對數(shù)據(jù)庫的訪問
UDP_RR 同上获印,用的udp報文
# netperf -t TCP_CRR -H k-2 -l 10 -- -r 128.1024
MIGRATED TCP Connect/Request/Response TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to k-2 () port 0 AF_INET : demo
Local /Remote
Socket Size? Request? Resp.? Elapsed? Trans.
Send? Recv? Size? ? Size? ? Time? ? Rate
bytes? Bytes? bytes? ? bytes? secs.? ? per sec
16384? 87380? 128? ? ? 128? ? 10.00? ? 5172.56
16384? 87380