SSD Garbage Collection

How the Trim Command Works

By | Feb 13, 2023 | All, Technology

A solid-state drive (SSD) is an electronic data storage device consisting of a controller, NAND flash, DDR (optional), and an interface/protocol connector. (e.g., PATA, SATA, and PCIe NVMe.) Unlike hard disk drives (HDDs), SSDs don’t use mechanical parts to read, program, and erase data. Through precise control of millions of NAND flash memory cells, an SSD controller can perform read, write, and erase tasks.

 

 

A flash memory cell is essentially a MOSFET (metal-oxide-semiconductor field-effect transistor) with a special floating gate that can retain and store data persistently. Each time electrons are trapped in the floating gate of a transistor, the data is programmed. When the electrons are released, the data is removed.

Unlike an HDD, NAND flash memory cannot overwrite existing data. Garbage Collection (GC) is instead used to relocate free or used space and reclaim valid and invalid data and is a fundamental process adopted in all SSDs. GC can be implemented in many ways that directly affect overall SSD performance and endurance.

 

How GC processes data

Since SSDs cannot overwrite existing data in NAND memory cells, they must first erase old data before programming new data to the same location. GC is the process of relocating existing data to new locations within free memory space and allowing the surrounding invalid data to be erased thoroughly.

 

 

A flash memory cell is composed of pages, and pages form a block. Due to the intrinsic characteristic of NAND device physics, the flash cell allows data to be programmed on a page level but only erased on a block level. This inconsistency between program and erase tasks is the major impact on SSD endurance.

Before claiming the space taken up by invalid data, all the valid data in pages from the initial block must be copied and written into empty pages of a new block. The invalid data in the original block can then be erased, ready for new valid data to be written.

 

Trim command

Operating System (OS) awareness can only recognize the logical locations addressed in the mapping table of SSDs. The storage system returns the data from the physical locations while the OS requests data from corresponding logical locations. Microsoft proposed the Trim command concept to reduce unnecessary wearing on NANDs. This command lets the OS give immediate notice to an SSD while a file is being deleted at the OS level. The SSD can then tell earlier whether the data is marked as a valid one or an invalid one.

The best benefit of the Trim command is to help the SSD closely follow what the OS is about to execute in real-time. Consequently, redundant access to the NAND flash is efficiently reduced.

The Trim command can produce three key benefits:

      1. Lower write amplification: Early notice of invalid data for those pages with invalid data contributes to fewer data rewrites. When more free space is available to write, it equals fewer write tasks required for the SSD.
      2. High throughput: A drive runs faster when there is less data to move during GC when using the Trim command. Throughput is bottlenecked by how quickly an SSD can write to the flash memory. When GC is processing, the SSD has to stop some data transfers from the Host. Therefore, it’s beneficial for SSDs to know what pages contain invalid data, so the page doesn’t have to be moved during GC.
      3. Improved endurance: By not rewriting invalid data, the drive writes less data to the NAND flash.

 

 

GC and Trim are the building blocks in SSD’s operations

Garbage Collection is a significant difference between SSDs and HDDs. Instead of overwriting existing data, SSDs perform GC when new data is programmed to pages with invalid data. It causes additional wearing to NAND. However, one of the solutions to this issue is the Trim command. It helps an SSD to anticipate any “file-deleting” tasks from the user or operating system. This results in lower write amplification, higher throughput, and improved SSD endurance.

 

The Foundation that Accelerates Innovation™

en_USEnglish