When speaking about maintaining the performance of solid-state drive (SSD) we cannot neglect the important role TRIM command plays in this regard. If you are new to SSD world, you must care for this precious computer part and learn how to properly use it so as to keep it lasting without an issue the longest possible time. One of the major causes of the slowness of SSD is the absence of TRIM command. So, what is TRIM command and how does it work? To understand what “TRIM Command” is, you first need to understand how solid state hard drives work.
Understanding How SSDs Deal With Data:
SSDs use NAND flash memory to store and transfer information. This flash memory is created up of small “pages” and groups of pages are called “blocks.” When you tell your computer to delete a page on the solid state hard drive the page isn’t actually deleted – it is merely marked for deletion. This is because data can only be deleted in blocks. You cannot delete individual pages on an SSD. Later on, when you tell your computer that you need the space, the pages marked for deletion are grouped into a block and the whole block is wiped clean. This process slows down the solid state hard drive when it is writing.
Let us explain in a different way.
Imagine, if you will, that you have a stack of blank papers on your desk at work. Each workday you keep the papers with important information on them, but get rid of the unnecessary papers, like the one you doodled on during a boring meeting, by putting them in the “To Be Recycled” tray on your desk. It’s not worth going all the way down to the recycling center for a few sheets of paper, so you wait until you have a stack that is worth the travel time.
Eventually, you run out of blank paper. Since you have a project due that day, it is now time to use the paper from the “To Be Recycled” tray. You take out your eraser and get to work. Erasing takes a lot of effort, so you decide to only clean up a portion of the stack to tide you over for a while. Eventually you will run out of paper again and you’ll have to erase another portion, but you plan on crossing that bridge when you come to it.
That is why solid state hard drives slow down while writing after prolonged use, and the longer you use an SSD, the more likely it becomes that you see degradation in performance, even if the device isn’t filled with data. When the performance of conventional hard drive deteriorates it’s usually sufficient to defrag, because in this case it is beneficial to have all data stored in sequence or in the same physical location on the hard drive so that the head doesn’t have to move back and forth when reading or writing to the disk.
With an SSD the complete opposite applies – it is better to have the data spread out across different locations so that the data can be read in parallel. This is essential to get the best possible performance from the drive. In addition, an SSD does not like to overwrite or physically delete data. Such instructions consume performance and also shorten the life span of the drive. They have instead to clean the files marked for deletion by flagging them as “available” before they can be written on, and erasing takes time. This can cause serious delays, depending on how much data you’re trying to save and how much needs to be deleted.
However, when there are no vacant blocks that can be used for new files you run into another issue. While it is possible to read and write to NAND flash in 4KB pieces you can only delete an entire block of 512KB. In other words, if you want to overwrite a 6KB previously deleted file with another 6KB file, the drive has to start by loading the entire 512KB block. Then it rewrites it by replacing the deleted file with the new one and finally writes the entire block back to the drive.
TRIM Is There To Fix It
Luckily, TRIM alleviates this problem and is supported on many of the SSDs and operating systems made today. A TRIM command enables your operating system to find the marked pages before you need them and wipe them clean. By knowing what pages and blocks no longer contain valid data, the SSD controller can stop worrying about preserving that data and instead mark those blocks for garbage collection or recycling. This increases the effective free space from the controller’s perspective, and caps a drive’s performance degradation to the amount of space that’s actively used vs. a continuing downward spiral until the worst case steady state is reached, and cleaning these data pages beforehand saves you time when you need to write on the data pages again. It’s like you have your own recycling guy next to your desk, recycling the pieces of paper as they come.
In order to work correctly, TRIM has to be supported by both the solid state hard drive and the operating system you are using. When both the OS and the SSD support TRIM individual pages can be cleaned and your solid state hard drive will be informed that the pages are now blank and can be written on. This kind of cleaning and communication is essential to keep your drive performing to the best of its abilities.
The following video may help you understand the issue of TRIM:
Hope this article has been helpful and informative. If you believe so please like it on Facebook.