Dumb then, smart nowPublication date: 8 February 2007. Last modified 03-Dec-2011.
Vista, schmista. It's time to put some swap space on Flash memory.
But, as a correspondent asked me just the other day, Is It Not Written that it is dumb to use Flash memory for scratch "disk" purposes? What're Microsoft doing putting a cache of the system pagefile on a lousy USB key?
ReadyBoost doesn't actually break any of the old rules, because it's not being mean to the Flash memory. But even if it were, it'd still probably be OK, because the same mathematics that made it a bad idea to put a swap file on Flash a few years ago now makes it quite sensible.
The weakness of Flash memory - especially the NAND stuff that's used in all high capacity storage devices - is writes. Flash is not an ordinary read/write medium. You can't just write to any chunk of the device you like. That's how it looks to the operating system, but what's actually going on is that first, the device has to erase enough sectors to fit the data, and sectors are quite large - 128 kilobytes, or something. Only after the sector's been blanked can the data be written.
There's a limit to the number of erase cycles Flash memory cells will survive. The reason why ordinary scratch disk used to be a bad idea for Flash was, apart from the fact that Flash devices weren't very fast, that the constant activity of a swap file could push the memory to a hundred thousand or more write cycles surprisingly quickly. This was despite firmware that takes care of "wear levelling", making sure new data always goes to the sectors that've had the fewest erase cycles.
Nowadays, though, you can get large, cheap, significantly-faster-than-they-used-to-be Flash devices. And that has changed things.
Say you've got a Flash device that really and truly only can handle the oft-quoted 100,000 erase cycles. Quality Flash should actually be better than that these days, though some of it is apparently rather worse.
If the device is a decent size, though, it can take a long time to make it to even 50,000 cycles.
If your Flash device is "4Gb" with a formatted capacity of 3900Mb, and you do nothing but write to it as fast as you can - at, say, 30Mb/s - you'll still only be able to replace its entire contents every 130 seconds. At that rate, it'll take you 150 days to hit 100,000 cycles.
Since even scratch disk use doesn't come close to writing non-stop, it's quite possible that a humble thumb drive could, in this situation, last two or three years as a swap device on a Windows system.
Older Flash devices were slower, which made them less useful as scratch disks all by itself. But they were also a lot smaller, and more likely to genuinely only support 100,000 erases, if not fewer.
Those factors made the calculation less favourable. A "128Mb" (formatted 125Mb) device at 10Mb/s will be completely overwritten every 12.5 seconds, giving you only a couple of weeks before you hit 100,000 cycles. In real world use, I'd be surprised if that lasted a year as a scratch disk. And a 10Mb/s swap file ain't exciting anyway.
Reading is no problem at all for Flash. Reading is considerably faster than writing, there's near-zero seek speed (which, along with a minimum speed specification for ReadyBoost devices, is the main reason why ReadyBoost works). And reading doesn't hurt the memory - you can do all the reads you want.
So if you acknowledge the weaknesses of Flash and deliberately avoid hammering it with erase/write cycles, you can get considerable value from any vaguely recent Flash, no matter how fragile it is. It can last easily as long as a consumer hard drive.
Seldom-changed system files can go on the Flash disk, as indeed can chunks of the pagefile - presumably those chunks that're themselves full of operating system information, not user data that's changing all the time.
If you overwrite the entire contents of a 100,000-cycle device only every hour - which I'll bet you ReadyBoost doesn't come close to doing - it'll last for more than eleven years!
Advanced Flash devices - proper Solid State Disks, not cheap thumb drives - have onboard battery-backed normal-RAM caching, and lots of spare blocks to remap bad blocks onto. They can, right now, work just fine for indiscriminate long term "enterprise" scratch disk use, and they're well suited to other write-heavy tasks as well.
But thumb drives are now so cheap that it'll be trivial to replace your several-gigabyte Flash cache drive if it fails.
If your cache/swap/whatever Flash fails, of course, then Bad Things can happen. If the swap file is yanked out from under your operating system - by a hardware failure, or just because you've unplugged the swap disk - your computer will instantly crash hard, even if it could otherwise have dealt elegantly with the loss of that device.
Vista takes this into account, and shouldn't do anything drastic if you unplug your ReadyBoost USB key, even if you do it while the activity light's flashing. (Not that I've tried it myself.)
If you decide to put swap space on an unpluggable device, though, woe betide you if you unplug it.
That aside, though, it's definitely time to give this stuff a try.
Forget Vista - let's Flash-enhance earlier Windows versions, or Mac OS or Linux for that matter.
There are two ways to connect Flash memory to your computer. Via a hot-swappable interface (USB or FireWire), or via an internal hard disk interface.
That second strategy, at the moment, still means old-fashioned ribbon-cable Parallel ATA (PATA). CompactFlash cards all have an ATA ("IDE") interface built into them; all you have to do is connect them to a pin adapter, and they can then plug straight into any regular ATA cable. I reviewed such an adapter years ago here; nowadays somewhat improved versions are dirt cheap on eBay.
Back when I wrote that review, the best ATA mode CF cards supported was the slow, high-CPU-use PIO 1. This made them useless for system-drive purposes in performance computers, even then; not nearly enough transfer rate, far too much CPU utilisation. Even if they'd supported billions of read cycles, putting a swap file on one of them would have been a painful experience.
Nowadays, though, CompactFlash cards support DMA modes, just like hard drives. Not all cards support DMA, and there are still compatibility issues between particular cards and particular motherboards, especially if the CompactFlash card isn't the only device on the PATA cable. But DMA is at least possible these days.
(After I put this page up, a reader reminded me about CompactFlash cards in cheap PCMCIA adapters, which often-but-not-always also use DMA mode, and so are very suitable for doing this same trick on a laptop. Putting your swap on a 1Gb CF card in a PCMCIA adapter could significantly accelerate an old laptop that can't accept enough RAM to make Win2000/XP run smoothly. This is, incidentally, exactly analogous to the reason why people who're running old mainframes that can't accept tons of RAM buy very expensive Solid State Disks.)
Plug a DMA CompactFlash card in via PATA and it's just a hard drive, as far as the computer's concerned. You can do anything with it that you can do with any other hard drive. You could use it as your system drive, if you liked; you're not going to install a whole lot of DVD games on even an 8Gb CompactFlash card, but given the improved durability of big Flash devices, it's no longer completely nuts to make a WinXP computer that boots from a memory card.
You could even, if you were feeling kinky, make a RAID array out of multiple cards, to give more speed and/or data redundancy.
Windows artificially restricts users' ability to make RAID arrays, for a number of reasons.
First up is the artificial marketing restriction that makes non-"Server" versions of Windows unable to create proper RAID arrays. Windows XP Professional, for instance, can make mirror and stripe sets, but is unable to do good old RAID 5, your standard best-of-both-worlds RAID level, without a simple, but scary, hack.
(I'm damned if I can figure out what version of Vista you have to buy to get proper software RAID. Possibly Smoky Bacon.)
Second up, though, is that Windows won't let you make software RAID arrays on "removable" devices, which includes USB drives of all kinds (and FireWire devices as well, but you can work around that).
(Well, OK, maybe if you install some odd driver or other, but that looks too much like hard work to me.)
Windows will, however, let you put swap file(s) anywhere you like, including on removable media. This is much more dangerous than making a RAID array out of removable devices, since Windows absolutely will fall in a screaming heap if you unplug a swap drive. But strange are the ways of Microsoft.
So here are some swap-on-Flash options for WinXP users, in order of complexity and expense.
1: Plug in a modern, high capacity, USB 2.0 Flash storage device (a thumb drive, a memory card in a reader, whatever), and put a paging file on it (in WinXP, Control Panel -> System Advanced -> Performance -> Advanced -> Change).
And then watch as it doesn't work.
I originally thought that this not only could but did work, as Windows is perfectly happy to let you follow the above steps, and the virtual memory settings show a paging file assigned to the USB drive after you reboot. But there won't actually be a paging file on the USB drive, because USB devices are initialised too late in the boot process for one to be created.
(Yes, a lot of modern PCs can be coaxed into booting from USB devices. But that doesn't mean you can boot from a hard disk and initialise USB storage devices then as well.)
This isn't a super-exciting idea anyway, since cheap Flash hasn't yet made it to the transfer speed that hard drives were managing in the year 2000. But on a single-hard-drive system with a decent amount of RAM you might still reap a noticeable benefit, by reducing thrashing when Windows wants to access the swap file and files on the hard drive at the same time.
Except you won't, because it won't work, dammit. You can assign the USB device as a Photoshop scratch disk or something if you want to, but you can't put proper system swap on it.
2: Connect a CompactFlash card with an adapter to a PATA cable, and use it that way. This absolutely positively does work, since PATA-adapted CompactFlash cards are just another ATA device as far as the computer's concerned, and are initialised on boot like any other drive. The adapters are also down to a few US bucks each, delivered, these days. So that's not much of an obstacle.
Doing the trick this way also gives you a nice standard hard-to-accidentally-unplug internal device that'll be a bit faster than the same thing connected via USB, though probably not enough that you'd notice.
Incidentally, hooking up a CF card this way is now a very workable way to make a no-hard-drive computer, especially if you're happy to run an older Windows flavour. It's also an absolutely excellent way, old schoolers, to make a silent and very reliable "hard disk" Amiga system, provided you've got an Amiga with an ATA controller in it, like the old A1200. The "A1200HD" versions came with an expensive 20 or 40 megabyte hard drive; you can stick a gigabyte in one of them now for peanuts. (But don't exceed 2Gb per partition unless you're feeling lucky.)
Any old CompactFlash card should be fine for an Amiga; the Commodore ATA controller didn't support DMA anyway. And even if you use an old small card, there'll be no problems with swap files wearing it out, since AmigaDOS has no virtual memory.
Note, however, that the A1200 and A600 used 2.5 inch laptop drives, with the corresponding smaller 44 pin ATA connector. So you'll need a CompactFlash adapter with a 44 pin connector on it, or a separate 40-to-44 pin adapter.
OK, back to the present day.
3: Use a bunch of ATA-adapted CompactFlash cards, and RAID 'em. Software RAID in Linux, Mac OS or a suitable version of Windows; if you've only got XP Pro, you can still make a striped (RAID 0) volume out of ATA-adapted cards, which should work perfectly well for scratch disk purposes, and give a decent speed increase.
Or you could use hybrid hardware/software RAID on a cheap PATA controller card (cheap Promise- and Highpoint-chipset cards pretend to be doing proper hardware RAID, but most of the work is actually done by the host computer's CPU, and they only support RAID 0+1 at best, anyway), or proper hardware RAID on a real ATA RAID card.
The simpler versions of this can be very cheap to set up. You can get two-card CF-to-ATA adapters for only slightly more than the price of the single-card versions; this eBay dealer has them for less than $US6.50 delivered.
This dealer has the slightly cheaper single-card versions, in case you're interested, and also stocks RAID-capable two-socket PATA controller cards, which... probably... work fine with cheap CompactFlash cards in adapters, for $US14.98 delivered.
If you've got a typical modern PC with one SATA hard drive and one PATA optical drive, you'll have three spots open for adapted CF cards without buying a new controller.
After that, all you need are your CompactFlash cards, which you may have sitting around already - though if all you've got is the 8 or 16Mb card that came with your digital camera, I suggest you save it for that Amiga project.
CF cards are cheap as chips on eBay at the moment, of course, but I would if I were you steer clear of very cheap "SanDisk" CF cards currently available, because most if not all of them are fakes.
Minor fakes are a cheaper brand of card with fake SanDisk stickers, which may well work perfectly well. Major fakes look like, say, a 2Gb card, but don't actually have that much storage, leading to entertaining errors when your write operations fall off the end of the memory that's actually there.
Provided your CompactFlash cards are real, though, this setup is not only a fun exercise in nerdery, but a genuine way to get some more performance out of your computer, not to mention possibly save wear and tear on your magnetic drives.
You can put Photoshop and other scratch files and directories on the Flash memory too, if you like. Or, as I said, even use an adapted CF card as your boot device. If it's just one adapted CF card (or USB key) then you shouldn't expect exciting performance from it, but four DMA CF cards in a stripeset should chug along pretty speedily.
Tell me how you get on!