]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: reduce debug overhead of dir leaf/node checks
authorDave Chinner <dchinner@redhat.com>
Wed, 30 Jun 2021 22:28:31 +0000 (18:28 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Jun 2021 22:28:31 +0000 (18:28 -0400)
commitf5e56725784c60b0c745cbfa09eb073795e50c9f
tree2ab9d5c320686c3628f2a6e40d6b254beca2178c
parentaf10e4bc7084d355c63bc9294bea7bd96451c964
xfs: reduce debug overhead of dir leaf/node checks

Source kernel commit: 1fea323ff00526dcc04fbb4ee6e7d04e4e2ab0e1

On debug kernels, we call xfs_dir3_leaf_check_int() multiple times
on every directory modification. The robust hash ordering checks it
does on every entry in the leaf on every call results in a massive
CPU overhead which slows down debug kernels by a large amount.

We use xfs_dir3_leaf_check_int() for the verifiers as well, so we
can't just gut the function to reduce overhead. What we can do,
however, is reduce the work it does when it is called from the
debug interfaces, just leaving the high level checks in place and
leaving the robust validation to the verifiers. This means the debug
checks will catch gross errors, but subtle bugs might not be caught
until a verifier is run.

It is easy enough to restore the existing debug behaviour if the
developer needs it (just change a call parameter in the debug code),
but overwise the overhead makes testing large directory block sizes
on debug kernels very slow.

Profile at an unlink rate of ~80k file/s on a 64k block size
filesystem before the patch:

40.30%  [kernel]  [k] xfs_dir3_leaf_check_int
10.98%  [kernel]  [k] __xfs_dir3_data_check
8.10%  [kernel]  [k] xfs_verify_dir_ino
4.42%  [kernel]  [k] memcpy
2.22%  [kernel]  [k] xfs_dir2_data_get_ftype
1.52%  [kernel]  [k] do_raw_spin_lock

Profile after, at an unlink rate of ~125k files/s (+50% improvement)
has largely dropped the leaf verification debug overhead out of the
profile.

16.53%  [kernel]  [k] __xfs_dir3_data_check
12.53%  [kernel]  [k] xfs_verify_dir_ino
7.97%  [kernel]  [k] memcpy
3.36%  [kernel]  [k] xfs_dir2_data_get_ftype
2.86%  [kernel]  [k] __pv_queued_spin_lock_slowpath

Create shows a similar change in profile and a +25% improvement in
performance.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_dir2_leaf.c
libxfs/xfs_dir2_node.c
libxfs/xfs_dir2_priv.h