HomeFreeBSD

Batch enqueue/dequeue for bqueue

Description

Batch enqueue/dequeue for bqueue

The Blocking Queue (bqueue) code is used by zfs send/receive to send
messages between the various threads. It uses a shared linked list,
which is locked whenever we enqueue or dequeue. For workloads which
process many blocks per second, the locking on the shared list can be
quite expensive.

This commit changes the bqueue logic to have 3 linked lists:

  1. An enquing list, which is used only by the (single) enquing thread, and thus needs no locks.
  2. A shared list, with an associated lock.
  3. A dequing list, which is used only by the (single) dequing thread, and thus needs no locks.

The entire enquing list can be moved to the shared list in constant
time, and the entire shared list can be moved to the dequing list in
constant time. These operations only happen when the fill_fraction is
reached, or on an explicit flush request. Therefore, the lock only
needs to be acquired infrequently.

The API already allows for dequing to block until an explicit flush, so
callers don't need to be changed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #14121

Details

Provenance
mahrensAuthored on Jan 10 2023, 9:39 PM
GitHub <noreply@github.com>Committed on Jan 10 2023, 9:39 PM
Parents
rG0c8fbe5b6adc: ztest: update ztest_dmu_snapshot_create_destroy()
Branches
Unknown
Tags
Unknown

Event Timeline