How to Benchmark Ram Speed on Linux / Ubuntu / Fedora with Sysbench

By | November 27, 2022

Sysbench is a command-line tool that is designed to test and benchmark database performance, but with certain options it can also be used to run tests to measure the raw performance of cpu, ram and storage devices as well.

These tests can give a brief and fairly accurate assessment of the system's performance. In this article we shall see how it can be used to test the raw read/write speed of ram installed on the system.

Bear in mind that ram performance is not the same as memory performance. Memory performance depends on multiple factors like ram, pagefile, cpu cache etc, whereas ram speed measures the raw performance of the ram dimms.

Sysbench can be used on both live or installed Ubuntu and you can expect similar results. Though the scores will vary slightly every time you run the tests.

Sysbench is available in the ubuntu repositories and can be can be installed with apt.

sudo apt-get install sysbench

If you are running Ubuntu in live mode then you have to run the following commands in order:

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install sysbench

Fedora users can use dnf

sudo dnf install sysbench

How to use Sysbench - The Right Way

Using sysbench to measure ram speed is actually quite tricky. Following the documentation you might be tempted into thinking that you just need to run a simple command like this:

sysbench memory run

However the above command will show inaccurate results and report much higher ram read/write speeds than actual. The reason is that it uses a very small block size which easily goes through the CPU Cache, resulting in faster operation, which in reality is not the true ram speed.

By default sysbench uses a memory block size of 1 KiB, which produces completely wrong ram speed measurements.

The solution

The solution is to use a larger block size which will force the system to write more data directly to ram and effectively make correct or close to correct measurements.

Ideally you should use a block size that is multiple times larger than your cpu cache size. For example if your system has 16MB of cache, use a block size of 32MB, 64MB or 128MB block size.

In our tests we are using 1GB block size.

Here is the command I shall be using:

Write Speed Test:

sysbench memory --memory-block-size=1G --memory-total-size=20G --memory-oper=write run

Read Speed Test:

sysbench memory --memory-block-size=1G --memory-total-size=20G --memory-oper=read run

Make sure to run sysbench with only 1 thread, when testing ram speed. If more than 1 thread is used, the reported speed will be higher. So if you use the --threads option it should always be set to 1.

sysbench memory --memory-block-size=1G --memory-total-size=20G --memory-oper=write --threads=1 run

By default sysbench uses only 1 thread, so this option can be skipped. Or you might want to specify it to be double-sure.

Sysbench will output quite some information about the tests, it performs. The transfer speed is the metric which indicates performance. So if you just want to see that number, filter the output with grep.

sysbench memory --memory-block-size=1G --memory-total-size=20G --memory-oper=write run | grep -i transferred

Now lets start testing our machines with sysbench.

Benchmark Results

In this benchmark round, we shall be testing multiple machines, whose hardware specs are already known. Here are the system specs.

System CPU Total RAM Channels Clock frequency (Mhz) DDR Speed (MT/s) Timing Total Bandwidth (MT/s)
Acer Swift 3 Laptop 8G+8G 2 2133 4267 8534
Ubuntu desktop i5-7400 16G+16G 2 1200 2400 16-16-16-39 4800
Asus TUF A17 5800H 8G+8G 2 1600 3200 6400

1. Acer Swift 3 results:

The RAM transfer (DDR) speed "per-channel" can be checked using the dmidecode command at first. The clock frequency is usually half of the DDR transfer speed.

$ sudo dmidecode -t 17 | grep -i "speed"
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
        Speed: 4267 MT/s
        Configured Memory Speed: 4267 MT/s
$

Since this Acer laptop has onboard soldered ram, it shows 8 entries instead of only 2.

acerlight@acerlight-laptop:~$ sysbench memory --memory-block-size=1G --memory-total-size=16G --memory-oper=write --threads=1 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1048576KiB
  total size: 16384MiB
  operation: write
  scope: global

Initializing worker threads...

Threads started!

Total operations: 16 (   13.80 per second)

16384.00 MiB transferred (14135.74 MiB/sec)


General statistics:
    total time:                          1.1577s
    total number of events:              16

Latency (ms):
         min:                                   71.85
         avg:                                   72.35
         max:                                   73.30
         95th percentile:                       73.13
         sum:                                 1157.53

Threads fairness:
    events (avg/stddev):           16.0000/0.00
    execution time (avg/stddev):   1.1575/0.00

acerlight@acerlight-laptop:~$

Write Speed: 14135.74 MiB/sec

acerlight@acerlight-laptop:~$ sysbench memory --memory-block-size=1G --memory-total-size=16G --memory-oper=read --threads=1 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1048576KiB
  total size: 16384MiB
  operation: read
  scope: global

Initializing worker threads...

Threads started!

Total operations: 16 (   14.61 per second)

16384.00 MiB transferred (14962.12 MiB/sec)


General statistics:
    total time:                          1.0936s
    total number of events:              16

Latency (ms):
         min:                                   67.76
         avg:                                   68.34
         max:                                   69.68
         95th percentile:                       69.29
         sum:                                 1093.44

Threads fairness:
    events (avg/stddev):           16.0000/0.00
    execution time (avg/stddev):   1.0934/0.00

acerlight@acerlight-laptop:~$

Read Speed: 14962.12 MiB/sec

2. Ubuntu System

The ram transfer speed as per dmidecode is 2400 MT/s in each channel. So being dual channel, the net bandwidth is 2400+2400 = 4800 MT/s.

Size: 16G+16G
Max Clock Freq: 1200 Mhz
Max Transfer Speed: 2400 MT/s
Timings: 16-16-16-39
$ sudo dmidecode -t 17 | grep -i "speed"
        Speed: 2400 MT/s
        Configured Memory Speed: 2400 MT/s
        Speed: 2400 MT/s
        Configured Memory Speed: 2400 MT/s
$

Now lets run sysbench and see the numbers.

Write Speed Test:

enlightened@enlightened:~$ sysbench memory --memory-block-size=1G --memory-total-size=20G --memory-oper=write run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1048576KiB
  total size: 20480MiB
  operation: write
  scope: global

Initializing worker threads...

Threads started!

Total operations: 20 (   12.18 per second)

20480.00 MiB transferred (12470.48 MiB/sec)


General statistics:
    total time:                          1.6407s
    total number of events:              20

Latency (ms):
         min:                                   80.57
         avg:                                   82.02
         max:                                   86.70
         95th percentile:                       84.47
         sum:                                 1640.46

Threads fairness:
    events (avg/stddev):           20.0000/0.00
    execution time (avg/stddev):   1.6405/0.00

enlightened@enlightened:~$

Write Speed: 12470.48 MiB/sec

Now lets test the read speed. The command to test ram read speed is shown below.

Read Speed Test:

enlightened@enlightened:~$ sysbench memory --memory-block-size=1G --memory-total-size=20G --memory-oper=read run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1048576KiB
  total size: 20480MiB
  operation: read
  scope: global

Initializing worker threads...

Threads started!

Total operations: 20 (   13.89 per second)

20480.00 MiB transferred (14219.70 MiB/sec)


General statistics:
    total time:                          1.4386s
    total number of events:              20

Latency (ms):
         min:                                   69.23
         avg:                                   71.92
         max:                                   74.33
         95th percentile:                       74.46
         sum:                                 1438.44

Threads fairness:
    events (avg/stddev):           20.0000/0.00
    execution time (avg/stddev):   1.4384/0.00

enlightened@enlightened:~$

Read Speed: 14219.70 MiB/sec

3. Asus TUF A17

The next machine is Asus TUF A17 laptop with the following ram configuration:

Size: 8G+8G
Max Clock Freq: 1600 Mhz
Max Transfer Speed: 3200 MT/s (PC4-25600 DDR4)
Timings: 22-22-22-52

Write Test:

ubuntu@ubuntu:~$ sysbench memory --memory-block-size=1G --memory-total-size=16G --memory-oper=write --threads=1 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1048576KiB
  total size: 16384MiB
  operation: write
  scope: global

Initializing worker threads...

Threads started!

Total operations: 16 (   11.34 per second)

16384.00 MiB transferred (11608.65 MiB/sec)


General statistics:
    total time:                          1.4108s
    total number of events:              16

Latency (ms):
         min:                                   87.38
         avg:                                   88.16
         max:                                   95.34
         95th percentile:                       89.16
         sum:                                 1410.58

