From 36c276358b332ef43b1cb9f43767dd381a06f9d1 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 18 Feb 2022 01:31:45 +0300 Subject: [PATCH] Attempt to fix "head-of-line blocking" by LIST operations --- src/blockstore_impl.cpp | 13 +++++++++---- src/blockstore_impl.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/blockstore_impl.cpp b/src/blockstore_impl.cpp index f1e96e40..8bb34391 100644 --- a/src/blockstore_impl.cpp +++ b/src/blockstore_impl.cpp @@ -118,7 +118,7 @@ void blockstore_impl_t::loop() // has_writes == 0 - no writes before the current queue item // has_writes == 1 - some writes in progress // has_writes == 2 - tried to submit some writes, but failed - int has_writes = 0, op_idx = 0, new_idx = 0; + int has_writes = 0, op_idx = 0, new_idx = 0, done_lists = 0; for (; op_idx < submit_queue.size(); op_idx++, new_idx++) { auto op = submit_queue[op_idx]; @@ -198,9 +198,14 @@ void blockstore_impl_t::loop() } else if (op->opcode == BS_OP_LIST) { - // LIST doesn't need to be blocked by previous modifications - process_list(op); - wr_st = 2; + // LIST doesn't have to be blocked by previous modifications + // But don't do a lot of LISTs at once, because they're blocking and potentially slow + if (single_tick_list_limit <= 0 || done_lists < single_tick_list_limit) + { + process_list(op); + done_lists++; + wr_st = 2; + } } if (wr_st == 2) { diff --git a/src/blockstore_impl.h b/src/blockstore_impl.h index e77933c6..2b10ffe8 100644 --- a/src/blockstore_impl.h +++ b/src/blockstore_impl.h @@ -241,6 +241,8 @@ class blockstore_impl_t int throttle_target_parallelism = 1; // Minimum difference in microseconds between target and real execution times to throttle the response int throttle_threshold_us = 50; + // Maximum number of LIST operations to be processed between + int single_tick_list_limit = 1; /******* END OF OPTIONS *******/ struct ring_consumer_t ring_consumer;