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
Comments Locked

250 Comments

View All Comments

  • ryedizzel - Thursday, March 19, 2009 - link

    Anand,

    I just wanted to thank you for an amazing article. I am a very picky buyer and technology critic, so I always come to your site for the ‘real’ story on things. In fact for the amount of time, research, and (useful) testing methodologies you invest, I almost feel guilty receiving this information for free. Especially since your findings benefit the industry as a whole since it causes manufacturer’s to fix/improve their products (well at least the smart ones do). The i7 motherboard roundup was another great example of this. Seriously, if you have a place for donations I would send you $50 in a heartbeat. I know it’s not much but if others did the same it would add up to a decent token of appreciation.

    Oh and please don’t take people’s grammar or nitpicky corrections the wrong way. Yes it can be annoying, but in the end it does help the article become closer to perfect since others catch little things overlooked by human error. In the end we are all grateful for these articles, otherwise we wouldn’t be here reading them!
  • bsoft16384 - Thursday, March 19, 2009 - link

    You know, the JMicron SSDs really aren't so bad. Yes, you'd have to be crazy to spend $400 on one when there are better options like the X25-M (or the new Vertex series for that matter).

    But I paid $65 for my 30GiB OCZ "Core" SSD. Yeah, random writes are piss slow. I knew this. The drive replaced the 5400.5 that came with my EEE PC.

    I'm not going to be doing any 'extensive multitasking' on my EEE. I'm not running a file server, I certainly don't have antivirus in the background, and I don't spend all day installing new apps.

    I'm running 7. Compared with the 5400.5, the system boots faster, Chrome loads faster, but Windows updates take longer. That's a trade-off I'm willing to deal with, considering that I get less noise and more battery life in return.

    I can tell you this - the JMicron SSDs beat the pants off of the PCIe MLC SSDs that ship with many netbooks.

    So, yeah, I guess this is a product that's "unfit for market". But it's perfect for some of us. If I wanted a boot drive for a Linux media/backup server (along with HDDs for storage), I could see choosing a $50 SSD over a $50 HDD.

    It's all about your needs. No one is pretending that JMicron SSDs are fast, at least not at writing. But if your usage is mostly read-centric (or "nothing-centric", as is frequently the case on netbooks), and your chief criteria are low power and low price, the JMicron SSDs do quite well.
  • petersterncan - Thursday, March 19, 2009 - link

    Anand,

    That was an awesome article... and good for you to give OCZ to do the right thing... and they did!

    Kudos also to OCZ for actually listening to feedback and doing something about it.

  • Adul - Thursday, March 19, 2009 - link

    Good work Anand :)
  • SSDMaster - Thursday, March 19, 2009 - link

    The stuttering problem with SSD's can be fixed with diskpart. Go do some research before you post an article this massive and convoluted.
  • goinginstyle - Thursday, March 19, 2009 - link

    No it does not, it will help if the partition is properly aligned but it is not a cure, neither is the rest of the voodoo magic being spouted on the OCZ forums. They help, but do not cure the stuttering problem with the JMicron based drives. I just love the fact that OCZ wants to sell you a drive (Core series) that does not work properly, have you purchase third party software, and then hack the OS in order to improve the performance of the product. Glad to see it fixed with the Vertex and Summit drives though, but it will take a long time before I even think about using an OCZ product again. I was hoping to see the new ADATA and SuperTalent drives in this article, maybe those are coming in the next segment he mentioned.
  • SSDMaster - Friday, March 20, 2009 - link

    Yes, it does.
    I have a Core series 60GB OCZ drive. I bought it right before Newegg increased the price on the drives. The stuttering was horrible, and worthless even as a secondary drive if it was formatted with XP. Also, after using Diskpart and aligning the drive I could not install XP on the drive and have it bootable.. Which sucked.

    But there's ways around that, and guess what, I have a stutter free flash drive for cheap that gets very good performance numbers, and boots Server 2008 in under 10 seconds.
  • bsoft16384 - Thursday, March 19, 2009 - link

    OCZ's product works fine. You may not like the performance, but it's certainly not unusable.

    The $65 I paid for my 30GiB OCZ "Solid" SSD is about what you'd pay for a USB flash drive. The disk I have has a USB interface, which is very convenient, plus it's plenty fast enough for my EEE PC.

    I'm glad that Anand has done these reviews. People need to understand what they're getting into when they by a JMicron SSD. If you don't expect much, you won't be disappointed.

    Arguably for a normal notebook/desktop you should buy a normal hard drive if your budget is under $100. But the JMicron SSDs do a good job in netbooks (which, again, aren't too fast to begin with) at a very low price.

    I have aligned my partitions and disabled swap on my Windows 7 install (on my EEE). I also have 2GB of memory in my EEE. I haven't done any fancy tweaking on the OS.

    Compared with the EEE 900A that I had briefly (PCIe SSD), my EEE 900HA is dramatically faster. You can't run XP or Vista on PCIe SSDs unless you have a lot of patience. You *can* run it on a JMicron SSD.

    I honestly don't notice any stuttering. I don't run antivirus and I don't multitask much on this machine. If I demanded from my EEE what I demand from my desktop (Q9300 + 8GB + WD6400AAKS), I know that the SSD would choke up. But I'm not going to do that on a 1.6GHz single-core Atom anyway.

    So, yeah, OK. I guess I think that trashing JMicron SSDs is a little like trashing USB flash drives for being slow. Paying $300 for a UFD would be stupid, as is paying $300 for a JMicron SSD. But in the sub-$100 category, you don't expect much.

    When better SSDs drop below $100, maybe I'll upgrade. Until then, I'm enjoying 5 hours of battery life on my 900HA.
  • tomoyo - Thursday, March 19, 2009 - link

    Well I think it's unusable for my needs if I'm running it as an operating system drive. I place a giant important on the latency of the drive at that point and it certainly includes random writes. Which is why I would never ever buy an ssd that's majorly below the Intel write performance. It's not worth the price premium or loss of storage size compared to the standard hard drive.
  • Bikerskummm - Thursday, March 19, 2009 - link

    Fantastic article Anand!

    Just a few thoughts:

    I have had some trouble replicating some of the Samsung SLC results...

    Despite filling the drive up and emulating a well used drive as described in the article I cannot get my Sammy drive's performance to degrade as much as you managed to especially regarding random write performance...

    Now my system used for testing is a socket 775 (qx9650) and I was testing on ICH9R and WINXP (SP3) but still I would expect to see similar figures ...

    I do not have an X58 system to test on at the moment but I would be very interested if The Sammy SLC drives were shown to degrade faster / perform worse with a X58 / ICH10R / Vista x64 (SP1?) setup...

Log in

Don't have an account? Sign up now