Broken by Design

Btrfs defragment

I have BTRFS for root and home volumes on my laptop, and today I found out that BTRFS supports defragmentation. It's interesting to check whether defragmentation has measurable performance impact, so I did a quick test.

The easiest thing was to measure the boot time as reported by systemd. So I did a couple of restarts, recorded the boot times systemd-analyze reports:

Before defragmentKernelinitrduserTotal
Boot 12.7432.0154.819.568
Boot 22.7491.9134.7579.419
Boot 32.791.8823.2097.881
Average2.7611.9374.2598.956

Then I did a:

sudo btrfs filesystem defragment -v -r /

And recorded the new boot times:

After defragmentKernelinitrduserTotal
Boot 12.7511.7343.377.855
Boot 22.7431.764.2878.79
Boot 32.7461.7472.8477.34
Average2.7471.7473.5017.995

That's a whole second less, or about 11% improvement. Not so bad at all, given that the disk is Samsung 840 Pro SSD, and is quite fast anyway.

December 5, 2014