Disk Benchmarking on macOS

Recently, I tried benchmarking a USB stick using fio, and it turned out to be a cursed journey. To save you some time, here are the quirks I encountered and how I worked around them.

macOS employs aggressive file caching, and even with --direct=1, there’s no guarantee that reads or writes will bypass the Unified Buffer Cache. This behavior is discussed in this GitHub comment.
The XNU kernel ignores direct I/O requests if the chunk size is less than 16,384 bytes. In practice, even with larger chunk sizes, I often had to manually flush or purge the cache to get reliable results, as noted in this issue.

For accurate read performance measurements:

  • Pre-create the test file using the same flags. Use a short runtime (e.g., --runtime=1s) and a large chunk size (e.g., --size=1M).
  • Run sudo purge.
  • Then run the actual benchmark with --allow_file_create=0, pointing to the same file.
  • Make sure --direct=1 is set for both the file creation and the benchmark runs.

Measuring write performance is less tricky:

  • --direct=1 gives results closer to raw flash speed.
  • Alternatively, use --direct=0 and --fdatasync=1 to simulate real-world usage more accurately, similar to what AmorphousDiskMark and Finder report.

That should wrap it up. If you are coming from CrystalDiskMark or AmorphousDiskMark, there’s a script that automates the tests for you. Do read through the script and use it at your own risk.

Race Between a Rabbit and a Turtle

There was a carrot
in the middle of the woods,
sat between two roots.
It belonged to no one.

The rabbit found it first.
The turtle saw it too.
They stood beside the carrot.

The rabbit offered a race.
“Losing is a social construct,”
the turtle nodded.
“But I will run anyway.”

The rabbit said nothing.
Its fur turned black.

They parted.
The rabbit went left.
The turtle went right.

They followed instinct.
The paths bent toward the same place.

The rabbit saw the turtle often.
The turtle did not see the rabbit.
Its sight was fixed
on the thought of the carrot.

By the time the turtle arrived,
the carrot was buried in leaves.
Some were green.
Some were purple.

The rabbit was already there.
“I found this mushroom,” it said.
“Now the carrot is yours.”
The carrot was larger than before.
The rabbit had grown small.

The turtle nodded.
The carrot smelled like soil.
The turtle carried it to a pot.
The water was already burning.

The carrot sank slowly
into the boundary between life and death.
It gave no sound.
Its integrity was long gone.

The turtle stirred the pot.
The water lost its clarity.
The orange was scooped into an old cloth bag.
A leak trailed behind the turtle as it walked.

No one followed.
The turtle kept its eyes on home.

When it arrived,
it set the bag down,
reached for its keys,
and poured the last of the liquid
onto the wooden door.

The Candy Bar

As usual, I pulled my candy bar from my bag at lunch, but today, I hurled it onto the table in anguish and disgust. Mold and bacteria had claimed it, turning the once-lively green packaging into a sickly mix of brown, yellow, and black.

After lunch, I headed to the convenience store where I had initially bought the candy bar. At the counter stood a man in a blue uniform. I explained that the candy bar had gone rancid. He examined it carefully, then shook his head and said he was sorry that he couldn’t replace it.

I tried to explain how important the candy bar was to me: I keep it beside my pillow and take it to work every day. He apologized again. “Unfortunately, we can’t replace it,” he said. “It has a two-year expiration period, and the purchase was five years ago.”

I looked at him. “If I don’t have this candy bar, I can’t finish my work. If I can’t finish my work, I’ll lose my job. And it’ll be because of you.” He tried to interrupt several times, but he couldn’t because what once were his lips are now a zipper. At the forty-hour mark of my explanation, his right ear fell off and shattered into hundreds of pieces. In sign language, he told me he had escalated my case and hoped I’d find a satisfactory solution. Then, wearing a smile, he stepped aside as the manager arrived to replace him.

The manager listened patiently to my entire story. He explained that store policy didn’t cover expired candy bars, but said my case was “unique” and he’d escalate it to his senior manager. Soon, the senior manager appeared. She said she had been fully briefed and needed no further details. “You’re a loyal customer,” she said. “So we’ll make an exception.” She nodded, and the first employee returned with a brand-new candy bar in the same lively green wrapper.

I took the candy bar, nodded in acknowledgement, and walked back home into the sunrise.