13

I was writing to an SD card this evening from a Mac Book Air internal card reader, and the performance reported was 1.4 MB/sec. I later read tested it on the Raspberry Pi and got 20 MB/sec. It is a class 6 card and neither of these figures sound realistic!

I am using dd for my tests. Results of identical tests of both read and write on both computers:

Raspberry Pi: Read 20 MB/sec.  Write 11 MB/sec...
Air:                 Read   3 MB/sec.  Write  1.4 MB/sec

Using these commands:

Write test:

sudo dd if=/dev/zero of=/dev/mmcblk0p3 bs=1M count=400

Read test:

sudo dd of=/dev/null if=/dev/mmcblk0p3 bs=1M count=400

This indicates that the perceived anomaly was in fact lousy performance of the integrated Mac Book Air SD card reader! It makes for very slow image creation.

Peter Mortensen
  • 1,984
  • 2
  • 14
  • 17
ScrollerBlaster
  • 479
  • 1
  • 5
  • 12
  • Sandisk claims that class 6 cards have a read speed of 20MBps, although Kingston claims 15MBps is the read speed for class 6 cards. I don't know if the Mac Book has an integrated SD card reader or not. But for external (USB 2.0) versions the quality of the SD card reader (what chips used etc) is also of importance of the overall performance. But reading always is faster with these devices then writing. – ikku Oct 15 '12 at 23:31
  • Thanks. It is integrated. Pretty good read performance. Really bad write performance. – ScrollerBlaster Oct 16 '12 at 06:37

4 Answers4

11

To get the best speed out of your MacBook's SD slot, you need to use a 'raw disk' device.

This is a SanDisk Ultra Class 10 card:

~/Desktop/rpi $ sudo dd if=2012-12-16-wheezy-raspbian.img of=/dev/disk1 bs=8m
231+1 records in
231+1 records out
1939865600 bytes transferred in 1076.078932 secs (1802717 bytes/sec)

Compare this to using /dev/rdisk1 instead of /dev/disk1

~/Desktop/rpi $ sudo dd if=2012-12-16-wheezy-raspbian.img of=/dev/rdisk1 bs=1m
1850+0 records in
1850+0 records out
1939865600 bytes transferred in 129.712100 secs (14955163 bytes/sec)

1.8MB/s compared to 14.9MB/s - almost 10x the improvement!

Bert
  • 832
  • 7
  • 10
  • what is difference between disk and rdisk ? – valentt Dec 31 '12 at 08:44
  • "They are closer to the physical disk than the buffer cache. /dev/disk nodes, on the other hand, are buffered block-special devices and are used primarily by the kernel's filesystem code." - Check the `hidutil` man page for more information. – Bert Dec 31 '12 at 18:02
  • 2
    This is potentially misleading since the block size changed between the two tests. – Nick Aug 10 '13 at 12:53
  • FWIW: I changed the block size to 1m and the device /dev/rdisk1 and my write speed went from ~1.75MB/sec to ~11.4MB/sec with a class 10 card. – Gardner Bickford Feb 11 '14 at 06:54
  • I can confirm this - writing an image for my RPi SD card is 20x faster when I use rdisk2. I kept the block size constant for this (4m). Using /dev/disk2, gdd writes at 197 kB/s. Using /dev/rdisk2, it writes at 10.6 MB/s – judepereira Jul 12 '18 at 20:02
6

SD card speed class rating specifies minimal read/write performance the card should have while recording video. Class number is the lower speed limit in MB/s you should get when using the card.

Keep in mind, however, that reading from card is usually much simpler (and thus faster) than writing. This is why usual class 6 card will have 6MB/s write speed by 15-20 MB/s read speed (but only 6MB/s is warranted).

Speed of reading/writing can be limited not only by a card but also by a lot of different factors, both hardware and software. Especially it can be limited by some problems with card reader/writer.

So in your situation, it seems that your card has really bad performance on your Mac Book Air while it has proper (and realistic) performance on RaspberryPi. We can't be sure, however, since you tested write speed on Mac Book and read speed on RaspberryPi and as I mentioned earlier, they are not comparable. It's also hard to comment on why you're getting such results since you didn't specify how are you testing those speeds.

Krzysztof Adamski
  • 9,585
  • 1
  • 36
  • 53
  • I need to test read and write on both platforms. I'm using `dd` – ScrollerBlaster Oct 16 '12 at 08:49
  • @ScrollerBlaster: You can't compare read to write speed against each other. Similar, when testing just about anything, a good rule of thumb is to change only one thing at a time. But you changed everything (OS, host computer, card reader) but one thing (sd card) in your setup, so that won't give you meaningful results. – Krzysztof Adamski Oct 16 '12 at 09:16
  • I have said I will compare read vs write on the same OS. Do you have a problem with that approach? – ScrollerBlaster Oct 16 '12 at 09:17
  • @ScrollerBlaster: No, not at all. I just wanted to be clear on what I mean by saying they are not comparable in my answer. Remember that this answer is not only for you but for all the other people that may have similar problem in future so I try to make my advice as generic as possible. – Krzysztof Adamski Oct 16 '12 at 09:29
  • When you pointed out in your post that my test was not comparing apples and oranges, this was a very valid point. In my 1st comment I stated I would redo the test, meaning I would redo read and write on both platforms. Thereafter your subsequent advice to me was unnecessary. Going forward, any conclusions about Air versus PI are still premature. The most relevant test will be a read vs write test on the PI, given that this is a PI forum. If you have `dd` commands to do a safe write test I will use them! – ScrollerBlaster Oct 16 '12 at 10:05
  • @ScrollerBlaster: I apologize if my comment was somehow offensive for you. But back to your question about dd, unfortunately there is no easy way you could safely (i.e. not overwriting the card content) test card write speed. You could do this by only writing to a file, but that's not ideal since filesystem speed may have an impact. The best thing you could do is to create additional empty partition on the card and test write speed on this partition only. – Krzysztof Adamski Oct 16 '12 at 10:13
  • Yep, I was thinking I'm going to have to write to the 2nd empty half of it. I hope to return to this test so we can come to a conclusion but it's my first day with the PI so the issues are mounting up! Later and thanks! – ScrollerBlaster Oct 16 '12 at 10:21
1

You can also use these commands for benchmarking without influence of cache that gets loaded into RAM:

read speed benchmark: $ sudo dd if=/dev/sdX1 of=/dev/zero bs=1M count=400 iflag=direct

write speed benchmark : $ sudo dd if=/dev/zero of=/dev/sdX1 bs=1M count=400 skip=1000 oflag=direct

Make sure to always use oflag=direct and iflag=direct when respectively doing write and read benchmark test, or you risk toi get results that actually are filecache write and read timings.

valentt
  • 1,295
  • 3
  • 15
  • 21
0

On my 2015 MBP running OSX 10.11.5, I received the following write speeds while using dd:

when writing to /dev/disk: 1.80 MB/s when writing to /dev/rdisk: 12.80 MB/s