Memory throughput depends on RAM and CPU caches. On Linux, sysbench measures read and write throughput with a chosen working set so cache effects can be interpreted.
The sysbench memory workload repeatedly reads or writes an allocated buffer and reports MiB/sec. A buffer that fits in CPU cache can primarily measure cache throughput; transferring more total data through that same buffer does not make it a RAM bandwidth test.
Synthetic throughput changes with CPU governor, NUMA layout, virtualization, background load, operation type, block size, and thread count. Matching settings make before-and-after runs comparable, but the result is not the RAM's advertised data rate. Memory information covers installed memory type and configured speed.
Steps to benchmark memory throughput in Linux with sysbench:
- Refresh the package index on Debian or Ubuntu.
$ sudo apt update
- Install sysbench from the distribution package repository.
$ sudo apt install --assume-yes sysbench
On other Linux distributions, the equivalent installation uses the native package manager and a repository that provides sysbench.
- Check the available memory before running the benchmarks.
$ free -h total used free shared buff/cache available Mem: 37Gi 21Gi 4.6Gi 61Mi 12Gi 16Gi Swap: 1.0Gi 816Mi 207MiThe available column shows the memory usable without swapping. The 256M buffer used below is at least four times the size of any CPU cache up to 64 MiB. If lscpu --caches shows a larger last-level cache, a larger buffer keeps that margin; virtual machines often leave those sizes blank.
- Run a 30-second write benchmark.
$ sysbench memory --memory-block-size=256M --memory-total-size=0 --memory-oper=write --time=30 run ##### snipped ##### block size: 262144KiB total size: 0MiB operation: write scope: global ##### snipped ##### 312832.00 MiB transferred (10426.49 MiB/sec) ##### snipped ##### total time: 30.0024s ##### snipped #####--memory-block-size sets the buffer size. --memory-total-size=0 removes the transfer cap so --time sets the duration, which is why the output shows total size: 0MiB. The MiB/sec value is logical throughput for this workload, not a direct measurement of memory-bus traffic or a guaranteed peak RAM bandwidth.
- Run a parallel write benchmark when measuring four-worker throughput.
--memory-scope=local gives each worker its own buffer, so four 256M buffers allocate 1 GiB plus program overhead. Skip this run if the available memory is not comfortably above that, because exhausting memory can make the OOM killer stop the benchmark or other processes.
$ sysbench memory --threads=4 --memory-scope=local --memory-block-size=256M --memory-total-size=0 --memory-oper=write --time=30 run ##### snipped ##### block size: 262144KiB total size: 0MiB operation: write scope: local ##### snipped ##### 512768.00 MiB transferred (17045.12 MiB/sec) ##### snipped ##### total time: 30.0823s ##### snipped #####The rate is aggregate throughput across the four workers, so compare it only with other four-worker runs.
- Run a matching 30-second read benchmark.
$ sysbench memory --memory-block-size=256M --memory-total-size=0 --memory-oper=read --time=30 run ##### snipped ##### block size: 262144KiB total size: 0MiB operation: read scope: global ##### snipped ##### 483072.00 MiB transferred (16089.05 MiB/sec) ##### snipped ##### total time: 30.0242s ##### snipped #####A total time near 30 seconds and a nonzero MiB/sec value show that the test completed. Reads and writes can differ substantially, so before-and-after comparisons need the same operation, block size, duration, thread count, and sysbench version. Three or more runs per configuration show the normal variation; a smaller difference than that is inconclusive.