Wednesday, August 29, 2012

SD card benchmark on the Raspberry Pi

This thread in the Raspberry forum and this post discuss benchmarks of different SD cards for use with the Raspberry Pi. I wanted to test my own card, and to do it in the Pi itself. An important conclusion of the two discussions is that the speed of small random writes is important for running an operating system of the card. What the card manufacturers report is the sequential read and write speed which can be substantially higher - these are important in cameras for example.

The posts suggest the program iozone for measuring the SD card performance. I could not find it as a raspbian package, but it was easy to compile from source. Very quick instructions follow.

cat iozone3_408.tar | tar -x
cd iozone3_408/src/current
make linux-arm
./iozone -e -I -a -s 50M -r 4k -r 512k -r 16M -i 0 -i 1 -i 2

The final command runs the test. This command line was suggested in the raspberry forum, for the options run iozone -h . Note that iozone tests the device where the current directory is located. The flags -e and -I are significant here. -e include fflush and sync in the timing, while -I requests the use of direct I/O, without any caching.

For my SanDisk 8G class 4 card (8 €, Media Markt) I got the following results. See here for a picture of the card and packaging.
                                          random  random   
reclen   write rewrite     read   reread    read   write
     4     913     991     3279     3278    3061     457
   512    5292    5370    11305    11304   11218    1319
 16384    5122    5442    11442    11442   11442    5406

The column reclen gives the size of the data blocks tested, while the other columns are speeds in KB/s. For this card, the important figure for small block random write is quite respectable but not as high as what other people in the threads above have reported for the best cards. Anyway, SanDisk cards of class 4 or 6 seem to top the list.

But benchmarking a SD card seems to be a more complicated topic than running the short test above. In practice using RAM for cache gives a huge performance boost, in particular for small writes. My guess is that whether the small random writes will be a bottleneck or not is very much dependent on the application.

I ran two further tests with iozone, using the flag -a (for automatic): once without cache enabled (-e -I) and once with cache. In the -a mode, iozone runs tests for many different file sizes and block sizes. Each test ran for over an hour before I interrupted it. This made me wonder if this amount of writing will wear out the SD card. So far I have seen no problems.

As long as the data written fits in the RAM, cache gives a huge improvement. At a file size of 64 Mb there is a significant speed drop when the cache becomes too small.   
Newer Older Home
Related Posts Plugin for WordPress, Blogger...