How does an SSD write?

An SSD is based around a controller chip and NAND Dies.  These are slabs of silicon consisting of cells.  These cells store voltage allowing an on or off state (1 or 0) allowing the storage of data in a binary form.

For Single Layer cell based SSD the cell is either on or off.


SLC NAND FLASH

Writing to this type of Flash is quick and easy.  The controller has less to do.

For MLC the cells are split into 2 (it’s called Multi Layer Cell, but should really be called Dual Layer Cell as Triple Layer Cell technology is on the roadmap).  With this technology, the cell is divided between 0 and 50 and 51 and 100 (as an example – in reality it’s more complex than that).  This allows the cell to have 4 states On On, On Off, Off On, Off Off therefore doubling the amount of data the cell can store.


MLC NAND FLASH

The above is a very basic view of how data it stored.  There is a bit more to it and it is good to understand it so that you can understand the myriad of different scores and specifications.

Writing to an SSD

Reading from an SSD is simple, writing is a lot more complex.  This next section assumes that the SSD does not hold the OS but is installed as an additional drive.  Brand new, out of the box, direct from the manufacturer. 

The storage is divided into blocks, that can store Pages.  Pages are made up of multiple adjacent cells on the NAND Flash.  Blocks contain pages, and the number of Blocks is determined by the size of the SSD.   Pages are actually 4 kilobytes in size and writable Blocks are made up of 64 Pages. Data is erased in 256KB sized blocks.

For illustration purposes I have shrunk the blocks into 12 pages, and each Page is shown as 1 byte.


Blocks of Storage on an SSD

Keeping it simple, let’s open Notepad


Notepad.exe

We enter 1234 into Notepad and save it as 1234.txt


Notepad 1234 as text


4 byte 1234.txt

This is stored on the new, fresh SSD.  See above the file is 4bytes in size. Lets say our 4 bytes file makes up 1 page per byte (just to keep it simple).  We need to therefore, write 4 pages onto the SSD to store our 1234.txt 4 byte sized file containing the text 1234.


4 blocks of data

These 4 pages in the 1st block make up the file.


1234.txt stored on the SSD

Let’s edit the file – by adding 5678 to the start of the file.

Notepad containing 56781234

The file has now grown to 8 bytes


8 byte 1234.txt

Because we saved over the original file on the disk, there is a little work to do to write the new version of the file.


Original Pages are marked for erase – new pages written to same block

The new version of the text file is now 8 bytes in size


1234.txt 8 bytes in size

Above we see that the old data is no longer relevant – it really needs to be deleted. 

Solid State Disks only erase whole blocks of data – they cannot erase Pages.  So to erase the old data, it must again, write the good data in Block A to Block B and erase the whole of Block A.


1234.txt written from Block A to Block B

Once it has written to Block B – it can erase Block A


Block A Erased

The amount of times a cell can be written to has a limit before it becomes unreliable.  In SLC this number is between 50,000 and 100,000.  In MLC is typically between 3,000 and 5,000.

You see in the simplified illustration above, that the number of writes is more than expected.  We used an example of changing a file, but the same theory should be used to writing additional files to the disk.


New SSD with data written across it

The above graphic shows that Block D has had a clean up and that WORD.DOC file is written across Blocks C and E.  They don’t need to be sequential, and it makes no difference to the performance of the SSD that the data spans blocks that are not concurrent.  The important thing for the SSD is to erase in complete blocks.  Block D would have been erased after WORD.DOC had been written to the disk.  Block F is yet to be written to.

If we were to delete XYZ.dll from the disk, the SSD would need to move 1234.txt from block B and Pages E-L in Block C before Blocks B and C could be erased.


SSD cleaned up after XYZ.dll erased

Hopefully I have demonstrated in a simple way how an SSD writes data.  It does it in 4k sized Pages (we showed it in 1 byte sized chunks in the example for simplicity). With 64 writable pages per block (rather than 12 in our illustrations).  4 sets of Blocks are erased each time in 256 KB chunks.

This cleaning of the data is referred to as Garbage Collection and keeps the performance of the SSD at it’s peak.  Therefore there is no need to defragment an SSD.

This cleaning of data from the SSD before data is written is a downside of SSD as it creates additional write activity to the SSD.  The SSD has a limit to the number of writes.  The calculation of the number of writes is called Write Amplification  and can be calculated as

amount of data written to the flash memory / amount of data written by the host
= write amplification

The Solid State Disk market talks of Sustained Read and Sustained Write as well as Random Read and Random write scores. 

Sustained Write, writing pages to entire blocks without the need to clean up the block, this is determined by the OS – makes cleaning up of the data much faster.

Random write looks for space on the disk and writes data where it finds free space.  The maximum speed is determined by the number of channels on the SSD, the efficiency of the firmware and the speed of the NAND Flash Memory.

Of course, files come in a myriad of file sizes that don’t all fit into 4kb chunks.  The controller within the SSD controls all of this logic, improvements in controller design have been key to increasing SSD performance.

Next time we’ll explore Over Provisioning, TRIM, Wear Levelling.

Post a Comment

Your email is never shared. Required fields are marked *

*
*