Timely tips for speeding up your Raspberry Pi

Data Sink

As a boot medium, the Rasp Pi requires an SD card. The current Raspbian Debian image requires less than 2GB of space; cards with more capacity thus have enough space for application data. Nevertheless, an SD card is not really a device of choice for mass storage. This is, first and foremost, because of the read and write speed. SD cards are organized by speed classes (a class 10 card should thus have a throughput of at least 10MBps), but these values are fairly theoretical in nature and can really only be achieved in special situations. In particular, SD cards are designed for writing images and movies – that is, large amounts of contiguous data – sequentially.

The I/O performance of an SD card can be measured with the iostat command from the sysstat package. A special module also records I/O metrics for Ganglia; however, it does not work in the current Debian image on the Rasp Pi. When called without parameters, iostat outputs the throughput values since the last boot. A call to iostat t **d **5 **10 generates 10 outputs every five seconds. Alternatively, you could use the bonnie++ benchmark program:

$ bonnie++ -d test_directory -m Raspi -f -q >> bonnie.csv

A test started in this way runs for around 12 minutes. Bonnie++ writes the results to the console and also to a CSV file. Note that Bonnie expects a writable directory below test_directory.

My original scenario of an ownCloud instance on the Rasp Pi basically doesn't match the preferred access pattern for SD cards: A database runs in the background; thus, loading an ICS file packed with calendar data will paralyze the I/O system (Figure 5). This is not a typical scenario, and creating individual appointments or contacts is a reasonably smooth experience. Also, synchronizing large files (like images for the ownCloud Gallery) works well. However, some other storage device would be better.

Figure 5: A high load on a slow I/O system slows down the whole system, regardless of the CPU.

As an alternative to the SD card, you could go for a USB hard drive, but then the problems begin. Hard drives without an external power supply consume too much power, which generally leads to a total crash of the Rasp Pi when you plug it in. The first revision of the Rasp Pi board even had a 140mAh fuse upstream of the USB ports: this is so far below the USB specification that it makes it impossible to connect other USB peripherals, such as wireless dongles.

If the external hard drive does not have its own power supply, you can use an active USB hub – but again, there be dragons. If a powered USB hub acts strictly in line with the specification, it stubbornly supplies 500mAh per port. Many hard drives need more power for a short time during start-up. Also, USB hubs are mainly made on the cheap. Online sources report numerous problems, from mechanical issues to burning power supplies. I am not aware of an active USB hub designed explicitly for continuous operation. "Upgrading" the Rasp Pi with an active hub and a hard disk is not just esthetically questionable. On the other hand, small NAS devices do not consume much more power, are only slightly more expensive, and save you cable clutter in the bargain.

The final alternative is USB sticks, which have access patterns similar to SD cards and thus lead to some of the same problems I encountered in my ownCloud test scenario. Also, most manufacturers do not disclose the inner structure of the sticks, so it remains unclear how they control the flash chip.

One of my configurations shows you just how sensitively the Rasp Pi interacts with USB devices: I connected an mSATA SSD with an external mSATA USB3 case that became available. Doing this while the Pi was running made it crash reproducibly. However, if the SSD was plugged in before booting, the system started and ran with no problems. In this – admittedly overpriced – combination, the system remains compact and provides sufficient I/O performance, even if the SSD possibilities are not exploited by the USB2 interface on the Rasp Pi.

Conclusions

If you are willing to invest a little time, you can eke out between 10 and 50 percent more power from your Raspberry Pi. In many application scenarios, this constitutes the subjective difference between "too slow" and "fast enough." Of course, other platforms offer more performance and less bother, but exploring borders is part of the fun of tinkering with the Rasp Pi.

If the performance is still not fast enough despite tuning, there is another potential remedy: Rasp Pi-like small computers with better equipment are currently sprouting like mushrooms from the ground. I was unable to find a computer in this category that offered both significantly more computing power and better I/O performance, but it's probably only a matter of time until faster solutions become available. On the other hand, the communities for these alternative boards are much smaller – and the hardware and distribution support is accordingly less active. In real life, limited support might turn out to be a far bigger drawback than the Rasp Pi's admittedly limited performance.

Der Autor

Bernhard Bablok works for Allianz Managed Operations & Services SE as an SAP HR developer. When he's not listening to music, riding his bike, or walking, he focuses on topics relating to Linux and object orientation. You can reach him at mailto:mail@bablokb.de.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content