The Cleaning Lady and Write Amplification

Imagine you’re running a cafeteria. This is the real world and your cafeteria has a finite number of plates, say 200 for the entire cafeteria. Your cafeteria is open for dinner and over the course of the night you may serve a total of 1000 people. The number of guests outnumbers the total number of plates 5-to-1, thankfully they don’t all eat at once.

You’ve got a dishwasher who cleans the dirty dishes as the tables are bussed and then puts them in a pile of clean dishes for the servers to use as new diners arrive.

Pretty basic, right? That’s how an SSD works.

Remember the rules: you can read from and write to pages, but you must erase entire blocks at a time. If a block is full of invalid pages (files that have been overwritten at the file system level for example), it must be erased before it can be written to.

All SSDs have a dishwasher of sorts, except instead of cleaning dishes, its job is to clean NAND blocks and prep them for use. The cleaning algorithms don’t really kick in when the drive is new, but put a few days, weeks or months of use on the drive and cleaning will become a regular part of its routine.

Remember this picture?

It (roughly) describes what happens when you go to write a page of data to a block that’s full of both valid and invalid pages.

In actuality the write happens more like this. A new block is allocated, valid data is copied to the new block (including the data you wish to write), the old block is sent for cleaning and emerges completely wiped. The old block is added to the pool of empty blocks. As the controller needs them, blocks are pulled from this pool, used, and the old blocks are recycled in here.

IBM's Zurich Research Laboratory actually made a wonderful diagram of how this works, but it's a bit more complicated than I need it to be for my example here today so I've remade the diagram and simplified it a bit:

The diagram explains what I just outlined above. A write request comes in, a new block is allocated and used then added to the list of used blocks. The blocks with the least amount of valid data (or the most invalid data) are scheduled for garbage collection, cleaned and added to the free block pool.

We can actually see this in action if we look at write latencies:

Average write latencies for writing to an SSD, even with random data, are extremely low. But take a look at the max latencies:

While average latencies are very low, the max latencies are around 350x higher. They are still low compared to a mechanical hard disk, but what's going on to make the max latency so high? All of the cleaning and reorganization I've been talking about. It rarely makes a noticeable impact on performance (hence the ultra low average latencies), but this is an example of happening.

And this is where write amplification comes in.

In the diagram above we see another angle on what happens when a write comes in. A free block is used (when available) for the incoming write. That's not the only write that happens however, eventually you have to perform some garbage collection so you don't run out of free blocks. The block with the most invalid data is selected for cleaning; its data is copied to another block, after which the previous block is erased and added to the free block pool. In the diagram above you'll see the size of our write request on the left, but on the very right you'll see how much data was actually written when you take into account garbage collection. This inequality is called write amplification.


Intel claims very low write amplification on its drives, although over the lifespan of your drive a < 1.1 factor seems highly unlikely

The write amplification factor is the amount of data the SSD controller has to write in relation to the amount of data that the host controller wants to write. A write amplification factor of 1 is perfect, it means you wanted to write 1MB and the SSD’s controller wrote 1MB. A write amplification factor greater than 1 isn't desirable, but an unfortunate fact of life. The higher your write amplification, the quicker your drive will die and the lower its performance will be. Write amplification, bad.

Live Long and Prosper: The Logical Page Why SSDs Care About What You Write: Fragmentation & Write Combining
POST A COMMENT

296 Comments

