How is TRIM handled when an SSD is used as L2 Cache?
Posted: Fri Dec 16, 2011 7:13 pm
If you know much about the inner workings of an SSD, you know that the longer an SSD is in service, the more write performance degrades due to write amplification (http://en.wikipedia.org/wiki/Write_amplification). Optimally, you also want the SSD's garbage collector to be able to do Wear Leveling (http://en.wikipedia.org/wiki/Wear_leveling).
There's not a lot you can do as a user about this, but one action that's available to the OS is to send a TRIM command to the SSD whenever a file is deleted. This informs the drive that those blocks no longer contain data. This in turns allows the drive to add some cells directly back to the free list (so no write amplification will occur on the next write to those cells), and it also allows the garbage collector to focus on only those blocks that carry meaningful data.
I'm worried about how FancyCache manages the SSD when it is configured as a L2 cache - especially if the Cache approaches the size of the SSD. If it only creates the Cache file once and just opens it for writing during boot, then once every block in the file has been written to, the SSD will always see those blocks as having data, and eventually the SSD will be forced to re-build an entire cell with each subsequent write, even if it's just one block. This is the worst form of write amplification.
One solution here is for FancyCache to delete and re-create the Cache file each time it is started. The delete would cause Win7 to send a TRIM command for the entire cache, returning all the cells to the free list. As the Cache fills up again, it will likely claim other cells off the free list, speeding the writes and spreading the wear.
I see that FancyCache does recognize this problem for a running system - it can be configured so that once the cache is filled, it stops writing new data to the cache. However, if you reboot and FancyCache do not give Win7 an opportunity to issue the TRIM command, then it will start filling the cache again, but with the worst form of write amplification because it will be writing over blocks that the SSD thinks already contain data.
So, can I ask someone whose using an SSD as a L2 cache to check the creation date on the FancyCache file, and see if it was created on the last boot, or when they first configured FancyCache?
There's not a lot you can do as a user about this, but one action that's available to the OS is to send a TRIM command to the SSD whenever a file is deleted. This informs the drive that those blocks no longer contain data. This in turns allows the drive to add some cells directly back to the free list (so no write amplification will occur on the next write to those cells), and it also allows the garbage collector to focus on only those blocks that carry meaningful data.
I'm worried about how FancyCache manages the SSD when it is configured as a L2 cache - especially if the Cache approaches the size of the SSD. If it only creates the Cache file once and just opens it for writing during boot, then once every block in the file has been written to, the SSD will always see those blocks as having data, and eventually the SSD will be forced to re-build an entire cell with each subsequent write, even if it's just one block. This is the worst form of write amplification.
One solution here is for FancyCache to delete and re-create the Cache file each time it is started. The delete would cause Win7 to send a TRIM command for the entire cache, returning all the cells to the free list. As the Cache fills up again, it will likely claim other cells off the free list, speeding the writes and spreading the wear.
I see that FancyCache does recognize this problem for a running system - it can be configured so that once the cache is filled, it stops writing new data to the cache. However, if you reboot and FancyCache do not give Win7 an opportunity to issue the TRIM command, then it will start filling the cache again, but with the worst form of write amplification because it will be writing over blocks that the SSD thinks already contain data.
So, can I ask someone whose using an SSD as a L2 cache to check the creation date on the FancyCache file, and see if it was created on the last boot, or when they first configured FancyCache?