Quantcast
Channel: Hardware – Benjr.tw
Viewing all articles
Browse latest Browse all 145

LMbench Memory 測試 – lat_mem_rd

$
0
0

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/

lat_mem_rd

主要在測試 CPU 與 memory 之間的讀取延遲 (latency).

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

參數使用:

  • -P : 4 (0~4) 5個 lat_mem_rd 同時跑,可以透過 # ps -aux | grep -i lat_mem_rd 來觀察.
  • -W : 等待時間,單位??
  • -N : 測試重覆 8 次.
  • stride : 預設值為 64 ,改變記憶體大小和 stride (不懂) 來進行 memory 讀取延遲測試.
    The benchmark runs as two nested loops. The outer loop is the stride size. The inner loop is the array size.
    p = (char **)*p;
    

在測試前先透過 #lscpu 看一下 CPU 的 Cache 大小.

root@ubuntu:~# lscpu |grep -i cache
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
root@ubuntu:/usr/lib/lmbench/bin/x86_64-linux-gnu# ./lat_mem_rd 8 64
"stride=64
0.00049 1.201
0.00098 1.201
0.00195 1.201
0.00293 1.201
0.00391 1.201
0.00586 1.201
0.00781 1.201
0.01172 1.201
0.01562 1.201
0.02344 1.201
0.03125 1.201
0.04688 3.609
0.06250 3.609
0.09375 3.616
0.12500 3.616
0.18750 3.616
0.25000 3.616
0.37500 3.616
0.50000 3.616
0.75000 3.616
1.00000 3.615
1.50000 3.613
2.00000 3.617
3.00000 5.059
4.00000 7.533
6.00000 7.801
8.00000 7.843

測試輸出格式為: array size (M) & latency (nanoseconds)

L1 cache 32k 瓶頸一:
可以看到 0.03125M (31.25K) 之後的 延遲 (latency) 突然升高到 1.201 -> 3.609 ,因為到達我系統的 L1 cache 32k 大小上限了.
L2 cache 3M 瓶頸二:
接下來的另一個瓶頸是 2M 的 3.617 到了 3M 時延遲突然變大成為 5.059,因為到達我系統的 L2 cache 3M 大小上限了.

NUMA

如果你的系統架構是 NUMA (Non-uniform memory access),還可以使用 #numacl 來限制要使用哪一顆處理器或是記憶體執行測試程式.關於 NUMA 請參考 http://benjr.tw/96788

lat_mem_rd 來進行測試時,限制 MEM (–membind=0), CPU (–cpunodebind=0) ,我的系統是虛擬機,所以看不出差別.

root@ubuntu:~# numactl --membind=0 --cpunodebind=0 ./lat_mem_rd 8 64
"stride=64
0.00049 1.201
0.00098 1.201
0.00195 1.201
0.00293 1.201
0.00391 1.201
0.00586 1.201
0.00781 1.201
0.01172 1.201
0.01562 1.201
0.02344 1.201
0.03125 1.201
0.04688 3.609
0.06250 3.609
0.09375 3.616
0.12500 3.616
0.18750 3.616
0.25000 3.616
0.37500 3.616
0.50000 3.616
0.75000 3.616
1.00000 3.615
1.50000 3.613
2.00000 3.617
3.00000 5.059
4.00000 7.533
6.00000 7.801
8.00000 7.843

Viewing all articles
Browse latest Browse all 145

Trending Articles