Fragmentation is the #1 enemy of mechanical disks, as every head movement correspond to lower total I/O performance.

Both EXT4 and XFS has a fame to be very fragmentation resistant, but what is the best? Let's start with counting fragments per file after the extraction of the Linux kernel .tar.bz2 file (see the untar test above for more informations):

Fragmentation after untar

Yeah, both filesystems where exceptionally resistant to fragmentation here, showing perfect results.

Sysbench's sequential and random tests give us another interesting point of reference in this discipline. First, the fragmentation status after the sequential write test:

Fragmentation after sysbench seqwr

Now XFS is the leader, with EXT4 lagging quite behind. It is interesting to note that in the synchronous test (one write / one fsync) EXT4 exhibits lower fragmentation: this can explain the higher sequential read results in synchronous mode recorded earlier. Speaking about XFS, it seems that this filesystem optimally manage large files and its high sequential read/write speeds are likely a results of the complete lack of fragmentation in these class of files.

The random write test is a harder one:

Fragmentation after sysbench rndwr

In this case, both filesystems become heavily fragmented, proving that no filesystem is completely immune to this issue. However, XFS has and edge here: it ships with a functional, proved defragmenter, while the EXT4 package lack an official, stable-released defrag utility (while this utility exists, it is more-or-less in a beta stage).