Threads fairness:
    events (avg/stddev):           16.0000/0.00
    execution time (avg/stddev):   1.4106/0.00

ubuntu@ubuntu:~$

Write Speed: 11608.65 MiB/sec

Read Test:

ubuntu@ubuntu:~$ sysbench memory --memory-block-size=1G --memory-total-size=16G --memory-oper=read --threads=1 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1048576KiB
  total size: 16384MiB
  operation: read
  scope: global

Initializing worker threads...

Threads started!

Total operations: 16 (   23.38 per second)

16384.00 MiB transferred (23942.08 MiB/sec)


General statistics:
    total time:                          0.6838s
    total number of events:              16

Latency (ms):
         min:                                   41.58
         avg:                                   42.72
         max:                                   45.94
         95th percentile:                       44.17
         sum:                                  683.54

Threads fairness:
    events (avg/stddev):           16.0000/0.00
    execution time (avg/stddev):   0.6835/0.00

ubuntu@ubuntu:~$

Read Speed: 23942.08 MiB/sec

Comparing the scores

Now we have the sysbench results for each machine compiled in the table below:

System Sysbench (Write) Transfer Speed (MiB/sec) Sysbench (Read) Transfer Speed (MiB/sec) RAM DDR4-Speed (MT/s) Timings (CAS Latency)
Acer Swift 3 Laptop 14135.74 14962.12 8G+8G 4267 36-39-39-90 10.3ns
Ubuntu desktop 12470.48 14219.70 16G+16G 2400 16-16-16-39 13.3ns
Asus Tuf A17 (5800H) 11608.65 23942.08 8G+8G 3200 22-22-22-52 13.75ns
Acer Aspire 5 (5500U) 5512.75 16654.90 8G 3200 22-22-22-52 13.75ns

Note the following:

1. The Acer Swift 3 laptop scores the highest "Sysbench transfer Speed" which is expected because it has highest ram clock frequency.

2. Ubuntu desktop with 2400 MT/s ram has better write-speed than Asus TUF A17 with 3200 MT/s ram. This is because lower timings has less latency. This proves that clock frequency alone does not determine the ram peformance, and the latency numbers should also be taken into account.

3. Both Asus TUF A17 and Acer Aspire 5 have ryzen cpus have write speed half of the read speed. They are based on the Zen 3 architecture which uses a 1 CCD design and shares the L3 cache across all cores. However the Zen 3 architecture cuts the bandwidth to half for write operations. Read operations work at full rate though.

This has been discussed here, here, here.

Sysbench vs Passmark Memtest86

There are more free tools out there to test ram speed. Passmark Memtest86 is a popular ram testing and benchmark tool that runs on stand-alone without the need of operating system. Hence its able to perform tests much closer to the hardware, since there is no layer of operating system. This results in more accurate testing.

In our tests, we have seen that sysbench is able to produce test numbers that are quite close to those of Passmark Memtest86.
This makes it a useful tool to get a quick report of how the ram on a system is performing.

Conclusion

Sysbench is a versatile tool that can benchmark cpu, disk io and memory speeds. Though it primarily tests the overall memory speeds, when run with specific parameters it reveals the raw performance of ram as shown in the above tests.

Being a command-line tool sysbench can also be run on web servers that are run under heavy loads in a high demanding environment.

Other free tools include the mbw command, Stream. However each has a different approach towards testing memory bandwidth, which may or may not actually represent the true ram speed.

Tell us your scores

Run the commands shown above on your systems and paste the scores in the comment below. This will help readers to get a comparison of how their system performs vs other hardware profiles.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

3 Comments

How to Benchmark Ram Speed on Linux / Ubuntu / Fedora with Sysbench
  1. Rayan

    Great Article.
    Could you elaborate a bit how with this command i can verify the nominal speed of my RAM? Ive been told that my laptop (RYZEN 7 7735HS) supports DDR5 4800 MT/s and in the case of using a higher clock speed it will be clocked down to 4800. but people on reddit and elsewhere claim they have used 5600 MT/s RAMs successfully with noticable operating speed. how can i verify that using this command?

Leave a Reply

Your email address will not be published. Required fields are marked *