APFS – Very Slow Write Performance for 2GB Files

apfscarbon-copy-clonerhard driveperformance

Yesterday I have been working with Docker on my MacBook Pro 2012 which runs Mojave and the internal drive has been automatically converted to APFS (seems to be so for startvolumes since Mojave).
It worked well until I decided to add another plugin to my jenkins docker container. Then everything got slow.

  • I tried to restart docker but that did take endless.
  • Reboot of machine looks slow as ever – since Mojave.
  • Uninstalled docker and reinstalled it.
  • It took 36mins to copy the 2GB DockerDesktop into
    the Applications folder.
  • I am now running fsck and it takes very long
    but don't expect any useful output.

Is it normal that perfomance of APFS degrades, especially suddenly?
I did run benchmarks recently and thougt okay write performance is bad but still okay and now it looks like glue. Found this note according to APFS: "Copy-on-Write may cause a performance degradation over time as the drives become fragmented."

Are there any tools for APFS to fix the performance?
I guess the best option might be to get an SSD and use CarbonCopyCloner to Copy the System over to an SSD. I think of a 1TB SSD are there any recommendations according the 2012 Mac Book Pro?

Best Answer

Okay after running

diskutil APFS defragment /dev/<yourdisklocation> status

I saw that defragment was disabled. Turning it on with

diskutil APFS defragment /dev/<yourdisklocation> enable

an waiting about an hour, the write speed startetd to return to "normal".
I could Copy the 2 GB in about 5 Minutes instead of 40ยด

Anyway - the Cruxial 500 MX 1TB SSD ist already in my Postbox.