aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Motin <[email protected]>2024-03-21 18:42:21 -0400
committerBrian Behlendorf <[email protected]>2024-04-19 10:13:38 -0700
commitf7c1db6366947d879d0103a0970d22d9663ef20e (patch)
treee086b36bffae25cccf3abceb4d56d91562032a26
parentfa5de0c5cd4061b3b70d5e9eb2d67a4a7c594a63 (diff)
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
-rw-r--r--module/zfs/brt.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/module/zfs/brt.c b/module/zfs/brt.c
index 225ddaca1..3d565cd13 100644
--- a/module/zfs/brt.c
+++ b/module/zfs/brt.c
@@ -1420,13 +1420,14 @@ brt_pending_entry_compare(const void *x1, const void *x2)
const blkptr_t *bp1 = &bpe1->bpe_bp, *bp2 = &bpe2->bpe_bp;
int cmp;
- cmp = TREE_CMP(BP_PHYSICAL_BIRTH(bp1), BP_PHYSICAL_BIRTH(bp2));
+ cmp = TREE_CMP(DVA_GET_VDEV(&bp1->blk_dva[0]),
+ DVA_GET_VDEV(&bp2->blk_dva[0]));
if (cmp == 0) {
- cmp = TREE_CMP(DVA_GET_VDEV(&bp1->blk_dva[0]),
- DVA_GET_VDEV(&bp2->blk_dva[0]));
- if (cmp == 0) {
- cmp = TREE_CMP(DVA_GET_OFFSET(&bp1->blk_dva[0]),
- DVA_GET_OFFSET(&bp2->blk_dva[0]));
+ cmp = TREE_CMP(DVA_GET_OFFSET(&bp1->blk_dva[0]),
+ DVA_GET_OFFSET(&bp2->blk_dva[0]));
+ if (unlikely(cmp == 0)) {
+ cmp = TREE_CMP(BP_PHYSICAL_BIRTH(bp1),
+ BP_PHYSICAL_BIRTH(bp2));
}
}