MacOS – Extremely slow write speed to encrypted external drive on Mavericks

filevaulthard drivemacbook promacosusb

Writing to a fully encrypted USB flash drive on Mavericks is extremely slow.

The drive model I used for testing was a Kingston DataTraveler Ultimate 3.0 G3 (64 GB). I tested transfer speeds by reading/writing a large file from/to both an encrypted and an unencrypted drive. I tested on a current Macbook with Mavericks and on an older machine with Mountain Lion. I used Disk Utility to format the drive as Mac OS Extended (Journaled) and Mac OS Extended (Journaled, Encrypted).

MacBook Pro (2013) with USB 3.0 running OS X 10.9.2 (13C64)

Write: 86.16 MB/sec (encrypted: 0.62 MB/sec)

Read: 181.66 MB/sec (encrypted: 151.15 MB/sec)

MacBook Pro (2007) with USB 2.0 running OS X 10.8.5 (12F45)

Write: 23.57 MB/sec (encrypted: 5.04 MB/sec)

Read: 36.23 MB/sec (encrypted: 37.87 MB/sec)

As you can see on the older machine the write speed clearly decreases when writing to the encrypted volume but is still about ten times faster compared with the newer machine running Mavericks. Could this be some recently introduced issue in FileVault or CoreStorage?

Update (2014-06-28)

The USB drive seems to have had a hardware defect from the start. I got a replacement drive (same model) which still doesn't deliver the results I would expect but at least the encrypted write speed of the 2013 MBP is now on par with the 2007 MBP.

MacBook Pro (2013) with USB 3.0 running OS X 10.9.3 (13D65)

Write: 135.41 MB/sec (encrypted: 9.29 MB/sec)
Read: 196.22 MB/sec (encrypted: 187.04 MB/sec)

MacBook Pro (2007) with USB 2.0 running OS X 10.8.5 (12F45)

Write: – MB/sec (encrypted: 9.39 MB/sec)
Read: – MB/sec (encrypted: 37.79 MB/sec)

This still leaves the question though why the encrypted write speed to the USB drive on the 2013 MBP is less then ten percent of the regular write speed. I also compared read/write speeds before and after activating FileVault on the internal SSD of the 2013 MBP and there I couldn't detect any slowdown at all.

Best Answer

I have the same problem, which I'm pretty sure is due to a combination of the way write operations work on flash memory and the way core storage (or any whole-volume) encryption works.

First, write behavior: unlike volatile memory (the stuff used in the memory of your computer) or hard disks, where any bit can be written to 0 or 1 at any time, flash memory has two main states: written and erased. Within "written" are 0 and 1. When you need to write to flash memory you must write an entire block that is currently in the erased state. File system software in the OS may know what blocks are free, but the controller and storage on a flash device don't. A special way for the OS to tell an SSD to make blocks available has been devised for "bus-connected" SSDs: it's called TRIM. USB protocol stacks don't, to my knowledge, support TRIM. So, basically, flash memory continues to fill up until there are no actual erased blocks, at which point the file system has to erase and rewrite blocks by reading them, merging in the new data, erasing, and writing them back out. That's why you see small-file write performance degrade on SSDs over time.

The special circumstances of encrypted volumes is interesting: depending on the way the encryption works, it may actually encrypt an entire volume, filling all the blocks with what appears to be random data even if the blocks are actually unused and would contain zeroes. So when you turn on FileVault (or otherwise enable core storage encryption), it basically consumes the entire volume, leaving no space for write operations. The file system has to constantly read, erase and rewrite blocks so that it can rewrite them with any encrypted data you want to put on it.

Now I will say right here that this is speculation based on a reasonable understanding of how things work, but there are people who actually know the details, who may correct or improve my explanation and I hope that they will do so.