]> git.proxmox.com Git - mirror_zfs.git/commit
Improve ZFS objset sync parallelism
authorednadolski-ix <137826107+ednadolski-ix@users.noreply.github.com>
Mon, 6 Nov 2023 18:38:42 +0000 (11:38 -0700)
committerGitHub <noreply@github.com>
Mon, 6 Nov 2023 18:38:42 +0000 (10:38 -0800)
commit3bd4df3841529316e5145590cc67076467b6abb7
tree816fe92ee22d00a2e82e9b931b3a524c9740a707
parent052777406601a4049c28e25fe0b4df57160b5a58
Improve ZFS objset sync parallelism

As part of transaction group commit, dsl_pool_sync() sequentially calls
dsl_dataset_sync() for each dirty dataset, which subsequently calls
dmu_objset_sync().  dmu_objset_sync() in turn uses up to 75% of CPU
cores to run sync_dnodes_task() in taskq threads to sync the dirty
dnodes (files).

There are two problems:

1. Each ZVOL in a pool is a separate dataset/objset having a single
   dnode.  This means the objsets are synchronized serially, which
   leads to a bottleneck of ~330K blocks written per second per pool.

2. In the case of multiple dirty dnodes/files on a dataset/objset on a
   big system they will be sync'd in parallel taskq threads. However,
   it is inefficient to to use 75% of CPU cores of a big system to do
   that, because of (a) bottlenecks on a single write issue taskq, and
   (b) allocation throttling.  In addition, if not for the allocation
   throttling sorting write requests by bookmarks (logical address),
   writes for different files may reach space allocators interleaved,
   leading to unwanted fragmentation.

The solution to both problems is to always sync no more and (if
possible) no fewer dnodes at the same time than there are allocators
the pool.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Edmund Nadolski <edmund.nadolski@ixsystems.com>
Closes #15197
18 files changed:
include/os/freebsd/spl/sys/taskq.h
include/os/linux/spl/sys/taskq.h
include/sys/spa.h
include/sys/spa_impl.h
include/sys/zfs_context.h
include/sys/zio.h
lib/libzpool/taskq.c
man/man4/zfs.4
module/os/freebsd/spl/spl_taskq.c
module/os/linux/spl/spl-taskq.c
module/zfs/dbuf.c
module/zfs/dmu_objset.c
module/zfs/dnode_sync.c
module/zfs/dsl_dataset.c
module/zfs/dsl_pool.c
module/zfs/spa.c
module/zfs/spa_misc.c
module/zfs/zio.c