Why and how to check your SSDs Trim correctly

Brajeshwar2 pts0 comments

Why and how to check your SSDs Trim correctly – The Eclectic Light Company

Skip to content

Writing data to an SSD is really little faster than a good hard disk, but SSDs cheat better to improve their performance. This is because, before the SSD can write to a memory block that has been in use, it must erase it, and its erase-write cycle time is abysmally slow.

The cheat is simple: instead of waiting to erase blocks when they’re required for writing, they’re erased in advance and left in a free pool ready for use. That in turn relies on your Mac telling the SSD which blocks it can erase because they’re no longer being used by its file system, a process known as Trimming, after the TRIM command used in SATA SSDs. To be pernickety, NVMe SSDs don’t use a TRIM command, but its equivalent is DEALLOCATE to perform the same task.

Most modern SSDs also perform their own housekeeping that may reduce or eliminate the need for Trimming, but some don’t, and when they’re left untrimmed they eventually become extremely slow at writing.

Does an SSD Trim?

There’s a lot of black magic about Trim and Trimming, but one of the basic pieces of information you need to confirm about any SSD you use with your Mac is whether it supports Trimming. If it does, then you should never see severe performance degradation resulting from that SSD being left untrimmed.

If you suspect that an SSD might be suffering the effects of being untrimmed, the easy test is to check its read and write performance, as Trimming doesn’t affect read speed at all. If its write speed has fallen to 20% or less of its read speed, then you can be confident that there’s a Trim problem. Unfortunately the only curative treatment is to fully reformat the SSD and see whether that restores normal write speed.

As a general rule, all Apple internal SSDs enjoy full support for Trimming, and third-party external drives with NVMe interfaces should too. Slower drives with SATA interfaces are those most likely not to support Trimming, and are also those that are hardest to get useful information about. You may find Trim listed in a relevant section in the Hardware section of System Information. Device trees worth inspecting there include USB, NVMExpress, PCI, SATA, Storage and Thunderbolt/USB4, but in many cases you’ll draw a blank.

Trimming isn’t supported by all file systems either. While both APFS and HFS+ will normally Trim an SSD each time it’s mounted, a drive formatted in an old PC file system like ExFAT is most unlikely to be Trimmed at all.

This may still leave you wondering whether an SSD is being Trimmed properly. Provided it’s formatted in APFS, there’s a reliable way to tell by mounting the drive and checking entries by APFS in its log during the mount process.

How to verify Trim

Use Mints to verify whether your external drive does get trimmed correctly when it’s mounted, using its Disk Mount feature. What you do is:

Eject and disconnect the external drive.

Connect the drive at a known time, according to the Mac’s clock, for example the moment the seconds turns to 00.

Leave the Mac alone until all that disk’s volumes have been mounted.

20 seconds after connecting the drive, or 10 seconds after the last of its volumes has mounted, open the Mints app.

Click on the Disk Mount button, and set the time in its log window to the time at which you connected the drive.

Set the period to a minimum of 20 seconds, long enough to cover the period up to 5 seconds after the last volume mounted.

Uncheck all the category checkboxes except the first, APFS + .

Click the Get log button.

When log entries are displayed, scroll to the end and look back for APFS trim entries as shown below.

This only works for APFS, though, as log entries for HFS+ don’t show Trimming clearly. If you’d rather use a different log browser like LogUI or the log show command, use the predicate senderImagePath CONTAINS[c] "apfs", or in LogUI set senderImagePath in its Predicate menu to apfs.

Shown in black are many log entries, a few of which come from APFS. You should look for those whose message starts with spaceman_scan_free_blocks, as those record the APFS Space Manager Spaceman scanning for free memory blocks and Trimming them.

Here are example entries following the mounting of a USB 3 SSD with NVMe, with times in seconds elapsed:

04.171 spaceman_scan_free_blocks:4461: disk5 scan took 0.026856 s (no trims)

08.803 spaceman_scan_free_blocks:4431: disk5 scan took 4.631657 s, trims took 4.604585 s

08.803 spaceman_scan_free_blocks:4435: disk5 477294662 blocks free in 30305 extents, avg 15749.70

08.803 spaceman_scan_free_blocks:4444: disk5 477294662 blocks trimmed in 30305 extents (151 us/trim, 6581 trims/s)

08.803 spaceman_scan_free_blocks:4447: disk5 trim distribution 1:8683 2+:5170 4+:9375 16+:3045 64+:2249 256+:1783

08.803 spaceman_scan_free_blocks:4455: disk5 trims dropped: 14590 blocks 10757 extents, avg 1.35

Here’s a set from a Thunderbolt 5 SSD:

04.854...

trim trimming apfs ssds drive spaceman_scan_free_blocks

Related Articles