Friday, October 11, 2024

A Brief History of Defragging

Howard Oakley:

All storage media, including memory, SSDs and rotating hard disks, can develop fragmentation, but most serious attention has been paid to the problem on hard disks. This is because of their electro-mechanical mechanism for seeking to locations on the spinning platter they use for storage. To read a fragmented file sequentially, the read-write head has to keep physically moving to new positions, which takes time and contributes to ageing of the mechanism and eventual failure. Although solid-state media can have slight overhead accessing disparate storage blocks sequentially, this isn’t thought significant and attempts to address that invariably have greater disadvantages.

Fragmentation on hard disks comes in three quite distinct forms: file data across most of the storage, file system metadata, and free space. Different strategies and products have been used to tackle each of those, with varying degrees of success.

[…]

Manually defragging HFS+ hard disks was always a questionable activity, as Apple added background defragmentation to Mac OS X 10.2, released two years before Coriolis was even founded. By El Capitan and Sierra that built-in defragging was highly effective, and the need for manual defragging had almost certainly become a popular myth.

I would agree that defragging became much less useful since the days when I was using the Speed Disk component of Norton Utilities on System 7. But my recollection is that HFS+’s automatic defragmentation didn’t fully solve the problem because it wasn’t able to work on all files (notably skipping large ones, which could have hundreds or even thousands of fragments for a single file) and didn’t consolidate the free space. iDefrag remained useful for spinning disks until the advent of APFS.

APFS also has built-in defragmentation, which in some cases I enabled myself and in other cases seemed to have been automatically enabled. I haven’t noticed any improvement from enabling it, which is unsurprising since Oakley and Mike Bombich say that it doesn’t defragment the file system metadata. APFS performance remains really bad on spinning disks, in my opinion.

Previously:

6 Comments RSS · Twitter · Mastodon


I remember one of the joys of switching from Windows to Mac OS X in the mid 2000s was just not having to care about fragmentation any longer. In spite of the above that mentions situations where fragmentation could still have been an issue, I never concerned myself with it and never had a problem with it.


"APFS performance remains really bad on spinning disks, in my opinion."

You're being too kind. Apple made a huge mistake in allowing APFS on spinning disks. I've personally seen 4 systems (one Mac mini, three iMacs) which became functionally unusable after updating to Mojave (which automatically converted the disk to APFS). Program launch was the most egregious slowdown.

In one case (the mini) I wiped the disk and reinstalled the original OS, then updated it to High Sierra. Worked great and I still use it as a Time Machine destination.


@Keith I don’t think they had any choice; their entire modern data-on-rest security is built on top of APFS. So it was either not support spinning disks at all, which Apple was not in position to do, run without security on spinning disks, or just go slow. They chose to ruin their users’ experience but be secure. This is inline with every decision Apple has made for many years.


"They chose to ruin their users’ experience but be secure." Very well put. Especially the part where it's ambiguous whose security Apple cares about, since more often than not it seems to be about them and not the user.


@Léo Did they have a choice to make APFS more friendly to spinning disks? It seems like there are things they could have done that would have helped but they just didn’t care.


@Michael I’m not sure. I haven’t really read about FS design and what makes one so hostile to spinning disks. I just know that this is a shared trend among modern file systems, such as btrfs, bcachefs, ZFS and, to some extent, ExFat.

Leave a Comment