The Trim Command: Coming Soon to a Drive Near You

We run into these problems primarily because the drive doesn’t know when a file is deleted, only when one is overwritten. Thus we lose performance when we go to write a new file at the expense of maintaining lightning quick deletion speeds. The latter doesn’t really matter though, now does it?

There’s a command you may have heard of called TRIM. The command would require proper OS and drive support, but with it you could effectively let the OS tell the SSD to wipe invalid pages before they are overwritten.

The process works like this:

First, a TRIM-supporting OS (e.g. Windows 7 will support TRIM at some point) queries the hard drive for its rotational speed. If the drive responds by saying 0, the OS knows it’s a SSD and turns off features like defrag. It also enables the use of the TRIM command.

When you delete a file, the OS sends a trim command for the LBAs covered by the file to the SSD controller. The controller will then copy the block to cache, wipe the deleted pages, and write the new block with freshly cleaned pages to the drive.

Now when you go to write a file to that block you’ve got empty pages to write to and your write performance will be closer to what it should be.

In our example from earlier, here’s what would happen if our OS and drive supported TRIM:

Our user saves his 4KB text file, which gets put in a new page on a fresh drive. No differences here.

Next was a 8KB JPEG. Two pages allocated; again, no differences.

The third step was deleting the original 4KB text file. Since our drive now supports TRIM, when this deletion request comes down the drive will actually read the entire block, remove the first LBA and write the new block back to the flash:


The TRIM command forces the block to be cleaned before our final write. There's additional overhead but it happens after a delete and not during a critical write.

Our drive is now at 40% capacity, just like the OS thinks it is. When our user goes to save his 12KB JPEG, the write goes at full speed. Problem solved. Well, sorta.

While the TRIM command will alleviate the problem, it won’t eliminate it. The TRIM command can’t be invoked when you’re simply overwriting a file, for example when you save changes to a document. In those situations you’ll still have to pay the performance penalty.

Every controller manufacturer I’ve talked to intends on supporting TRIM whenever there’s an OS that takes advantage of it. The big unknown is whether or not current drives will be firmware-upgradeable to supporting TRIM as no manufacturer has a clear firmware upgrade strategy at this point.

I expect that whenever Windows 7 supports TRIM we’ll see a new generation of drives with support for the command. Whether or not existing drives will be upgraded remains to be seen, but I’d highly encourage it.

To the manufacturers making these drives: your customers buying them today at exorbitant prices deserve your utmost support. If it’s possible to enable TRIM on existing hardware, you owe it to them to offer the upgrade. Their gratitude would most likely be expressed by continuing to purchase SSDs and encouraging others to do so as well. Upset them, and you’ll simply be delaying the migration to solid state storage.

Free Space to the Rescue Restoring Your Drive to Peak Performance
POST A COMMENT

235 Comments

