Author Topic: Speed of SD and CF cards (writes)  (Read 2578 times)

derekp

  • Full Member
  • ***
  • Posts: 154
    • View Profile
Speed of SD and CF cards (writes)
« on: February 02, 2004, 11:16:44 pm »
Ok, I\'ve just had an \"enlightenment\", thought I\'d share with everyone.
As we all know, writing out data to an SD or CF card is slow.  Example, untaring a bunch of files typically takes about a second or so per file to write out regardless of size.
Anyhow, if you mount up an SD card using the -o async option, this speeds it up a slight amount, but not by much.  However, I noticed back a while ago that if you create an image file on your flash media, then mount that image up via the loopback driver, then writes to that mount point go blindingly fast.  What is happening is that the loop driver filters out redundant writes (i.e., to the inode table), so that only the last one takes effect.  You can also mount your entire SD (or CF) card via the loopback driver (i.e., mount -oloop /dev/mmcda1 /mnt/card), and get the same fast write speed.  Now if you write out a bunch of data, it still will take a few seconds to sync up, but overall the write is still faster.

Now for the problem.  If you mount the SD as /home, or use your SD as root, and use the \"-o loop,async\" option, then you will frequently get a lockup on suspend.  I figure that the SD card was getting shut down by apm while some other process still needed it, but it would only happen for me when using both sd as /home and sd mounted with -oloop,async.  Also, others have reported that with certain brands of SD cards, they would get lockups on suspend using my home-on-sd technique.

And, the revelation...
I was looking through the kernel config options in the 2.4.18 Sharp linux tree, and noticed that under filesystem configuration, there was an option turned on calld \"Syncronos File I/O\".  This option isn\'t on a normal 2.4.18 kernel tree, and didn\'t have a doc page for it.  So, I turned it off, recompiled the kernel and reflashed my Zaurus.  And guess what?  Now, mount -oasync has the expected effect.  It makes the file operations much faster than without it, without having to use the loopback driver trick mentioned above.  And, best of all, no more lockups on suspend when using the SD card as /home.  I can even use the SD as the root filesystem (/) for OpenZaurus (using a dual-boot technique) without any issue, and it\'s FAST.  Well, not quite as fast as ram or a hard disk, but many times faster than before.

Summary:
SD is slow writes, with async flag still mostly slow, mounting via loopback driver and async is very fast but unstable, mounting async and with syncronous file i/o option in kernel turned off is just as fast as the loopback mount trick, but is very stable.

BTW, I love the new OpenZaurus 3.3.5.  I\'m not quiet ready to commit it to my 5500\'s flash rom yet, but what I\'ve seen so far dual-booting from the SD card (and now with the sync option turned off in the kernel), it rocks.