I have BTRFS for root and home volumes on my latop, 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 defragment | Kernel | initrd | user | Total |
Boot 1 | 2.743 | 2.015 | 4.81 | 9.568 |
Boot 2 | 2.749 | 1.913 | 4.757 | 9.419 |
Boot 3 | 2.79 | 1.882 | 3.209 | 7.881 |
Avegare | 2.761 | 1.937 | 4.259 | 8.956 |
Then I did a :
sudo btrfs filesystem defragment -v -r /
And recorded the new boot times :
After defragment | Kernel | initrd | user | Total |
Boot 1 | 2.751 | 1.734 | 3.37 | 7.855 |
Boot 2 | 2.743 | 1.76 | 4.287 | 8.79 |
Boot 3 | 2.746 | 1.747 | 2.847 | 7.34 |
Average | 2.747 | 1.747 | 3.501 | 7.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.