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.   

Monday, August 27, 2012

Beaded bowl surfaces

Hexagons side by side forms a flat surface, with zero curvature. Reading Make Magazine's Math Monday, I learned that a pentagon among the hexagons makes the surface  curvature positive, like the surface of a sphere. A heptagon does the opposite - it creates a saddle surface, which has a negative curvature.

Here, I've built the same bowl-shaped trial surface from white glass beads and from Magnetic spheres. The surface is formed from hexagons, with a pentagon in each 'corner', to make the surface curve.

In an earlier post, I used only pentagons, which shapes the surface into a sphere.

Monday, August 20, 2012

Beads from scraps

Using leftover Fimo clay from the previous two projects, the instruction beads and the red flower cane, I made some sets of mixed striped beads. Below are the basic steps: rolling out the different-colored scrap pieces and bunching them together, then rolling out the bunch, cutting up and re-bunching and so on, twisting slightly, and the stripes get thinner.

When I was happy with the stripes, I cut the roll into pieces and formed round beads. Part of the roll I made thinner, and squared it before cutting, creating small elongated square beads.

Above are also shown some darker beads made with a similar method, with scraps from the instruction beads.

This single bead is made from leftovers of the petal in the red flower - the bead actually shows the pink-and-orange stripes which were supposed to show in the red flower as well, but the pattern got way to small when reducing...

Friday, August 17, 2012

Trying out the Raspberry Pi

I am a happy owner of a Raspberry Pi - a tiny (and really cheap) computer, capable of running Linux. Now I too am a part of the Raspberry revolution. I am just starting to try it out, but I already got our platform game running on it! More on the game will follow in a later post, first some notes on the Pi itself.

I decided to try out the Raspbian flavor of Linux on the Pi. I chose this for the hardware floating point support, and since the Raspberry Pi foundation recommends it.

I currently don't have an USB keyboard, so I hoped to access the Pi over the network with ssh. Luckily, Raspbian is set up with an ssh server running. The only things required is to make sure that the Pi gets an IP address when it boots, and then find out which IP it got so that you can ssh to it.

I connected the Pi to a laptop running ubuntu, and tried to use the network manager on the laptop to give the Pi an IP address with DHCP when it boots. Sadly, this did not succeed. Apparently the laptop Ethernet interface stays "down" as long as nothing is connected to it (the Pi is off), and the Pi got no IP address when it booted.
Fortunately it was easy setting up a DHCP server on the laptop manually:
1) Turn the network manager off, so it does not get in the way
2) sudo ifconfig eth0 #enable eth0, give it an IP address
3) sudo udhcpd -f
4) boot the Pi, wait a while.
5) udhcpd prints out the IP address it offers
6) ssh to the address. User name pi, password raspberry.

If you have the Pi connected to a TV or monitor, you will see the Pi printing some messages while it boots, and then launch the raspi-config program.  Without a keyboard raspi-config is not usable, but you can still access the Pi with ssh. Raspi-config seems to start automatically at each boot, until you have completed it once.  It can be run from a terminal at any time.  If one wants the Pi connected to the internet, some more networking is needed than what I describe above. A router would probably be the most convenient solution. I have had success with Windows "internet connection sharing".

EDIT: When trying to share an internet connection from an Ubuntu laptop to the Pi, this bug bit me. After the suggested work-around, sudo killall dnsmasq on the laptop, I could boot the Pi and it got an IP address. Then the next problem appears: how to find the IP address of the Pi? The Pi prints it on the TV or screen during boot. If no screen is connected one can use the nmap tool:
nmap -sP
this IP range being the one that Network Manager seems to offer. -sP tells nmap to ping all the hosts in the given range.

I have a PAL TV connected to the Pi. PAL needs a setting in the configuration file config.txt, located on the boot partition (the small, FAT one) on the SD card. Either edit this file on the card and uncomment the line
or use raspi-config on the Pi.

In this discussion and here I found interesting observations about which SD cards work well with the Pi. Apparently the fancy and expensive cards, called Class 10, are not the best since they are highly optimized for sequential reads and writes. This is good for photography but not for running Linux of the card. For this application, the speed of short random reads and writes is much more important, and these speeds may well be much better on cheaper cards of lower class. I got an 8 Gb Class 4 Sandisk SDHC card from the local Media Markt for 8 €. It seems to work well, but I have no serious benchmarks yet.

Wednesday, August 15, 2012

Red flower cane beads

A flower cane made from the magenta and orange Fimo polymer clay from this set. The center is made of scraps from that checkered cane. First, I made some simple flat round beads by cutting slices from the reduced cane.

I then reduced the cane further, and put thin slices on a white clay sphere, made from half a Fimo strip. Twelve 1 cm slices fit covered the sphere nicely, in a dodecahedral formation.

Quarter-strip spheres were covered by six slices (cubic formation) and half-strip cylinders carried two rows of four slices. Leftover flower canes I stacked and rolled until they were tiny, wrapped them in white and cut into small flat beads.

Monday, August 13, 2012

Checkered instruction beads

Checkered beads and a Fimo set.
A friend of mine bought a Fimo set, containing magenta, orange, black and white clay. We made some square checkered beads, following the instructions in the box - except for tweaking the colors a tiny bit: we mixed 1:5 white into the orange and magenta, to create a larger contrast for the black.

Thursday, August 9, 2012

Bubbles III

bubbles in glasses
A beautiful phenomenon discovered while doing the dishes.
Newer Older Home
Related Posts Plugin for WordPress, Blogger...