1

I have a Pi B+ running openelec 6.0 and I am using it as backend/frontend to record over-the-air TV programs. So far everything seems pretty good aside from some performance issues. I am interested in performing some read/write test to determine the best device used for recording TV programs. In some cases I am recording while watching a previously recorded program. Since I am reading and writing to the same device (for example) microSD card I am interested in looking at some tests that provide some insight about my system. Can I perform a read/write test simultaneously? Another question; I havent used dd for performance test. I read from another post it is possible to use the following command. I am not sure what does /dev/zero and /dev/null means. Can I perform this in the microSD card where openelec is installed without deleting it? The next question is can I run both commands simultaneously? What would I do open two SSH sessions?

#write
dd if=/dev/zero of=~/test.tmp bs=500K count=1024 
#read
dd if=~/test.tmp of=/dev/null bs=500K count=1024
3
  • 1
    you can try ctrl+t while transferring files with dd for stats
    – Gotschi
    Nov 16, 2015 at 15:42
  • 1
    @Gotschi Beware that may easily give you a (very) fake time because of file caching, see "However..." in my answer.
    – goldilocks
    Nov 16, 2015 at 16:03
  • Your bottle neck could be the USB2 ethernet
    – Antzi
    Dec 16, 2015 at 17:23

2 Answers 2

1

/dev/zero is just a bottomless source for null bytes. You can endlessly read from this.

/dev/null is just a bottomless sink for anything. You can endlessly write to this without affecting anything.

See man dd for an explanation of how it works. This:

bs=500K count=1024

is 1024 blocks of 500 KiB each, i.e., ~512 MB. You probably want a more realistic block size for testing, e.g.:

bs=4096 count=51200

A 4 KiB block size, there are 256 such blocks in 1 MiB, so that's 200 MiB, which is probably enough.

However...

Doing this way with the filesystem has a catch, because the OS will cache data in free memory. You need to include a sync call with the write so the data is actually flushed out:

#!/bin/sh
dd if=/dev/zero of=test.file bs=4096 count=51200
sync

Make a script of that and time it.

To do the read, first echo 3 > /proc/sys/vm/drop_caches; you have to do this as root and you can't use sudo.

I get ~17 seconds to write 100 MiB and ~6 to read it back with a nothing special card. If I leave out the sync and the flush, I get much, much higher speeds, 80+ MB/s. This is a meaningful number depending on what you are doing, but it is not the actual speed of I/O to the device.

You won't get faster than 20-25 MB/s read from the SD card (this is a limitation of the reader) and a pretty good write speed would be half that, some cards may go higher. You could get a bit more from USB, maybe as high as 30 MB/s. Anybody who claims to be doing more than that with a Pi is delusional.

The next question is can I run both commands simultaneously?

Since the read will almost always be significantly faster than the write doing this with the same file may not work and would be pointless if it did. Doing it with separate files is of debatable value unless you have some particular condition you are testing.

1

I have used iozone for benchmarking SD cards on the Pi. Here is an article about that: http://www.jeffgeerling.com/blogs/jeff-geerling/raspberry-pi-microsd-card

I have benched the Samsung EVO+ and it is the fastest of the cards I own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.