View All Comments

  • jtleon - Tuesday, September 08, 2009 - link

    Yes I fell asleep atleast 3 times reading this article (it IS Monday afterall)

    Yes, Indilinx clearly rocks the SSD world - Now I know thanks to Anand!

    Stories like this set the standard for all review sites - I don't come away with the feeling I was just sold a bill of goods by some schiester in Intel's pocket, or otherwise.

    Great Job Anand! Keep them coming!
    Reply
  • SSDdaydreamer - Tuesday, September 08, 2009 - link

    I too am wondering whether TRIM will be available on the Intel Drives for Windows XP or Vista. I seriously doubt it, as the OCZ Wiper Tool appears to only be available for Indilinx controllers. Perhaps Intel will introduce their own wiper utility. I am leaning towards the OCZ Vertex or Patriot Torqx drives, as I am quite content with Windows XP and Windows Vista.
    I have an itchy trigger finger on these SSDs, but I want to hold back for the following unknowns.

    1. I would like to use the NTFS file system for my drive, but I am unsure of the proper/ideal block size.

    2. I would merely like to image my existing Windows Installation, but I am worried that performance or stability problems will arise from the NTFS file system. A fresh install could be in order, but it is preferred to image.

    3. Is there a way to change the size of the spare area? Maybe I have the wrong idea (perhaps only format part of the drive, unformatted space goes appends to the spare area?) I am willing to sacrifice some of the usable partition space for an increased spare area for improved performance.

    4. Are there complications with multiple partitions? If there are multiple partitions on the drive (for multi-boot) do they all share the same spare area? Is it possible to allow their own respective spare areas?


    Is there anybody out there that could enlighten me? I'm sure others would do well to have the answers as well. If I make any discoveries, I will be sure to post them.
    Thanks in advance.
    Reply
  • bradhs - Monday, September 07, 2009 - link

    IS there a "Wiper" app for Intel X-25m G2 drives? For people who don't have Windows 7 (TRIM) and want to keep the Intel X-25m G2 running smooth. Reply
  • smjohns - Tuesday, September 08, 2009 - link

    No there is no wiper tool for Intel drives at the mo. In addition to this the current firmware on the Intel drives do not have TRIM enabled. I guess this will be released soon after Windows7 is released. I think I have read somewhere that Intel are working on a TRIM version of it's Matrix Storage Manager software that will provide this functionality to the other operating systems. Reply
  • Burny - Monday, September 07, 2009 - link

    As many before me: great article! I learned a lot about SSD's. Even up to the point i'm ready to buy one.
    I still have 2 questions tough:

    2. Will TRIM be available on the G2 Intel drives for sure? Some sources doubt this: http://www.microsoft.com/communities/newsgroups/en...">http://www.microsoft.com/communities/ne...t=&l...


    3. As I understand, TRIM will work on a firmware level. That implies that TRIM will also function under Windows XP or any OS for that matter? Then why the need to build another TRIM into Windows 7? Or does a TRIM firmware enabled SSD simply allows the OS to use TRIM?

    Thanks!
    Reply
  • smegforbrain - Monday, September 07, 2009 - link

    While I consider myself handy with computers, I'm not the best technical mind when it comes to the details. You do an excellent job of presenting everything in a manner that it can be understood with little difficulty. I look forward to future articles about SSDs.

    I do have a question I'm hoping somebody can answer. I'm as interested in the long-term storage outlook of SSD drives as I am every day use. I've seen it said that an SSD drive should hold its charge for 10 years if not used, and it was discussed a bit earlier in this thread.

    Yet, none of my current mechanical hard drives are more than 3 years old; none of my burned DVDs/CDs are older than 5 years. It seems far more likely that I would replace an SSD for one with a greater storage capacity after 5 years tops than to expect one to be in use, even as archival storage, for as long as 10 years.

    So, is the 10 year 'lifespan' even going to be an issue with archival storage for most people?

    Will this worry over the life span of an SSD become even less of an issue as the technology matures over the next couple of years?
    Reply
  • Starcub - Tuesday, September 08, 2009 - link

    "So, is the 10 year 'lifespan' even going to be an issue with archival storage for most people?"

    No, but who takes wads of money out of their wallet to store it on their shelf?
    Reply
  • smegforbrain - Tuesday, September 08, 2009 - link

    "No, but who takes wads of money out of their wallet to store it on their shelf?"

    That is simply assuming that they will remain as expensive as they are now. They won't.
    Reply
  • BlackSphinx - Sunday, September 06, 2009 - link

    Hello! I'm taking the time to comment on this article, because I am very thankful for all of these awesome write-ups on SSD.

    I'm in the process of building an heavily overclocked i7 rig for gaming and video edition, and I was going to jam 2 Velociraptors in Raid0 in there. Why? I had only heard bad things about SSDs in the past.

    Reading your aticles, who are, while in depth, very clear and easy to understand, I understand much better what happened in early SSDs, what's so good about recent Indilinx and Intel SSD, and, truly, why I should forgo mechanical drives and instead go the SSD route (which, frankly, isn't more costly than a Raid0 raptor setup). In short, these articles are a great service to the end users just like myself, and if they were intended as such, you have passed with flying colors. Congratulations and thanks.
    Reply
  • Transisto - Sunday, September 06, 2009 - link

    Could someone reset my brain as to why there is no way to get a (very noticeable) improvement from USB thumb-drives. I mean these thing also get 0.1 ms latency.

    It's a bit extreme but for the same price I could get 9 cheap 8gb SLC usb drive for around 20$ each and put them in three separate PCI-USB add-on card (5$)

    They would saturate the USB controler with 3 drive in it so I Could get around 140mb/s read and 60mb/s write.

    Say you manage to merge that into a raid or ... ? Is eboost or Readyboost any good at scaling up ?

    Reply

Log in

Don't have an account? Sign up now