The new Apple File System announced at WWDC highlights how the company is planning for the future. Here's a look under the hood at what the company will use to replace HFS+ on Macs, iOS, Apple Watch and Apple TV.
Apple's existing HFS+
Over the last three decades of Macs, Apple's file system has spanned a history where data was first stored on 800K floppies, then on magnetic hard drives where 40MB of storage was considered a lot. Today, hard drives are measured in terabytes, and most of the devices Apple now sells use Flash or SSD storage.
HFS+ has been modified several times since it was "plus" refreshed in the late 1990s (largely to accommodate bigger drives). Apple has bolted on file system Journaling, which records a continuous record of changes to files so that if something bad happens— such as a loss of power— the file system can restore a disk to a known good condition.
Apple also created a version of HFS+ called HFSX that is case-sensitive (like most Unix systems) for use with server software that expects to be able to create multiple files in the same directory that differ in only in case (file1h and file1H, for example).
And when Apple introduced iOS, it created a specialized file system based on the Mac's HFSX with support for individual file encryption used for data protection on mobile devices.
Apple has also developed storage technologies that exist below HFS+, ranging from EFI storage partitions (Intel's equivalent to OpenFirmware, which Apple pioneered adoption of when it moved to Intel chips a decade ago) to CoreStorage, the logical volume format Apple developed to support features such as Full Disk Encryption and Fusion Drive. Logical volumes are created on disk partitions and then initialized with a file system.
However, HFS+ itself still has some significant shortcomings, and continuing to bolt on new features would eventually break compatibility with the past because the file system uses some rigid data structures that can't effectively be stretched much further without requiring a non-backward compatible volume format change.
HFS+ also uses largely single-threaded data structures which require catalog file locks that that make it hard for multiple processes to access the same data at once.
Apple File System to become default in 2017
Apple currently calls APFS, its replacement to HFS+, a developer preview in macOS Sierra, but it expects to complete support across its platforms and make it the default file system for all Apple products next year.
At WWDC, the company emphasized that APFS was designed with all of Apple's platforms in mind, scaling from watchOS to iOS and tvOS to macOS, and taking advantage of the fact that most of the company's products are now using Flash or SSD storage. It also was designed with encryption in mind as a primary feature.
When complete, users will be able to upgrade from HFS+ to APFS in place
When complete, users will be able to upgrade from HFS+ to APFS in place, similar to how Microsoft migrated PC users from FAT to NTFS. User data will remain in place, and APFS will create new metadata within free space on the HFS+ volume before converting it into a APFS volume.
Developing a new Apple File System for the future
The new APFS opens up a variety of new features to support technologies on the horizon over the next decades. Apple developed its own new APFS rather than using an existing file system because most existing file systems are tuned for use cases that differ from Apple's.
For example, many high performance modern file systems are tuned to the needs of servers with multiple disks, and often optimize for throughput rather than latency. On mobile devices, latency is more critical— users want to see immediate results when they tap, more so than they need to move huge files quickly. Most Apple devices also only have one disk.
Apple already supports a high performance, shared file system for Storage Area Networks on macOS: Xsan, which supports multiple platform users accessing the same volume via FibreChannel, using a dedicated metadata controller.
To address the more common needs of its existing HFS+ users, Apple developed an advanced replacement file system tuned specifically for the typical usage scenarios of its install base of consumer devices— now exceeding 1 billion worldwide.
Advanced new structures in APFS
APFS not only introduces new features, but is designed for future expansion in mind. This includes a jump to a 64-bit inode number (used to track each file; compare to HFS+ and its 32-bit catalog record). On APFS, this enables more than 9 quintillion (a million trillion) files on a disk.
The expanded new inode structure of APFS also appears to address a core problem in HFS+ related to file and directory information being kept in a single catalog file, which serializes access and creates a logjam when multiple threads are all trying to access the file system.
APFS also improves upon the one second time stamps of HFS+ with new nanosecond timestamps, making it possible to distinguish the order of files that may be written in parallel. APFS also has an expansive block allocator that allows users to set up a new very large disk or RAID array and begin using it before the system finishes slowly initializing the entire disk (as HFS+ requires).
APFS also adds support for Sparse files (HFS+ only includes virtual support) and implements a new copy-on-write metadata scheme that's used to maximize performance over the overhead required by HFS+ journaling. It also builds in support for extended file attributes, which on HSF+ were tacked on as a B-Tree Attributes file (which HFS+ uses to store Access Control List permission attributes, for example).
APFS will also harmonize support for full disk and individual file encryption across all of Apple's platforms, using multiple keys for user data and metadata designed to protect data access even if a device is physically obtained by another party.
APFS can be used with existing Apple RAID volumes to provide software-based striping (for performance) and mirroring (data protection) or simple disk spanning (for cost savings), and can also be used on hardware RAID devices.
While the current developer preview does not yet support Apple's Fusion drives (which combine an SSD and a conventional spinning hard drive in a RAID-like hybrid device), that's clearly in the cards. Apple also stressed that its new file system is designed around the modern reality of Flash and SDD storage, which presents different characteristics than spinning magnetic disk storage.
New features designed into Apple File System
In addition to greatly advancing and refining the basic design of HFS+, APFS also introduces a variety of completely new features.
This includes Space Sharing, which enables multiple volumes to claim the free space on a disk. That means a 4TB disk could have 4, 4TB volumes created on it, allowing each volume to expand as needed without creating a problem of having to repartition the volumes to assign more space to one of them. This could particularly benefit users of virtual machines (or Boot Camp Windows users) where a given disk volume on disk needs to create a very large file.
Another new feature, Clones, allows files or even entire directories to be instantly "copied" without using up storage space. This supports the idea of "duplicating" a document or an entire workflow, and then making multiple sets of independent changes to each copy. Because the changes are saved separately, the bulk of the parallel projects can be stored as one pristine copy, saving lots of otherwise wasted disk space.
APFS also supports Snapshots, which work something like Clones on an entire file system level; they preserve the state of an entire file system at a given point in time, recording new changes separately so that the system can efficiently backup and roll everything back to a clean slate Snapshot. This has applications in education and other shared systems, as well as being a more efficient and less convoluted way to backup devices compared to Apple's existing Time Machine, which saves backup points in time using on hard links.
Another new feature is Fast Directory Sizing, which enables the file system to calculate the space used by a folder and all of its contents and then keep this figure up to date. HFS+ has to regularly recalculate this information any time you Get Info on a folder because it can't simply store this data in a folder directory itself or percolate this information up the file system hierarchy (because child items can't lock their parent).
Because many files or apps on Apple's platforms are actually directories of contents ("Bundles") that merely pose as a singular item for simplicity, APFS introduces a feature called Atomic Safe-Save that ensures that when updates are being saved, the process can't be interrupted, resulting in a partially-saved (and possibly corrupt) item. The process is "Atomic" because it either successfully completes or doesn't, but won't end up in a split condition of uncertain status.
Origins and evolution of Apple File System
It's notable that Apple has been expanding upon HFS+ for years. Apple hired file system guru Dominic Giampaolo back in 2002, before the company even had a significant mobile device business and at at time when Macs were just transitioning from the classic Mac OS 9 to the new OS X, and would remain PowerPC based for another four years.
Giampaolo was perhaps best known for developing BeFS in 1996, an advanced file system of its time designed for BeOS (above). It relied heavily on extended file attribute metadata that the system could index to enable users to quickly search for data like a relational database. Today, iTunes and Photos similarly present collections of items in an easy to sort and search fashion.
Giampaolo literally wrote the book on file system design. After joining Apple, he worked on adding file system journaling to HFS+ (which was turned on by default in Mac OS X 10.3), and then initiated the Spotlight project to bring BeFS-style, indexed metadata search to the Mac (a feature which debuted in 2005).
Giampaolo also worked on Time Machine and the wireless Time Capsule product for backups, and helped develop the initial Documents and Data implementation for iCloud in 2011.
He also cited work on a "file system that never shipped," and Apple separately worked on adding support for ZFS on Macs, before abandoning the effort in 2009 (apparently related to licensing issues, although the sudden rise of iPhone likely also shifted Apple's strategy).
Giampaolo is now working on APFS as a senior software engineer in Storage and File Systems, applying the experience of a couple decades of developing file system-related features.
Once deployed next year, APFS will not only enable new new features and optimize performance and the utilization of modern storage systems, but will also serve as an extendable platform for introducing new file system advances in the future.