LMbench 是用來測試系統效能的工具.關於安裝與測試種類請參考 http://benjr.tw/98076
測試環境為 Ubuntu 16.04 x86_64 (VMware 虛擬機) ,這邊來討論 LMBench 有關於 Memory 記憶體的測試項目.
安裝完成的 LMbench 程式目錄位於 /usr/lib/lmbench/bin/x86_64-linux-gnu/
root@ubuntu:~# cd /usr/lib/lmbench/bin/x86_64-linux-gnu/
bw_mmap_rd
這邊主要在測試 memory 到 檔案 (硬碟) 之間的讀取速度.
Usage: ./bw_mmap_rd [-C] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] <size> open2close | mmap_only <filename>
參數使用:
- -P
: 4 (0~4) 5個 bw_mmap_rd 同時跑,可以透過 # ps -aux | grep -i bw_mmap_rd 來觀察. - -W
: 等待時間,單位?? - -N
: 測試重覆 8 次. - open2close | mmap_only : 測試方式有兩種 open2close 與 mmap_only ,但沒有查到其代表的意思.
在測試之前需要建立一個大小相等的檔案,可以透過 dd 來建立.
root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# dd if=/dev/zero of=/root/1M bs=1M count=1
root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./bw_mmap_rd 1M open2close /root/1M 1.00 10501.54 root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./bw_mmap_rd 1M mmap_only /root/1M 1.00 22136.85
測試輸出格式為 “%0.2f %.2f\n”, megabytes, megabytes_per_second .
結果為:
megabytes = 1.00 ,每次處理 1M 的資料.
megabytes_per_second = 22136.85 MB/s ,每次處理 1M 的資料,每秒可以處理 22136.85 MB.
NUMA
如果你的系統架構是 NUMA (Non-uniform memory access),還可以使用 #numacl 來限制要使用哪一顆處理器或是記憶體執行測試程式.關於 NUMA 請參考 http://benjr.tw/96788
bw_mmap_rd 來進行測試時,限制 MEM (–membind=0), CPU (–cpunodebind=0) ,我的系統是虛擬機,所以看不出差別.
root@ubuntu:~# numactl --membind=0 --cpunodebind=0 ./bw_mmap_rd 1M open2close /root/1M 1.00 10501.54