APFS Fast Directory Sizing – How to Check if Enabled

apfshigh sierramacosperformance

Apple's technical documentation in the Apple File System Guide describes that some directories like /tmp are not good candidates for the fast directory sizing feature.

Fast directory sizing works by precomputing the size of directory as content is added and removed. Therefore, it is most appropriate for directories that contain many files and have relatively little churn. For example, a user’s Documents folder is a good candidate for fast directory sizing, whereas the /tmp directory would not.

How can I tell if a given directory has this enabled or disabled so I can choose where to do speed intensive "churn" work and where not to do that sort of work?

Best Answer

We now know the previous answer is a bit off since Apple has recently released more technical details on APFS. Fast directory sizing is indeed enabled on a per-directory basis and this can be checked by the user (albeit not easily). It can only be enabled when a directory is empty and must also be turned on for every new subdirectory as well. Details: https://developer.apple.com/support/apple-file-system/Apple-File-System-Reference.pdf

Relevant quote

You cannot enable Fast Directory Sizing on directories containing files or other directories directly; you must instead first create a new directory, enable fast directory sizing on it, and then move the contents of the existing directory to the new directory

We now know that you must set this flag to enable FDS

INODE_MAINTAIN_DIR_STATS: The inode tracks the size of all of its children

Though still unclear to me if macOS is turning this flag on automatically where appropriate or not, but some initial experimentation makes me think it isn't being used yet. I assume it will be used in forthcoming macOS updates.