OS X Understanding & Enabling SSD Trim Support December 31st, 2011
Over the past few years, our understanding of SSD technology has advanced significantly. In theory, SSDs are a massive improvement over conventional spindle drives with no major weakness to speak of. No longer does your computer have to wait for a motor powered platter to rotate into the correct position every time you want to access a piece of data; it can now grab it instantly from a bank of memory cells inside the SSD. As well as this dramatic increase in performance gone is the noise, the heat, and importantly the power consumption, and in its place smooth, silent, virtually instant data transfer.
Well, that’s the theory anyhow.
The reality is that whilst a lot of the above is true, an SSD is not immune to problems like any other hard drive; one of the biggest of these problems is the way in which SSDs handle deleted data and the way this causes overall performance to tail off after continual use.
First, we need to understand the problem.
SSDs are split into multiple cells. Imagine for a moment a brand new SSD with a clean 20kb cell, the drive writes two 10kb files into this space at its full write speed, so far so good. Later, you delete one of these 10kb files as it is no longer required. The SSD will now simply mark the unwanted 10kb space as an area that is available to be rewritten, this is exactly the same behaviour you’d expect from a conventional spindle drive; the important point to note here is that neither the SSD nor the conventional spindle drive actually deletes the physical data. The difference comes when you need to right new data into the 10kb space.
The conventional spindle drive will simply write over the 10kb of space when the new data comes along however when the SSD comes to rewrite data to the 10kb of free space in the now dirty cell – in order retain the 10kb file still there – it must first read that data to its controller, wipe the whole 20kb cell clean and then rewrite the complete set of valid data, old and new, into the cell. Over time, this continual rewrite process has very little impact on the performance of a conventional spindle drive however the read-modify-write process employed by the SSD will drastically reduce performance on the SSD in comparison to writing data to new, clean cells. This behaviour is the main cause of SSD performance degradation over a period of time, especially for heavy users accessing data daily.
Ironically, for a device which can, at least in theory, address any given cell at the same speed, SSDs can also become subject to fragmentation as a side effect to dirty NAND. Having numerous cells filled with deleted data means the drive needs to perform more and more read-modify-write cycles when writing files to the drive which over time causes yet more performance degradation. A heavily fragmented SSD will also have no choice but to spread files over even more cells, forcing the drive to address all those cells too when reading data; this of course has the effect of reducing the overall read performance of the SSD as well as the write performance.
SSD manufacturers are aware of these issues of course and there is a fix by way of the TRIM command. TRIM reorganises written data on the SSD and scrubs deleted data as soon as it has been deleted (this is triggered by a delete command, clearing the recycle bin or, reformatting the drive). This means that when the drive needs to write data to that cell again, there is nothing but clean NAND waiting negating the need to perform the read-modify-write process, therefore ensuring the optimum write performance is maintained and does not degrade with use. However, in order for TRIM to work, support is required not only within the SSDs firmware but also the host OS. Windows 7 shipped with TRIM support out of the box and I can say from personal experience, it makes a huge difference. The problem with OS X is that TRIM support is very limited.
TRIM is officially supported in OS X 10.6.8 or greater, but is limited by the fact that it only supports Apple branded SSDs.
Take a look at About This Mac>More Info>Serial-ATA and you’ll notice unless you’re running an Apple SSD the TRIM support flag is set to ‘No’. It seems a deliberate oversight on Apple’s part, no doubt to try and convince you to buy their own branded drives (which by the way you should never do, they are way over-priced and old technology) but as always there is a way to enable TRIM for other manufacturers SSDs. To enable TRIM support, simply download an app called TRIM Enabler which works by loading a kernel extension from MacBook Pro 2011 models (with TRIM support) into your Mac OS X kernel, this forces TRIM to be enabled; all you have to do is download and mount the DMG file and click on Patch. Simples!
Caveat: This is completely unsupported software and is not endorsed by Apple. I am not responsible for any damage or data loss that may result from enabling TRIM. Always have a backup of your data and proceed carefully at your own risk. If you decide to download the above patch and enable TRIM, you do so of your own choice.
Notes: I have tested TRIM Enabler on my MacBook Pro (early 2011) i5 running OS X 10.6.8 Snow Leopard without issue. After a reboot, the TRIM support flag changes to ‘Yes’ and the system runs normally without any issues, it’s too early to tell if having TRIM enabled will keep my read/write speeds consistant but I will run some benchmarks and report back at a later date with a comparison.
I hope this may be of use to someone, please feel free to share your experiences in the comment box below.
Tags: apple, MacBook Pro, os x, ssd
This entry was posted on Saturday, December 31st, 2011 at 3:32 pm and is filed under Apple, Blah, Lion, Mac OS X, MacBook Pro i5, Snow Leopard, Technology Related. You can follow any responses to this entry through the RSS 2.0 feed.You can leave a response, or trackback from your own site.
One Response
Ross Mckenzie Says:
Mike.
Good explanation thank you. If I understand correctly then TRIM is only going to benefit a clean install of an OS/DATA on an SSD? ie the pre TRIM enabling state will not benefit?
The reason for asking is I have a mid 2009 MacBook Air running Lion which leads to 2 questions. (Q1) How can I tell if my Apple supplied mid 2009 stock 128Gb SSD is TRIM compatible (Q2) There will be a significant proportion of cell area (2 years use) marked on my 128Gb as available for rewrite. Assuming my SSD is TRIM capable and I enable it – I assume my first 2 years worth of use will not be intelligently marked for deletion as per TRIM’s design and intent?
Incidentally, Grant Pennell’s article at http://digitaldj.net/2011/07/21/trim-enabler-for-lion/, is compelling, offering a simple and safe method to enable TRIM on OSX for 3rd party SSDs, as an alternative to TRIM Enabler.
For general info to your readers:
I have installed a 240GB Vertex II Sandforce in both my partners work MacBookPro and an older MacBook for a family member and have been staggered by the performance increase (boot times reduced from >2 mins to <25 seconds including all menu bar items. Near instantaneous application response – ie. select a document and the application and document load as if both were sat open in the dock…). I do not intend to enable TRIM on these 3rd party SSDs; I will rely on the Sandforce implementation to do its job and have read that whilst Sandforce supports TRIM it could be counter productive in such drives that have already addressed the issue in their own way.
It is these installs that made me read up and more aware of current generation SSD limitations. This got me thinking about the native SSD installed in my 2009 MacBookAir, I was blissfully unaware at purchase that it will slow with time, and eventually, if I understand correctly, be unable to write at all (not wishing to overstate the issue though – 'with time' is relative).
I have been so impressed at the cost vs reward that the next job will be to implement a 128GB SSD in my workhorse iMac for the OS, and have the data on the stock HDD. A little more involved but will no doubt be worth it and the ideal compromise I feel of OS on the SSD with minimal rewrites required, with data on a std HDD.
General word of advice for all tinkerers though, grab a £5 2.5" caddy for the drive you replace, partition it and Time Machine backup to one half and Carbon Copy Clone a bootable to the other half on a suitable repeat schedule for the day your SSD leaves you hanging… If it looks to good to be true, then it probably is…

