Understanding the SSD write performance cliff

Understanding the SSD write performance cliff

October 28, 2013 0 By Eric Shanks

Solid State drives are much faster than their spinning disk predecessors, but can also have performance degradation due to how they interact with Operating Systems.

Flash consists of blocks of data and those blocks are full of smaller items called pages.  A typical SSD might have block sizes of 512KB and 4KB pages.

There are 3 statuses that a healthy page could be in on a flash disk.

  •  Written to:  Data from the OS has been written to the page.
  •  Unwritten to: The page is free and available to be written to by the Operation System.
  •  Invalid: The page has data in it, but is available to be overwritten by the Operating System.

 

Pages

 

 

Parts 1 and 2 probably don’t need any explanation, but part 3 requires a bit more knowledge about how disk controllers interact with the Operating System.

Because modifying a page, or deleting a page takes time, the Operating System usually updates the file system to say that the page is available to be overwritten, but never informs the disk controller.  Since the disk controller never knows what pages have real data in them, and which pages are invalid, they are never deleted.  Normally, this speeds up the process because you don’t have to go through a whole routine of deleting the actual data.  The OS shows the amount of “Free Space” which is = (Total Unwritten Pages) + (Total Invalid Pages) * (Page Size).

 

Flash Memory has three kinds of operations.

  • Page-read:  A page is read.
  • Page-write:  A page is written.
  • Block-Erase:  A block is erased.

You might notice that one of those operations is not like the other.  The fact that an SSD needs to erase entire blocks at a time causes some performance issues.  Flash disks cannot erase a single page, they have to delete an entire block.

Overwriting an invalid page is not as simple as you’d think it would be.  It turns out that flash has to write to unwritten pages.  So if a page is invalid, the data in it must be deleted first and then it can be written to again.  Remember that the data in that invalid page still has data in it, the file system has marked that page as available to be re-written.  The disk controller has not deleted the info in that page.

Lets look at an example of what needs to happen to overwrite a single page.

Here we have a single block with all invalid pages, and two written pages.  The OS file system tells us that we can write to any of the pages except the two that are written, but the disk controller needs to delete the invalid pages first.

EraseBlock

The process of deleting a single page requires you to copy the entire block to memory, erase the block from disk, and then written pages back from memory.  This is a lot of work to write a few pages to NAND cells that should already be available to write to.

 

TRIM

TRIM commands have now been added to some Operating Systems to let the SSD’s know ahead of time that data can be deleted.  During the disk’s garbage collection cycle, it can go through and delete the blocks in advance of the OS needing to write to them again which helps alleviate this performance cliff.