A couple of days ago, I claimed that a rule-of-thumb guesstimate for the space used by extended attributes (xattrs) for the files in my Home folder might be 0.8 GB. I have now checked that by measuring the total size of the xattrs on my iMac, and can confirm that I was pretty wildly wrong: that was a gross underestimate. Xattrs are both more common and larger than I had ever thought.
I have an unreleased app, XattrXverser, which I use to chug painfully through different folders on my Mac analysing different aspects of xattrs. It can work out which different types of xattr are being used, provide examples, and give basic figures about how common each is. It wasn’t a difficult job to provide it with an option to total up the space occupied by all the xattrs for every file, as it traversed its way through the hierarchy of folders.
My iMac17,1 has an internal 2 TB Fusion Drive, and runs Sierra 10.12.6. It does have a few files deliberately constructed to test xattrs out, but there’s only a couple of dozen of those, at most.
Disk Utility tells me that its Fusion Drive contains 1.113 TB of data. XattrXverser arrives at a total xattr size of 4.520 GB.
Distribution of xattr data is very uneven. The /System folder has just over 1 KB between its 322,616 files, whereas my Home folder has a total of 3.838 GB. That is a lot more than my suggested 0.8 GB. These are summarised in the pie charts below: that on the left shows the breakdown of total xattr size, that on the right is for data size, as given by the Finder’s Get Info.
I had not expected xattrs to be so heavily used in the /Library folder, but the average size of xattrs across its files which have xattrs is just over 7 KB per file. I had expected them to be commonplace in my Home folder, but am surprised that the average total size of xattrs across all the files there (not just with xattrs) is just over 2 KB.
Even in my Home folder, xattr use varies quite widely. The fewest and smallest are in ~/Music, which averaged less than 100 bytes total xattrs per file (with or without xattrs).
The largest contribution is in ~/Documents, which has a total of 2.6 GB of xattrs across less than half a million files. However, a lot of my images in ~/Pictures still seem to sport thumbnails, so the average total of xattrs per file with xattrs is there almost 21 KB – that’s 0.796 GB in only 38018 files.
The pie chart below summarises the total sizes of xattrs across different folders within my Home folder, and shows the lion’s share are in ~/Documents.
The percentage of total space used that is taken up by xattrs is quite small, around 0.4%. This rises to 0.45% for my Home folder and /Applications, which happen to be two of the three largest folders in any case.
In terms of sheer storage space, that used by xattrs totals to slightly less than half the size of /System, which is neither here nor there. But for many files, such as images and those in ~/Documents, the space occupied by xattrs is significant relative to the total file size. It certainly can’t be ignored.