Raspberry PI IO benchmark with SD card
Tags: raspberrypi
Published: 2022-03-27 06:04:26

I've been experimenting with raspberry pi 400 recently. It is great as a low cost computer and for computing tasks. I ordered it from a site called CanaKit with common configuration which includes SD card as its storage medium to boot up and write data while running.

This setup is good in general, you can even browse the web to some degree but you will notice some sluggishness in your browser. And if you are doing high I/O operations the problem will be easily noticable, your Pi will feel very slow and sluggish despite having a 4-core CPU. Why is that? Because SD Cards are not meant to run a OS (maybe for read only working mode they are okay)

So I was curious about actual performance difference between an SSD and SD card and ran a test. First one is from a Raspberry Pi 400 with 16 GB SD card and second is from Macbook Pro Mid-2012 with SSD installed.

## raspberry pi 400
```
sysbench --test=fileio --file-total-size=250M --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run

sysbench fileio --file-total-size=250M --file-test-mode=rndrw --time=300 --max-requests=0 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


Extra file open flags: (none)
128 files, 1.9531MiB each
250MiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...

Threads started!


File operations:
    reads/s:                      125.66
    writes/s:                     83.77
    fsyncs/s:                     268.17

Throughput:
    read, MiB/s:                  1.96
    written, MiB/s:               1.31

General statistics:
    total time:                          303.6778s
    total number of events:              144910

Latency (ms):
         min:                                    0.00
         avg:                                    2.07
         max:                                19073.59
         95th percentile:                        3.55
         sum:                               299868.24

Threads fairness:
    events (avg/stddev):           144910.0000/0.00
    execution time (avg/stddev):   299.8682/0.00

sysbench --test=fileio --file-total-size=250M cleanup
```

# macbook pro mid 2012 with SSD
```
sysbench fileio --file-total-size=250M --file-test-mode=rndrw --time=300 --max-requests=0 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


Extra file open flags: (none)
128 files, 1.9531MiB each
250MiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...

Threads started!


File operations:
    reads/s:                      8361.83
    writes/s:                     5574.56
    fsyncs/s:                     17838.62

Throughput:
    read, MiB/s:                  130.65
    written, MiB/s:               87.10

General statistics:
    total time:                          300.0045s
    total number of events:              9532565

Latency (ms):
         min:                                    0.00
         avg:                                    0.03
         max:                                  220.04
         95th percentile:                        0.14
         sum:                               290765.63

Threads fairness:
    events (avg/stddev):           9532565.0000/0.00
    execution time (avg/stddev):   290.7656/0.00
```

## Comparison
Writes are 67 times slower in PI. Reads are somewhat similar slower too. That explains the sluggish feel while using chrome, while opening new pages etc. That is because chrome downloads lots of temporary files and caches them, that makes a lot writes into disk. That is okay for an SSD but for an SD card, it causes a slow feeling.