OK, here’s the deal: I’ve got a Mac, I’ve got an SSD. My SSD’s firmware supports the TRIM command, which means that on operating system’s that support said command, deleting files actually causes files to be deleted, rather than marked as deleted. The benefit of this is that next time something has to be written to that spot, it can just be written, rather than deleted and written. Mac OS X does not support this command. Furthermore, my SSD’s firmware isn’t the brightest of things: it doesn’t intelligently know where to put new files… at least not when the drive is 75% full. It also doesn’t have a feature called Garbage Collection, which essentially performs something similar to TRIM when the drive isn’t in [much] use, without the OS knowing a thing.
To summarize, I have a cheaper SSD and it’s not the brightest, best thing on the block. Had I known about all these problems before I bought it, I would have sprung for a more expensive one, with all the bells and whistles that I need. But here’s the thing: it’s still really fast for reading files. Given that I have a MacBook Air, the alternatives to SSDs are extremely slow 1.8″ hard drives, so while I’ll eventually get a better SSD, I’m not going back to mechanical hard drives. Even when I change my computer, to whatever I chose, my SSD is coming with me or I’m getting a new one. Applications literally launch instantly, it’s unbelievable. I can’t go back to a spinning platter!
Now, all these things out of the way, you’re probably wondering what the problem is. The problem is that the biggest limitation of the drive is when writing dozens of little files to disk, because with the deletion of a tiny file and re-creation of the same file, the system slows down to a crawl. In mast applications, this isn’t a problem at all. When writing code, it’s a tiny bit of a problem (on small programs, anyway) but not the biggest problem in the world.
Where the SSD utterly fails is
A- write performance degradation over time
B- applications that are very generous with small cache files
The second I will get into first, because it is actually very specifically talking about one app in particular: Safari.
B – Solutions:
Safari (4, 5… whatever!) is a little cache monster. I have studied its behaviour and even with caches turned off in the ‘Develop‘ menu (which you can get in Safari > Preferences > Advanced > Show Develop menu in menu bar) it slows down after enough time has passed.
Safari is quite fast on other computers, but on my SSD (and other cheap SSDs) the constant writing of little files makes it unusable over time. It stores many things: bookmarks, history, cookies, extensions, web forms and passwords, but most importantly: webpage previews (screenshots of every site you visit!), and your cache. These two items are what are constantly being written to disk , and the way Safari does it mocks us cSSD (cheap SSD, you heard it here first!) users: it creates a tiny file, presumably reads the tiny file, then deletes the tiny file. Over, and over, and over again.
B – Solution 1: other browsers
Use Chrome, or Firefox, both of which manage cache more intelligently. How to do this seamlessly? Install X-marks for every browser you wish to use, enabling your bookmarks to sync between all your browsers, and in Firefox install the Add-on “Keychain Services Integration” to allow it to use the system keychain for passwords. And there you go: all your passwords and bookmarks available system-wide!
The caveat is that the Safari bookmarks are in their own folder. Where most browsers have 2 bookmark locations: a bookmarks menu and a bookmarks bar, Safari has three: an additional ‘Bookmarks’ location. What I have done is within the bookmarks bar, created a folder called ‘BOOKMARKS’ and put everything in Safari ‘Bookmarks’ in that folder… here’s a screenshot:
|Move BOOKMARKS elsewhere|
rm -f ~/Library/Safari/WebpageIcons.db
rm -f ~/Library/Safari/WebpageIcons.db-local
rm -f ~/Library/Caches/com.apple.Safari/Cache.db
rm -f ~/Library/Caches/com.apple.Safari/Cache.db-local
rm -fr ~/Library/Caches/com.apple.Safari/Webpage\ Previews
mkdir ~/Library/Caches/com.apple.Safari/Webpage\ Previews
The first set of commands deletes all the files, and the second set re-creates them. the .db files are the actual database files in which things ore saved, the -local files are the scratch files that Safari writes things to before writing them to the database files (we have to consider these because otherwise the disk will still be written to for no reason once the caches are disabled), and the folder ‘Webpage Previews’ is deleted, with all the snapshots that Safari takes (you’d think it’s a photographer if you looked in that folder before deleting stuff…).
Next, navigate to your Home folder > Library > Safari, and you’ll see WebpageIcons.db and WebpageIcons.db-local. Right click on each, goto Get Info and check Locked. A little lock should appear below the icons for these files. You may close the Get Info window. Do the same for the files Cache.db, Cache.db-local, and the folder Webpage Previews in your Home folder > Library > Caches > com.apple.Safari
|Locking files: commanding with an iron fist!|
…and there you have it! Safari is fast again! If there’s anything I missed, I’ll eventually stumble upon it and post it here, but so far it seems that I can BREATH! Safari will still need to write to disk to update your history, top sites, bookmarks, and other settings, but it doesn’t do this constantly and so it shouldn’t be a problem. Alternatively, I have found that creating a RAM disk, and placing both folders Caches > com.apple.Safari and Library > Safari in it, then creating symlinks and placing those where the original folders should be. The speed increase is technically faster, but in practice there’s not much difference. Certainly nothing insanely noticeable. The problem with a RAM disk is that it needs to be unmounted eventually, and so if the full folders are there they need to be saved elsewhere first, and if something crashes you could lose your bookmarks. You could also put only the files we played with above in there, but then you take up a lot RAM needlessly, though there are some speed benefits from loading things from cache. Overall, the above is a great way to muck with as little as possible while using Safari (my favourite browser!) with a cSSD.
If that’s the only slowdown you notice with your cSSD, you can stop here. Otherwise, there are additional methods I have found that work to ‘TRIM’ your SSD, without installing Windows and running a TRIM utility for your drive. These solutions cost money, but may be worth it if you feel like your SSD isn’t what it was when you first got it.