RAIDZ: Use cache blocking during parity math
authorAlexander Motin <mav@FreeBSD.org>
Mon, 30 Oct 2023 21:54:27 +0000 (17:54 -0400)
committerGitHub <noreply@github.com>
Mon, 30 Oct 2023 21:54:27 +0000 (14:54 -0700)
commit05a7348a7e7e0be7ae5e729fdc98cb77416d30b8
tree12adfcd77e618832461316c5d7d9c867cf82da37
parentc3773de168668a5515e82d100ed6509e7d174fe9
RAIDZ: Use cache blocking during parity math

RAIDZ parity is calculated by adding data one column at a time.  It
works OK for small blocks, but for large blocks results of previous
addition may already be evicted from CPU caches to main memory, and
in addition to extra memory write require extra read to get it back.

This patch splits large parity operations into 64KB chunks, that
should in most cases fit into CPU L2 caches from the last decade.
I haven't touched more complicated cases of data reconstruction to
not over complicate the code.  Those should be relatively rare.

My tests on Xeon Gold 6242R CPU with 1MB of L2 cache per core show
up to 10/20% memory traffic reduction when writing to 4-wide RAIDZ/
RAIDZ2 blocks of ~4MB and up.  Older CPUs with 256KB of L2 cache
should see the effect even on smaller blocks.  Wider vdevs may need
bigger blocks to be affected.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15448
include/sys/abd.h
module/zfs/abd.c
module/zfs/vdev_raidz_math_impl.h