View All Comments

  • KadensDad - Tuesday, October 27, 2009 - link

    How do these drives fail? I have heard that they will just suddenly die, no more writes or reads possible. What I would like to know is what happens when it dies? Do you lose all data? Just can't write anymore? How does the OS respond? Any early warnings? What about e.g. CRC? How does possibility of data corruption compare to traditional SSD? What about RAID? Since the drives are electrical, not mechanical, this reduces the number of failure vectors and environmental concerns (e.g., ambient temperature over lifetime of the drive). Won't SSDs therefore fail closer together in time in a RAID configuration? This reduces the window of opportunity for fixing an array and also decreases the applicability of RAID, however marginal.
    Reply
  • adsmith82 - Monday, September 14, 2009 - link

    I need to run HDDErase on an X25-M. No matter what bootable CD or flash drive I create, HDDErase does not see either of my SATA hard drives. I already disabled AHCI in BIOS. Also, I am using version 3.3. I know that 4.0 does not work with the X25-M.

    Can someone help me troubleshoot this please? Thanks.
    Reply
  • gallde - Thursday, June 11, 2009 - link

    You point out that TRIM will only work on deletions, not on overwrites. But, couldn't a smart controller look at blocks that have a majority of invalid pages and "trim" them as well, recovering clean pages as a background process? Reply
  • forsunny - Thursday, August 13, 2009 - link

    Why not just make the SSDs capable of individual page erases instead of blocks? Problem solved. Reply
  • lyeoh - Friday, May 29, 2009 - link

    Good and informative article.

    Regarding the shill tshen83 who claims that Anandtech cost the drive manufacturers millions of dollars in sales.

    If that is true, Anandtech has saved customers millions of dollars.

    Anandtech should care more about their readers losses than drive manufacturer losses. If Anandtech was a site for drive manufacturers and their shills we wouldn't be reading it.

    To me, if the SSD drive manufacturers lose money, it's their own fault for building crap that has higher write latencies than old fashioned drives with metal discs spinning at 7200RPM or slower. Not anandtech's.

    I can get higher sequential reads and writes by using RAID on old fashioned drives. It is much harder to get lower latency. So Anandtech did the right thing for OCZ.

    Lastly, there might be a way of making your windows machine stutter less even with a crap SSD. Note: I haven't tested the actual effect on an SSD because I don't have an SSD.

    Basically by default when Windows accesses a file on NTFS, it will WRITE to the directory the time of the access. Yep, it writes when it opens files and directories (which are just special files). That might explain the stuttering people see. For a lot of things, Windows has to open files.

    Warning! There are reasons why some people or programs would want to know the last access time of files. Me and my programs don't (and I doubt most people would).

    If you are sure that's true for you (or are willing to take the risk) set NtfsDisableLastAccessUpdate=1 as per:

    http://technet.microsoft.com/en-us/library/cc75856...">http://technet.microsoft.com/en-us/library/cc75856...
    Reply
  • poohbear - Sunday, April 26, 2009 - link

    Brilliant article and very informative on these emerging technology. I wont be buying one anytime soon @ their prices, but good to know we'll FINALLY be replacing convential HDD which are the one component that have been pretty much the same since as far back as i can remember

    "SSDs have +5 armor immunity to random access latency"

    rofl that's the best analogy i've seen on a hardware review site. is every comp geek a RPG geek @ heart?
    Reply
  • Gootch - Sunday, April 19, 2009 - link

    Great article. Realy made me understand what I need to look at before making the plunge. Mistakes and all, my compliments. As for value between the now seemingly drastically improved Vertex vs the X25-M, I compared prices between the two and per Gb, the Intell product for say an 80 Gb drive is Can $5.86/Gb, while the OCZ 60 Gb SSD is Can $6.81/Gb. Now that we are no longer comparing apples and oranges, I think we need to point out that the Intel product is not only faster and maintains it's performance edge better, but it is cheaper per Gb. At least in Canada. I have many OCZ products and I love the company and it's customer support. I can only hope that they will make their SSDs more competitive in the near future, because most consumers will pay the extra 70 bucks and go with the X25 when they pay attention to the numbers, both performance and price. Reply
  • Baffo - Saturday, April 11, 2009 - link

    I could forsee a whole host of issues with encrypting SSD drives, not the least of which is essentially making the drive completely "used" outside of the drive slack space - which would be a temporary reprieve for the reasons discussed in this article. However, I could also see potential performance and lifetime issues since modern encryption uses streaming ciphers (e.g. an entire encrypted block - which may or may not conform to the physical block size will be changed for even one bit change within the block itself). Has anyone looked at the resultant effect on performance due to using encryption - it would be good to compare say Bitlocker, PGP, Checkpoint, and an open source encryption solution (Crypt or something like that?). This could actually become a real driver for moving to on-drive encryption where it would have the opportunity to optimize the encrpytion for the pro/cons of the SSD architecture. Reply
  • brandensilva - Friday, April 10, 2009 - link

    Great article! I respect that OCZ made the necessary changes to make this drive work. I'd rather take a slightly slower drive if it meant consistent performance.

    If my hard drive started to stutter I'd flip out! I'm glad that they took the feedback and instead of selling faulty drives, that would ultimately hurt their brand, they decided to go back to the drawing board and iron out the kinks. I'm not expecting them to compare to Intel's 25-M per price or performance. They don't have nearly the cash or manufacturing capacity to compete with Intel but they do have that small business feel with receiving feedback and making improvements, which is important to customers.

    Lets hope they continue to utilize that aspect of their business and further improve on their products and bring us some reliable SSD's in the future.
    Reply
  • Hrel - Thursday, April 09, 2009 - link

    although, I have some issues which I have put in an e-mail sent to Anand; can't wait for you response. Reply

Log in

Don't have an account? Sign up now