aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2023-01-10 13:39:22 -0800
committerGitHub <[email protected]>2023-01-10 13:39:22 -0800
commitfc45975ec8685a6c7a14c407a44f336fbbf18e76 (patch)
tree6d4c32cc5d4e0f985411836f8f3b3521f3ccc9e2 /include
parent0c8fbe5b6adcf8a9bf8445eb2d95a3e24531b8d4 (diff)
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 <[email protected]> Reviewed-by: George Wilson <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Matthew Ahrens <[email protected]> Closes #14121
Diffstat (limited to 'include')
-rw-r--r--include/sys/bqueue.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/sys/bqueue.h b/include/sys/bqueue.h
index b96219660..edcee1622 100644
--- a/include/sys/bqueue.h
+++ b/include/sys/bqueue.h
@@ -27,10 +27,14 @@ extern "C" {
typedef struct bqueue {
list_t bq_list;
+ size_t bq_size;
+ list_t bq_dequeuing_list;
+ size_t bq_dequeuing_size;
+ list_t bq_enqueuing_list;
+ size_t bq_enqueuing_size;
kmutex_t bq_lock;
kcondvar_t bq_add_cv;
kcondvar_t bq_pop_cv;
- size_t bq_size;
size_t bq_maxsize;
uint_t bq_fill_fraction;
size_t bq_node_offset;
@@ -47,7 +51,6 @@ void bqueue_destroy(bqueue_t *);
void bqueue_enqueue(bqueue_t *, void *, size_t);
void bqueue_enqueue_flush(bqueue_t *, void *, size_t);
void *bqueue_dequeue(bqueue_t *);
-boolean_t bqueue_empty(bqueue_t *);
#ifdef __cplusplus
}