]> git.proxmox.com Git - mirror_zfs.git/commit - module/Makefile.bsd
btree: Implement faster binary search algorithm
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Fri, 26 May 2023 17:03:12 +0000 (13:03 -0400)
committerGitHub <noreply@github.com>
Fri, 26 May 2023 17:03:12 +0000 (10:03 -0700)
commit677c6f8457943fe5b56d7aa8807010a104563e4a
tree11c2e70b1530c04bf701e7b508cda3545d30f582
parentbb736d98d133b4449a4e3bb97a914651677e6713
btree: Implement faster binary search algorithm

This implements a binary search algorithm for B-Trees that reduces
branching to the absolute minimum necessary for a binary search
algorithm. It also enables the compiler to inline the comparator to
ensure that the only slowdown when doing binary search is from waiting
for memory accesses. Additionally, it instructs the compiler to unroll
the loop, which gives an additional 40% improve with Clang and 8%
improvement with GCC.

Consumers must opt into using the faster algorithm. At present, only
B-Trees used inside kernel code have been modified to use the faster
algorithm.

Micro-benchmarks suggest that this can improve binary search performance
by up to 3.5 times when compiling with Clang 16 and up to 1.9 times when
compiling with GCC 12.2.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14866
cmd/zdb/zdb.c
include/sys/btree.h
module/Kbuild.in
module/Makefile.bsd
module/zfs/btree.c
module/zfs/dsl_scan.c
module/zfs/metaslab.c
module/zfs/range_tree.c
module/zfs/zap_micro.c
tests/zfs-tests/cmd/btree_test.c