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.
In Figure 2, where there is insufficient space on Flash to write to, existing data (Pages D-I) is transferred to Block B, after which Pages J-L may be written. Block A is then erased. This is the essence of Garbage Collection. However, this process leads to write amplification, with the write amplification factor being a cause that significantly affects SSDs durability.
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, under normal circumstances, only 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 reduces the system load, aids in information management, and facilitates future write operations.