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

250 Comments

View All Comments

  • OCedHrt - Wednesday, March 18, 2009 - link

    Excellent article. One of the best I've seen. Reply
  • cliffa3 - Wednesday, March 18, 2009 - link

    I can tell a ton of work went into that, and all the history/details are greatly appreciated. I've been checking every week or so throughout February to see if it had been posted, but well worth the wait. As great as SSDs are, I can understand you not wanting to be near one for a while (-: Thanks for all the hard work...especially from the consumer standpoint. And kudos to OCZ for stepping up the way they did...that's (unfortunately) unheard of. Glad to see your no-compromise / report the facts no matter what attitude winning for the consumer. I'm glad at least one manufacturer was able to see (eventually) your intent wasn't to create a commotion, but to just plainly say what needed to be said. Reply
  • sngbrdb - Wednesday, March 18, 2009 - link

    An extremely (as always) informative article; comprehensive and no angle missed. Good stuff!

    From an enthusiast's perspective, OCZ gained 10 levels of trust as a result of Ryan Peterson's response and handling of the Vertex' firmware. Ryan accepted the harsh reality expressed to him from an outside reviewer, risked marketability to rely on Anand's expertise (Anand is *absolutely* correct that 230MB/s is worthless if it comes with stuttering write latency), and resolved the problem in record time.

    This is the rare kind of responsiveness and attitude that translate directly into sales (I'm on my way to price the Vertex now).
    Reply
  • tshen83 - Wednesday, March 18, 2009 - link

    BUT, still based on Windows Vista.

    I am going to drill this into reviewer's head -> NTFS isn't designed for SSDs.

    There are three problems for properly reviewing SSDs today:

    FileSystem, RAID controller, and SSD controller.

    Each of them can compensate for the SSDs, the question is which one SHOULD be responsible for optimizing random IOs.

    It is very clear that Intel's SSDs have implemented all the nitty gritty stuff like copy on write onto the SSD controller itself. So the OS or FileSystem shouldn't be responsible for performance degradation, however the same cannot be said for other SSDs.

    I am sure results would be difference if this were conducted on Solaris/OpenSolaris ZFS with Adaptec 5405(IOP348 based RAID card). Not to pump Solaris and ZFS, but it is the primary reason why IBM wants to buy SUN, because it is the only File System on the market that can properly operate SSDs and to do so without RAID controllers.

    If Anand really wants to stick to windows still, I think benchmarking on Windows 7 Beta would be slightly better option that Vista. Windows had made a lot of optimizations for rotational based hard disks that it actually makes SSD perform worse.

    The Vertex random write 4K IOPS benchmark doesn't look right at 2.6MB/sec, that is hardly 650 IOs. It should be much higher. It could be the ICH10R controller though.
    Reply
  • hyc - Wednesday, March 18, 2009 - link

    I'd expect IBM's JFS to be pretty efficient on an SSD as well. Anything that appends and avoids overwriting existing sectors will perform better here.

    Stepping back a bit, I still have a perfectly usable Dothan-based laptop with IDE. Any chance of getting an in-depth review on recent Transcend 128GB IDE SSDs? My new laptop is running fine with a G.Skill Titan 256GB SSD, but when I fire up the older laptop it's unbearable, even with that 7200rpm Hitachi 100GB drive inside.

    By the way, I paid under $2/GB for the 256GB G.Skill Titan; for the work I do with it on Linux it performs fine most of the time. (Just make sure to maximize use of the FS cache.) I don't see the value proposition for the OCZ Vertex or Summit.
    Reply
  • tshen83 - Wednesday, March 18, 2009 - link

    The random write 4K benchmark isn't right for the Vertex and other SSDs because of the test procedure:

    "The write test was performed over an 8GB range on the drive, while the read test was performed across the whole drive."

    It partially disables any write optimization algorithms on the Vertex. Intel wasn't affected as much.

    Anand, your first article pumping X25-M literally screwed Samsung's SSD manufacturers big time: they lost hundreds of millions of dollars because of your blatant pumping. Yes the random write was a big problem, but so was testing it on a Windows OS with NTFS and integrated SATA controller like ICH9/10 with no ram cache and obviously lack of IO optimizations for SSDs.

    Please redo the review with a proper OS, ie Windows 7 beta or OpenSolaris.

    Reply
  • Proteusza - Thursday, March 19, 2009 - link

    Yeah, who in their right mind uses Windows and integrated SATA controllers? Oh wait, nearly everyone.

    Since its pretty obvious that you either work for Samsung or one of their partners, I think its laughable that you think this cost them hundreds of millions in sales. How big is the SSD market exactly, and how many potential buyers visit this site? Not enough to cause such an impact if you ask me.

    And the fact remains - had you guys done what OCZ did, and optimized for real world use even if it cost you e-peen in the way of benchmarks, you would have been fine. Its only because you thought you could cheat and swindle consumers that you guys got a bad rep from Anand. Run an honest business, and your customers will thank you. I know that, if I ever considered an SSD, I would either buy Intel or an OCZ Vertex, nothing else. You know why? because they do what they say on the tin. You complain that the X25-M got a glowing review? Make a product as good as it and then Anand will sing your praises, but dont be upset when he tells it like it is.
    Reply
  • tshen83 - Thursday, March 19, 2009 - link

    Nearly everyone uses Windows and integrated SATA controllers. It still does not negate the fact that neither were optimized for SSD random IO patterns.

    No, I don't work for Samsung or its partners. It didn't cost them hundreds of millions in sales, but it did cost them hundreds of millions in inventory markdowns. Just look at the free falling of price of JMicron and original Samsung based SSDs in the past few months, and multiply by the inventory, that's the loss I was mentioning.

    I am not saying that Intel X25-M is a bad drive. It is good. but there is no reason to use crippled OS File Systems and crippled SATA controller to show off the X25-M's internal copy on write features. When windows 7 comes out of beta(soon), it will be the OS the majority of people will use, and I am just looking forward 6 months when SSD adoption rate will improve more. As to Solaris ZFS, you don't need it if you aren't mentally capable of understanding its elegance.(Most people won't and it is ok)
    Reply
  • strikeback03 - Thursday, March 19, 2009 - link

    If they had also tested with Solaris/ZFS and reported that the drives worked well there, but 99.x% of users can't take advantage of that, would you have been happier? They may work perfectly well in that scenario, but it is meaningless to most users. Working properly in Vista and OSX is currently a requirement for selling to general consumers. Windows 7 was not even available in beta at the time of the last test, I would expect they will test with it once it launches but for now with the OS/FS they are likely to use most of the available SSDs fail.

    Also, your economic analysis assumes they would have been able to sell all their inventory at the inflated prices they wanted to. Whether or not they received a negative review from sites like Anandtech, word would have gotten out from early adopters that they had problems. Also, they would have moved fewer units at those prices.
    Reply
  • tshen83 - Thursday, March 19, 2009 - link

    I could really careless if they did review SSD ZFS. I am using it right now and it kicks ass. Next Version of OSX will have ZFS so I guess Apple agrees that ZFS is the way to go here.

    Vista is one of the crappiest OS Microsoft put out in recent memory, maybe besides the Windows ME release. Just look at Vista adoption rates, and you will see why.

    You still don't understand my argument. My argument was that either File System, or RAID controller or SSD controller must implement copy on write.(basically if you have to erase a block to write to it, you are screwed) ZFS implements that in the file system. Adaptec 5 series or any Intel IOP RAID cards also help SSD performance greatly. If you don't use those two, then the SSD controller must implement it(X25-M is in this category.) You only need one of the three to properly handle SSDs to get greatly improved performance. Anandtech's review obviously skips file system optimization by picking Vista, and RAID controller optimization by picking ICH10R. What is left is the poor SSD controller that needs to virtualize the logical space, thus making the review entirely biased toward the X25-M for a good reason.

    It is sad that this is supposedly a review for the Vertex units that OCZ sent to Anand, but it seems to me that it just turned out to be another article defending the X25-M. I know X25-M is a good SSD, but it does not explain why Anand should cripple the OS, Controller so much to do it and then test the SSDs with strange IO queue depth of 3 and during the random write IOPS test, tried to cap the write space to a 8GB confinement. Those settings greatly exaggerate X25-M's internal implementation advantages.

    My economic analysis was based on SSD spot price published on dramexchange.com. Since the release of X25-M's review by Anandtech, all Samsung/JMicron MLC drives(Core, Core v2, Supertalent, etc) have been reduced to spot price of 2 dollars per GB to clear the inventories from the typical 4-5 dollars per GB that they used to command. The inventory markdown can be as high as 200+ dollar per drive and then you multiply that by the inventory that major vendors had, giving you hundreds of millions of dollars of aggregate damage sustained by the group of Samsung/JMicron partners.

    Reply

Log in

Don't have an account? Sign up now