Things You Never Knew About Flash Drives
by Robin Harris
Flash drives only look like disks. In fact, nothing works the way you'd think. Flash is really different from magnetic recording, and those differences have a big impact on flash drive performance. How well vendors manage flash oddities has a huge impact on performance and even drive lifespan.
The five weirdest things about flash drivesI've started from the bottom up -- the bits -- to present flash weirdness logically. And what it means to users of flash drives.
- Flash drives can only write zeros. Every write must be preceded by an erase because
the only way to write a one is to erase first, which writes all ones. Every write means
an erase followed by a write, which slows performance.
To write a page you must first erase the entire block. NAND flash, the most common kind, is divided into blocks -- typically 128 KB -- and each block is divided into pages -- typically 2 KB. To write a new page, the entire 128 KB block must be copied first -- less pages due for rewriting -- and the entire block rewritten.
This impacts performance even more. You may just need to write 2 KB, but the drive has to erase 128 KB and then write 128 KB.
This makes small random writes very slow -- even slower than notebook disk drive writes. And since today's PC/Mac file systems perform lots of small random writes, you won't see all the performance flash drives promise after you boot up.
There are no random writes in a block. Each block write starts with page 0 and proceeds in order to the 64th block. This is great for the blazing sequential write speeds that vendors happily quote, but it means that small random write performance is pretty awful.
Block size is a tradeoff, not a given. As flash chip capacities grow, keeping block size constant means more blocks to manage. For example, if flash drives were divided into 512 byte blocks, a 64 GB flash drive's block table would require 128 million entries and about 384 MB of storage. With a 128 KB block, the table size is a more manageable 524,352 entries and less than 2 MB of storage.
This means that vendors have the opportunity to improve flash drive performance through smaller block sizes and better block management techniques. They'll cost more to implement, but you should get more too.
The most important piece of a flash drive is the translation layer. This software takes the underlying weirdness of flash and makes it look like a disk. The translation layer is unique to each vendor and none of them are public. Each makes assumptions that can throttle or help performance under certain workloads.
What workloads? Sorry, you'll have to figure that out for yourself. The bottom line is that flash drive write performance will be all over the map as engineers try to optimize for a wide range of workloads.
The Storage Bits take
Flash drives fast access times are a compelling advantage over magnetic disks. Flash prices are dropping faster than disk prices, so the cost differential is dropping, making flash more attractive each day.
But just because it looks like a disk doesn't mean it acts like a disk. It will be years before we have a good handle on the details of flash drive performance.
Of course, if filesystems stopped issuing lots of small random writes these performance issues would go away. Apple's new ZFS does this, but NTFS doesn't and it isn't clear if it can be modified to reduce the problem.
Note: I've written a lot more about flash at StorageMojo -- my personal blog. If you want to get your storage geek on, check it out.