Understand SSD
- page 01: Flash memory
- page 02: MLC and SLC
- page 03: Sectors, pages, blocks...
- page 04: Wear-leveling
- page 05: TRIM
- page 06: Garbage collector
- page 07: Every day usage
- page 08: Conclusion
Sectors, pages, blocks...
Those three words are the main factors responsible of the huge drop in performance in multiple random accesses. The sector is the addressing unit of a HDD. It is almost always 512 bytes. With disc-based HDs, this basic unit is ideal, as it offers a 1:1 mapping between logical sectors and physical sectors managed by the controller. When writing data, the controller does not need to think, it simply writes data on the assigned sectors independently of the existing data stored on them (overwrite).
With a SSD, this 1:1 mapping does not exist as the controller does not use the same addressing unit: goodbye sectors, say hello to pages and blocks.
Pages are the basic unit for reading and writing. Their sizes range from 1 KB to 4 KB (plus a few bytes for storing the control and error correcting codes) so this is the smallest unit to be read or written during an operation. With a SATA interface working in 512-byte mode, one can then easily understand why the pages format will not be an issue in sequential mode (one will open several consecutive sectors, so it will request complete pages, and all data will be used), but it will become a true nightmare in random access mode: one will need 512 bytes from one sector, then 512 bytes from another one, then 512 bytes from a third location (etc.) every time the controller needs to access the entire page, meanwhile only part of the data will be used. If one considers a 4 KB page format, the controller will deal with a volume of data 8 times larger than the one requested by the system. So, in random access mode, performance level will be 8 times slower than in sequential mode.
The block is an even bigger problem: this is the basic unit for erasing data. Its size ranges from 128 KB and 512 KB. So every time the controller needs to write data in a page already hosting data, the entire block must be erased in order to make it possible to write new data. But as other pages of this block might contain data to be kept, one will in fact need to read all pages included in the block to be erased, erase the block and rewrite the original pages as well as new ones. So, on a SSD based on 2 KB pages with blocks of 512 KB, rewriting a SATA sector of 512 bytes might require to read up to 512 KB of data, then erase this volume, then rewrite the same volume. So, in the worst case, one will have to deal with 2 x 512 = 1024 KB of data, i.e. 20 times more than an HDD, on which the controller will simply overwrite a sector of 512 bytes.
In addition, the pages can be in 3 modes: blank, programed (storing data) and erasable. The latter mode defines that the page contains data of no value, so one can rewrite the page after having erased it. So, if a block of 512 KB is composed of 100 KB of data, 200 KB of blank pages and 212 KB of erasable pages, the controller of the SSD knows that this block can be used to write up to 412 KB of data after erasing available pages.
