]> git.proxmox.com Git - mirror_zfs.git/commit
Several sorted scrub optimizations
authorAlexander Motin <mav@FreeBSD.org>
Fri, 24 Jun 2022 16:50:37 +0000 (12:50 -0400)
committerGitHub <noreply@github.com>
Fri, 24 Jun 2022 16:50:37 +0000 (09:50 -0700)
commit1c0c729ab4165cd828fbeab404353b45b3836360
treeb3da1881d3e4d895ee1d0f3d62c8577e22df535e
parent83691bebf062d13e64a93ff80bf727cd1c162bb2
Several sorted scrub optimizations

- Reduce size and comparison complexity of q_exts_by_size B-tree.
Previous code used two 64-bit divisions and many other operations to
compare two B-tree elements.  It created enormous overhead.  This
implementation moves the math to the upper level and stores the score
in the B-tree elements themselves.  Since all that we need to store in
that B-tree is the extent score and offset, those can fit into single
8 byte value instead of 24 bytes of q_exts_by_addr element and can be
compared with single operation.
 - Better decouple secondary tree logic from main range_tree by moving
rt_btree_ops and related functions into dsl_scan.c as ext_size_ops.
Those functions are very small to worry about the code duplication and
range_tree does not need to know details such as rt_btree_compare.
 - Instead of accounting number of pending bytes per pool, that needs
atomic on global variable per block, account the number of non-empty
per-vdev queues, that change much more rarely.
 - When extent scan is interrupted by TXG end, continue it in the next
TXG instead of selecting next best extent.  It allows to avoid leaving
one truncated (and so likely not the best any more) extent each TXG.

On top of some other optimizations this saves about 1.5 minutes out of
10 to scrub pool of 12 SSDs, storing 1.5TB of 4KB zvol blocks.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <caputit1@tcnj.edu>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #13576
include/sys/dsl_scan.h
include/sys/range_tree.h
module/zfs/dsl_scan.c
module/zfs/range_tree.c