How to improve badblocks read/write performance in macOS

Solution 1:

You indicate that you're doing a write test to the drive using the badblocks program, however the options you state you're using do not include the -w flag for indicating that you want to test in write-mode. I assume this is because you left out the -w flag when stating your options here, and that you really did use the -w flag when you ran the program.

The reason you're seeing vastly different numbers in terms of MB/s is that the two programs (badblocks and Finder) are doing vastly different things:

Copying a file to the drive with Finder will essentially write large amounts of consecutive data in large blocks to the drive. This is something that most hard drive do very efficiently and quickly.

Doing a write-mode test with badblocks will essentially write a number of blocks to the drive with a specific value, then read them off the disk again to check that they were written correctly. Repeat that for all the blocks to be checked. Then it does that whole thing once more with a different value, and so on. By default it will do 4 passes over the drive with the values 0xAA, 0x55, 0xFF and 0x00.

This means that it is very natural that a Finder copy is much faster in terms of how quickly 1 GB of data can be copied compared to how quickly the badblocks program can check 1 GB of disk space. As reads are usually faster than writes, you would expect the badblocks program to be approx. 4-8 times slower than Finder - most often around 6 times slower.

That corresponds very well with the numbers you are seeing, so I wouldn't worry about it.

In terms of improving performance, I would make sure you're using the best device node for accessing the drive. If you're testing the whole drive, then test using /dev/rdiskX instead of /dev/diskX to see if that improves performance.