Memory Benchmark#
I was interested how my RAM performs. Now I know more.
sudo apt install mbw
mbw 512
example result#
locutus $ mbw 512
Long uses 8 bytes. Allocating 2*67108864 elements = 1073741824 bytes of memory.
Using 262144 bytes as blocks for memcpy block copy test.
Getting down to business... Doing 10 runs per test.
0 Method: MEMCPY Elapsed: 0.06258 MiB: 512.00000 Copy: 8181.135 MiB/s
1 Method: MEMCPY Elapsed: 0.06202 MiB: 512.00000 Copy: 8255.934 MiB/s
2 Method: MEMCPY Elapsed: 0.06202 MiB: 512.00000 Copy: 8255.401 MiB/s
3 Method: MEMCPY Elapsed: 0.06224 MiB: 512.00000 Copy: 8226.089 MiB/s
4 Method: MEMCPY Elapsed: 0.06216 MiB: 512.00000 Copy: 8237.338 MiB/s
5 Method: MEMCPY Elapsed: 0.06259 MiB: 512.00000 Copy: 8180.743 MiB/s
6 Method: MEMCPY Elapsed: 0.06220 MiB: 512.00000 Copy: 8232.041 MiB/s
7 Method: MEMCPY Elapsed: 0.06564 MiB: 512.00000 Copy: 7799.647 MiB/s
8 Method: MEMCPY Elapsed: 0.06342 MiB: 512.00000 Copy: 8072.654 MiB/s
9 Method: MEMCPY Elapsed: 0.06319 MiB: 512.00000 Copy: 8102.163 MiB/s
AVG Method: MEMCPY Elapsed: 0.06281 MiB: 512.00000 Copy: 8152.100 MiB/s
0 Method: DUMB Elapsed: 0.03948 MiB: 512.00000 Copy: 12966.949 MiB/s
1 Method: DUMB Elapsed: 0.03845 MiB: 512.00000 Copy: 13314.956 MiB/s
2 Method: DUMB Elapsed: 0.03828 MiB: 512.00000 Copy: 13374.432 MiB/s
3 Method: DUMB Elapsed: 0.03829 MiB: 512.00000 Copy: 13370.939 MiB/s
4 Method: DUMB Elapsed: 0.03875 MiB: 512.00000 Copy: 13212.562 MiB/s
5 Method: DUMB Elapsed: 0.03825 MiB: 512.00000 Copy: 13384.921 MiB/s
6 Method: DUMB Elapsed: 0.03842 MiB: 512.00000 Copy: 13326.393 MiB/s
7 Method: DUMB Elapsed: 0.03824 MiB: 512.00000 Copy: 13389.471 MiB/s
8 Method: DUMB Elapsed: 0.03798 MiB: 512.00000 Copy: 13482.554 MiB/s
9 Method: DUMB Elapsed: 0.03800 MiB: 512.00000 Copy: 13472.266 MiB/s
AVG Method: DUMB Elapsed: 0.03842 MiB: 512.00000 Copy: 13328.023 MiB/s
0 Method: MCBLOCK Elapsed: 0.04010 MiB: 512.00000 Copy: 12767.761 MiB/s
1 Method: MCBLOCK Elapsed: 0.04006 MiB: 512.00000 Copy: 12782.105 MiB/s
2 Method: MCBLOCK Elapsed: 0.04010 MiB: 512.00000 Copy: 12769.035 MiB/s
3 Method: MCBLOCK Elapsed: 0.04013 MiB: 512.00000 Copy: 12759.807 MiB/s
4 Method: MCBLOCK Elapsed: 0.03992 MiB: 512.00000 Copy: 12824.366 MiB/s
5 Method: MCBLOCK Elapsed: 0.04024 MiB: 512.00000 Copy: 12724.923 MiB/s
6 Method: MCBLOCK Elapsed: 0.04009 MiB: 512.00000 Copy: 12770.946 MiB/s
7 Method: MCBLOCK Elapsed: 0.03997 MiB: 512.00000 Copy: 12810.569 MiB/s
8 Method: MCBLOCK Elapsed: 0.04027 MiB: 512.00000 Copy: 12715.758 MiB/s
9 Method: MCBLOCK Elapsed: 0.03997 MiB: 512.00000 Copy: 12808.646 MiB/s
AVG Method: MCBLOCK Elapsed: 0.04008 MiB: 512.00000 Copy: 12773.304 MiB/s
interpret#
According to man mbw:
-t <number>
Select tests to be run. If no -t parameters are given the default is to run all tests. -t0: memcpy() test, -t1: dumb (b[i]=a[i] style) test, -t2: memcpy() with arbitrary block size
So
MEMCPYmeansmemcpy()DUMBmeansb[i]=a[i] styleMCBLOCKmeansmemcpy()with arbitrary block size
explain#
MEMCPY is slowest. I believe because of blocksize 8 (bytes). I get similar results with
mbw 512 -t2 -b8.It’s interesting that
DUMBis faster than MCBLOCK with default block size (whatever that is). I guess it’s because of compiler optimizations.
try#
Increasing block size improves performance - up to a point:
$ for i in 1 2 4 8 16 32 64 128 1024; do echo "$i: $(mbw 512 -q -n1 -t2 -b $i | rg ^AVG)"; done
1: AVG Method: MCBLOCK Elapsed: 0.53046 MiB: 512.00000 Copy: 965.196 MiB/s
2: AVG Method: MCBLOCK Elapsed: 0.26510 MiB: 512.00000 Copy: 1931.354 MiB/s
4: AVG Method: MCBLOCK Elapsed: 0.12078 MiB: 512.00000 Copy: 4239.077 MiB/s
8: AVG Method: MCBLOCK Elapsed: 0.05672 MiB: 512.00000 Copy: 9026.003 MiB/s
16: AVG Method: MCBLOCK Elapsed: 0.04311 MiB: 512.00000 Copy: 11876.870 MiB/s
32: AVG Method: MCBLOCK Elapsed: 0.04184 MiB: 512.00000 Copy: 12237.386 MiB/s
64: AVG Method: MCBLOCK Elapsed: 0.04000 MiB: 512.00000 Copy: 12799.040 MiB/s
128: AVG Method: MCBLOCK Elapsed: 0.04045 MiB: 512.00000 Copy: 12658.541 MiB/s
1024: AVG Method: MCBLOCK Elapsed: 0.04078 MiB: 512.00000 Copy: 12556.406 MiB/s
re: The Coming Loop | Armin Ronacher’s Thoughts and Writings