Skip to content

Commit f7c1db6

Browse files
amotinbehlendorf
authored andcommitted
BRT: Change brt_pending_tree sorting order
It does not look important how exactly brt_pending_tree is sorted. When cloning large file, it is quite likely that all of its blocks have identical physical birth times, so comparing them first does not provide useful entropy, while accesses additional cache line. In most cases combination of vdev and offset provides unique result and physical birth time comparison is not even needed. Meanwhile, when traversing the tree inside brt_pending_apply(), it can be beneficial for dbuf cache and CPU cache hits to group processing by vdev and so by the per-VDEV BRT ZAPs. Reviewed-by: Rob Norris <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15954
1 parent fa5de0c commit f7c1db6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

module/zfs/brt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,13 +1420,14 @@ brt_pending_entry_compare(const void *x1, const void *x2)
14201420
const blkptr_t *bp1 = &bpe1->bpe_bp, *bp2 = &bpe2->bpe_bp;
14211421
int cmp;
14221422

1423-
cmp = TREE_CMP(BP_PHYSICAL_BIRTH(bp1), BP_PHYSICAL_BIRTH(bp2));
1423+
cmp = TREE_CMP(DVA_GET_VDEV(&bp1->blk_dva[0]),
1424+
DVA_GET_VDEV(&bp2->blk_dva[0]));
14241425
if (cmp == 0) {
1425-
cmp = TREE_CMP(DVA_GET_VDEV(&bp1->blk_dva[0]),
1426-
DVA_GET_VDEV(&bp2->blk_dva[0]));
1427-
if (cmp == 0) {
1428-
cmp = TREE_CMP(DVA_GET_OFFSET(&bp1->blk_dva[0]),
1429-
DVA_GET_OFFSET(&bp2->blk_dva[0]));
1426+
cmp = TREE_CMP(DVA_GET_OFFSET(&bp1->blk_dva[0]),
1427+
DVA_GET_OFFSET(&bp2->blk_dva[0]));
1428+
if (unlikely(cmp == 0)) {
1429+
cmp = TREE_CMP(BP_PHYSICAL_BIRTH(bp1),
1430+
BP_PHYSICAL_BIRTH(bp2));
14301431
}
14311432
}
14321433

0 commit comments

Comments
 (0)