9

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?

2

Short Answer

FDS is a fundamental part of the file system in APFS formatted drives. It is not something users need to enable/disable, and it's not something that can apply to one directory and not another.

As it's an 'all in' scenario, there aren't any terminal commands to determine if a directory has FDS enabled. Instead, if a drive is formatted in the APFS format then FDS is enabled. If it's not formatted in the APFS format, then FDS isn't available.

Long Answer

Unfortunately, the information you've quoted from Apple's technical documentation is badly worded, hence the reason for your question.

If a drive is formatted in the APFS format then Fast Directory Sizing is applied across the board. FDS is not something a user can enable/disable on a per directory basis.

Because of this, it's also not something a user can determine the status of on a directory by directory basis. That is, if the drive is formatted as APFS then all directories have FDS enabled.

Where the confusion comes from (and understandably so in this case) is the bad choice of words in Apple's documentation and the ambiguity that created. What this information was trying to convey is that a user will benefit most from FDS in those directories that have lots of files but change little (e.g. a user's Documents folder), whereas they will not get much benefit (if any) from FDS in directories like the /tmp folder.

As an aside, the documentation you referenced has since been replaced by the About Apple File System page. The only mention of FDS on this page is as follows:

Apple File System offers improved file system fundamentals as well as several new features, including cloning, snapshots, space sharing, fast directory sizing, atomic safe-save, and sparse files.

There is no attempt to further explain what FDS means, beyond the fact it's a fundamental (read underlying) feature. However, if you're interested in some background:

In complex and deep directory structures in HFS+, we are familiar with the time the file system could spend on calculating the size of the file system tree. This is one of the common reasons that the system would hang. Apple, with APFS, introduced Fast Directory Sizing (FDS), where the file system can quickly compute the space used by a directory hierarchy, in order to remove this problem.

Source: Hansen, K.H., Toolan, F., Decoding the APFS file system, Digital Investigation (2017)

  • Is it true that if a drive is formatted as APFS that all directories have FDS enabled? This comment suggests that it is set on a per-inode basis, and that you must create such a directory first and then move items into it. Certainly on my own system, the folder sizes don't seem to display very quickly at all in the Finder (this was an upgraded system; not a clean install). – wincent Nov 13 '18 at 17:14
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .