SSDs are an increasingly popular form of storage. Though lighter, faster, and more shock-resistant than traditional hard drives, the SSDs suffer from a higher cost and lower endurance. Garbage Collection is one important factor increasing durability and speed.
How does Garbage Collection work?
With SSDs, the controller writes information to a free space on the Flash. In contrast to traditional hard disk drives, Flash cannot be directly overwritten but must first be erased (See Figures 1 & 2)
* For Flash, the smallest unit that can be written to is a Page; the smallest unit that can be erased is a Block.
- Data are written to the 9 pages of Block A. After the write operation is done, Block A’s 9 pages are full.
- Page a-c’s data are deleted, but pages cannot be individually erased. They are marked as unreadable, but cannot be written to again.
- Block A and Block B both have invalid Pages (gray area).
- The system will read Pages a-h as containing valid information and transfer them to Block C.
- After that, it erases Blocks A and B.
Based on the Garbage Collection algorithm, effective data will be transferred to Block C. Blocks A and B are then erased. After that, new data may be more efficiently written to the now freed up Blocks of A and B. This is the essence of Garbage Collection.
Advantages of Garbage Collection
In early SSDs, Garbage Collection was performed whenever a Block was discovered to have insufficient space. This greatly downgraded performance. The more advanced controllers on modern SSDs only, under normal circumstances, invoke Garbage Collection when read/write operations are not occurring. Flash first organizes free space and maintains spare blocks as buffer space. Garbage Collection therefore does not affect SSD performance in general.
From the system point of view, invoking TRIM (click here for more on “TRIM”) reduces the system load, aids in information management, and facilitates future write operations.