ReadyBoost for Linux?

Lifehacker has an interesting story about making your own ReadyBoost for Linux (and aptly calling it SwapBoost) and even if the benefit is questionable this is still something I would actually like to see — it’s simply an innovative take on a cheap-as-chips and common-as-dirt gadget commodity.

On Vista ReadyBoost does make a difference — for low memory systems. In my own brief testing ReadyBoost does nothing (as you’d expect) for a 2G and very little for a 1G system unless under heavy load but 512M and below it has a reasonable benefit. As a result its market is definitely the road warrior with a possibly less-memory-than-the-desktop laptop and a source of high capacity USB keys.

I still think it’s cool though and when I first installed Vista I wanted to see if I could see how it was implemented and intercept any data on it. If you remove a ReadyBoost USB key while in use and boot to Linux you can mount it using the UDF filesystem and you’ll get to see a container file which Vista uses to store the temporary data — it’s basically a loopback device. But you can’t peek inside — well you can but it’s encrypted (as it needs to be considering it pages from memory and there could be sensitive data).

While the Lifehacker SwapBoost script is commendable for its goal it’s quite a different thing — it’s just creating another swap partition on the USB device and adding it to the swap pool. Which given Linux’s excellent memory management is unlikely to see use. On my 2G system even running a plethora of beefy apps and compiling in the background in Gentoo my swap has never been touched. When I used to have 1G I could count on one hand the number of times I saw it grow. This is quite a bit different to Windows where even menial tasks seem to make use of swap.

Additionally the default I/O schedulers for the Linux kernel are Anticipatory and CFQ which are specifically designed and optimised with hard drives in mind (Anticipatory actually tries to take into account drive heads to optimise seeking). Flash media like a USB stick doesn’t suffer the problem of variable seek times across the diameter of a disk so ideally any ReadyBoost implementation for Linux would use the NOOP scheduler which is perfect precisely for this type of media.

Regardless of your take on Microsoft you have to commend it for the design of ReadyBoost — it mirrors data going to and from drives so the key can be removed at any time with no loss (if you removed your SwapBoost with data on it it’s gone) it diverts only small writes to the ReadyBoost device — which maximises the performance of both your storage devices (hard drives = high throughput high latency; USB keys = low throughput low latency) and of course it encrypts the data on the fly because you don’t want others peeking at your information should a key in use get stolen.

So ideally a proper attempt at ReadyBoost for Linux would need to take this these features as well maximising performance using the NOOP scheduler for it into account. Yeah it’s a niche feature but as before I still think it’s a clever use of an abundant media in our lives today and for that its commendable.


USB keys: Is there anything they can’t do?