I have replaced my traditional HDD with an Intel 525 SSD (120 GB, mSATA) recently. To keep the write performance high a TRIM option should be enabled. You can either mount the drive with ‘discard’ option, or you can run fstrim command periodically. (This can be a bit trickier if you have LUKS encrypted partitions).
The discard option performs TRIM immediately when a file is deleted, and there is some performance hit involved. You can work around that by having fstrim in a cron job and trimming the disk just once a day or so. It takes longer (about a minute in my case), but it is not a continuous performance hit.
Two years ago Patrick Nagel published a blog about discard performance on his OCZ Vertex LE (100 GB). I was curious whether the numbers would be the same for my SSD. Let’s have a look.
With and without discard option let’s do:
- Extract linux sources (linux-3.9.1.tar.gz; 45168 files, 592 MB extracted) including sync operation.
$ time (tar xzf linux-3.9.1.tar.gz ; sync)
- Remove the directory including sync operation.
$ time (rm linux-3.9.1 -rf; sync)
Of course, a few warmup rounds are included. The numbers are averaged from three passes. I have an ext4 partition on LVM on LUKS.
You can also view the raw data.
As you can see, there is a substantial hit on deletion. Removing 45k files was almost 4x slower. But, on the other hand, we’re talking about mere few seconds here, which is way better than in Patrick’s example. I guess the SSD controllers really improved in two years.
I also did a quick second test with deleting a large (3 GB) file. The results are similar – without discard it takes about 0.43s and with discard it takes about 1.65s. So there is no substantial difference between deleting a huge number of smaller files and deleting a single big file.
The output? If you are a general user with no specific needs and you don’t want to bother with cron scripts, you can simply enable the discard option and have your life easier. Of course, we’re talking about Intel 525 here. If you have some other SSD, especially an older one, it might be a good idea to measure the numbers yourself.