Apple's HFS vs APFS Filesystem - Which One We Chose For Our Customers, and Why !!

Apple's HFS vs APFS Filesystem - Which One We Chose For Our Customers, and Why !!

Introduction

Apple released their ingeniously named Apple File System (APFS) in 2017. Officially, it was released to cover shortcomings of HFS+, like data checksums, and included new features to provide better support for Apple products.

While new file system sounded great and had a lot of pro behind it to make it a choice of file system, but we wanted to compare both from every angel. So we did just that. We compare HFS+ and APFS to determine how the file systems stack up for end-users. In particular, we focused on understanding the performance requirements of our end users (if there are any).

Understanding HFS

Mac OS Extended (HFS+) was introduced in 1998 for Mac OS 8.1, the previous iteration of the desktop operating system found on Apple's computers. Marking the switch to Intel-based processors, Apple introduced OS X, a redesigned operating system based on UNIX capable of running on the new hardware.

HFS+ was initially retrofitted to support the transition to a UNIX-based OS and has been augmented throughout the years to add new features, including compression, journaling support, and whole disk encryption (FileVault Feature).

Pros of Apple's HFS+

  1. Supports all versions of Mac OS X and macOS
  2. Encrypted volumes are accessible by any version of Mac OS X and macOS
  3. Supports Fusion drives

Cons of Apple's HFS+

  1. Concurrent access to the file system by a process is not allowed.
  2. No snapshots
  3. Limited native file support for other file systems
  4. Timestamps do not use the nanosecond standard.
  5. Checksums for data integrity are missing.

Understanding APFS

The final code for Apple File System (APFS) was released to the public alongside macOS High Sierra in 2017. Apple's newest file system is the default for new installs and upgrades unless otherwise specified by the user. APFS was designed for flash-based devices, making it a suitable solution that scales Apple's entire line of devices.

APFS has been known to increase read/write speeds on Solid-State Drives (SSDs), as well as increase storage space due to the way in which it calculates the available data on disk. Since it was written from the ground up, many of the newer technologies that have been implemented are not retrofits (unlike it was on its predecessor) but are native to the file system, which allows for better performance when using modern computers.

Pros of Apple's APFS

  1. Allows for clones or multiple copies of the same file, with only changes stored as deltas, which reduces storage space when making revisions or copying files
  2. Can create point-in-time snapshots
  3. Full-disk encryption with single or multi-key encryption for added security
  4. Uses checksums for data integrity of metadata
  5. Metadata corruption prevention due to creating new records instead of overwriting existing ones, which can become corrupt due to system crashes
  6. Increases performance on some devices by eliminating the need to write changes twice compared to HFS+ Journaled file systems
  7. More efficient management of storage typically yields additional free space.

Cons of Apple's APFS

  1. Checksums are only for metadata integrity--not user data
  2. Compression is not available.
  3. Encrypted volumes can only be accessible by other computers running macOS High Sierra
  4. Does not support Fusion drives
  5. Cannot utilize NVRAM for data storage

Benchmarking data on NVMe SSD drive attached to PCI-Express

HFS+ Read Speed is: 1384.42 MB/sec Write Speed is: 1029.67 MB/sec

APFS Read Speed is: 1903.49 MB/sec Write Speed is: 727.661 MB/sec

Script we used at LambdaTest basic benchmarking

#!/bin/bash
echo "---------------------"
echo "Write Test Running. Please Wait..."
write=$(dd if=/dev/zero bs=2048k of=tstfile count=1024 2>&1 | grep sec | awk '{print $1 / 1024 / 1024 / $5, "MB/sec" }')
purge
echo ""
echo "Read Test Running. Please Wait..."
read=$(dd if=tstfile bs=2048k of=/dev/null count=1024 2>&1 | grep sec | awk '{print $1 / 1024 / 1024 / $5, "MB/sec" }')
clear
echo ""
echo "Read Speed is: $read"
echo "Write Speed is: $write"
echo "---------------------"
echo "Cleaning up. Please Wait..."
purge
rm tstfile
echo ""
exit 0

note: Run this script as root (i.e. sudo), else you won't be getting correct results as it won't be able to purge the in-memory data and give you IOPs data from RAM

Conclusion

LambdaTest does not save customer data and all test cases executed on the LambdaTest grid are isolated. We did not utilize a lot of features offered by APFS, as we only needed speed so that we can help our customers execute automation tests at scale.

Our application is more write-based compared to read from disk. Going ahead with HFS+ looked like the best way to increase the performance of LambdaTest's cloud-based Selenium platform.

We will keep this journey going to keep exploring and enhancing our cloud services to give best in class performance.

Happy Automation!