1,822 瀏覽數

LMbench – Memory 測試

LMbench 是用來測試系統效能的工具.關於安裝與測試種類請參考 http://benjr.tw/98076

測試環境為 Ubuntu 16.04 x86_64 ,這邊來討論 LMBench 有關於 Memory 記憶體的測試項目.

安裝完成的 LMbench 程式目錄位於 /usr/lib/lmbench/bin/x86_64-linux-gnu/

root@ubuntu:~# cd /usr/lib/lmbench/bin/x86_64-linux-gnu/

bw_mem

先前測試記憶體有 bw_mem_cp (memory copy) ,bw_mem_rd (memory reading and summing) , bw_mem_wr (memory writing). 現統一使用這一程式.
主要在測試 processor 與 memory 之間的傳輸速度.

Usage: bw_mem_cp  [ -P <parallelism> ] [ -W <warmups> ] [ -N <repetitions> ] size rd|wr|rdwr|cp|fwr|frd|bzero|bcopy [align]

測試 rdwr (read data write read) , -P 4 (0~4) 5個 bw_mem 同時跑 , -N 測試重覆 8 次.

root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./bw_mem -N 8 -P 4 16384 rdwr
0.016384 40576.03

測試輸出格式為 “%0.2f %.2f\n”, megabytes, megabytes_per_second .
結果為 megabytes = 0.016384 ,megabytes_per_second = 40576.03 MB/s ,每次處理 16K(0.016384M) 的資料,每秒可以處理 40576.03 MB.

其他可以供使用的測試方式.

  • rd measures the time to read data into the processor.
  • wr measures the time to write data to memory.
  • rdwr measures the time to read data into memory and then write data to the same memory location.
  • cp measures the time to copy data from one location to another.
  • frd measures the time to read data into the processor.
  • fwr measures the time to write data to memory.
  • fcp measures the time to copy data from one location to another.
  • bzero measures how fast the system can bzero memory.
  • bcopy measures how fast the system can bcopy data.

bw_mmap_rd

這邊主要在測試 memory 到 檔案之間的速度.

Usage: ./bw_mmap_rd [-C] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] <size> open2close | mmap_only <filename>

在測試之前需要建立一個大小相等的檔案,可以透過 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 ,megabytes_per_second = 22136.85 MB/s ,每次處理 1M 的資料,每秒可以處理 22136.85 MB.

測試方式有兩種 open2close 與 mmap_only ,但沒有查到其代表的意思.

lat_mem_rd

主要在測試 memory 的讀取延遲 (latency).

Usage: at_mem_rd  [  -P <parallelism> ] [ -W <warmups> ] [ -N <repetitions> ] size_in_megabytes stride [ stride stride...  ]

改變記憶體大小和 stride (不懂) 來進行 memory 讀取延遲測試.

root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./lat_mem_rd 1
"stride=64
0.00049 1.442
0.00098 1.440
0.00195 1.443
0.00293 1.444
0.00391 1.441
0.00586 1.441
0.00781 1.440
0.01172 1.446
0.01562 1.444
0.02344 1.444
0.03125 1.509
0.04688 4.277
0.06250 4.282
0.09375 4.284
0.12500 4.288
0.18750 4.480
0.25000 4.563
0.37500 4.824
0.50000 4.821
0.75000 4.821
1.00000 4.823

測試輸出格式為 nanoseconds per load 及 verified accurate to within a few nanoseconds. (還是不懂)

lat_mmap

這邊主要在測試 memory 到 檔案之間的延遲 (latency)..

Usage: ./lat_mmap [-r] [-C] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] size file

在測試之前需要建立一個大小相等的檔案,可以透過 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# ./lat_mmap 1M /root/1M
1.000000 11

測試輸出格式為 “%0.2f %d\n”, megabytes, usecs.
結果為 1.000000 megabytes, 延遲 (latency) 11 usecs (u : micro 10的-6次方 ).

stream

John McCalpin’s stream benchmark.記憶體的效能檢測.

Usage: stream [ -M <len> ] [ -W <warmups> ] [ -N <repetitions> ]
root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./stream
STREAM copy latency: 2.46 nanoseconds
STREAM copy bandwidth: 6501.42 MB/sec
STREAM scale latency: 1.42 nanoseconds
STREAM scale bandwidth: 11230.04 MB/sec
STREAM add latency: 1.99 nanoseconds
STREAM add bandwidth: 12034.10 MB/sec
STREAM triad latency: 1.91 nanoseconds
STREAM triad bandwidth: 12534.82 MB/sec

par_mem

測試記憶體系統可以並行 (parallelism) 執行多少個請求.

Usage: par_mem [ -L <line size> ] [ -M <len> ] [ -W <warmups> ] [ -N <repetitions> ]
root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./par_mem
0.004096 8.19
0.008192 7.89
0.016384 8.34
0.032768 9.00
0.065536 7.07
0.131072 6.38
0.262144 6.32
0.524288 5.77
1.048576 5.30
2.097152 5.33
4.194304 8.66
8.388608 6.74
16.777216 5.77
33.554432 5.98
67.108864 4.94

發表迴響