2

Following these instructions: http://elinux.org/RPi_SD_cards#Performance

I've got a 4GB SD card with Raspbian Wheezy.

Running sync; time dd if=/dev/zero of=~/test.tmp bs=500K count=1024; time sync gave me an error due to insufficent storage and reported a very low write speed (~2 MB/s)

I decreased the count to 128 ad then the write speed shot up to 34.4 MB/s.

Regardless of the count, when reading (with dd if=~/test.tmp of=/dev/null bs=500K count=1024) dd reports are read speed of 171 MB/s.

Is that normal? Everything I saw online seemed to suggest the SD Port topped out around 20 MB/s.

EDIT: As per @user2813274's comment, /dev/null and /dev/zero are special cases.

When I tried dd'ing a normal file with dd if=~/my_file of=~/test.tmp bs=500k count=128 dd reported a transfer speed of 31.0 MB/s.

31.0 MB/s is still substantially larger than the apparent maximum of 23.3 MB/s (link above) on a SanDisk Extreme III Class 10 SDHC card. I'm using the SD card that came with the Pi.

But, when I remove the count=1024 flag for dd, dd copies the entire file, instead of just a portion of it, and then it reports a variable transfer speed between 5.0 - 7.0 MB/s.

1

1 Answer 1

1

It all comes down to caching.

First, you only create a file of ~64 MB, so if you create that file and then immediately read from it, (parts of) it will still be in the kernel buffer. That explains the high speed of 171MB. To be absolutely sure nothing is left in the buffer, reboot the Pi.

The same could have happened with your 'dd' after your edit; again you are using a small file and parts of ~/my_file might still be in memory, and the kernel supports writeback so dd will return before the file is actually written to the card, thus skewing the results.

Your final command, copying the whole file, shows a normal speed simply because there is more data than fits in the kernel buffer. Variations are caused by what's left in the buffer, other processes accessing the card and the actual speed of the SD card.

5
  • I would have used a larger file, but I only had a 4GB SD card and I didn't have the space to use a larger file. Would that have [substantially] affected the speeds?
    – zaxvo
    Aug 19, 2014 at 17:27
  • Yes, it would have. Reading data would top out at the SD reading speed, writing at SD writing speed (minus a bit of kernel overhead, of course). Combining the two operations you might end up somewhere near writing speed, as that is the bottleneck.
    – JvO
    Aug 19, 2014 at 17:35
  • But since the file I was using was 64 MB, and the write speed is under 10 MB/s, surely going from a 64 MB to, say, a 1 GB file wouldn't affect the average write speed too much, right? Or am I missing something?
    – zaxvo
    Aug 19, 2014 at 17:37
  • Well, the Linux kernel has a disk cache. So if the file you manipulate fits inside the cache your results will be skewed. Use the free command and see how big your buffers and cached data size are.
    – JvO
    Aug 19, 2014 at 17:43
  • >400 MB free...so a 64 MB file is definitely not large enough. Makes sense, thanks for your help.
    – zaxvo
    Aug 19, 2014 at 18:53

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.