summaryrefslogtreecommitdiffstats
path: root/iothread.c
diff options
context:
space:
mode:
authorNicolas Saenz Julienne2022-04-25 09:57:23 +0200
committerStefan Hajnoczi2022-05-09 11:43:23 +0200
commit71ad4713cc1d7fca24388b828ef31ae6cb38a31c (patch)
treebaf49f521c85ffa4551b2cb73083562570b3c857 /iothread.c
parentutil/main-loop: Introduce the main loop into QOM (diff)
downloadqemu-71ad4713cc1d7fca24388b828ef31ae6cb38a31c.tar.gz
qemu-71ad4713cc1d7fca24388b828ef31ae6cb38a31c.tar.xz
qemu-71ad4713cc1d7fca24388b828ef31ae6cb38a31c.zip
util/event-loop-base: Introduce options to set the thread pool size
The thread pool regulates itself: when idle, it kills threads until empty, when in demand, it creates new threads until full. This behaviour doesn't play well with latency sensitive workloads where the price of creating a new thread is too high. For example, when paired with qemu's '-mlock', or using safety features like SafeStack, creating a new thread has been measured take multiple milliseconds. In order to mitigate this let's introduce a new 'EventLoopBase' property to set the thread pool size. The threads will be created during the pool's initialization or upon updating the property's value, remain available during its lifetime regardless of demand, and destroyed upon freeing it. A properly characterized workload will then be able to configure the pool to avoid any latency spikes. Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-id: 20220425075723.20019-4-nsaenzju@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'iothread.c')
-rw-r--r--iothread.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/iothread.c b/iothread.c
index 8fa2f3bfb8..529194a566 100644
--- a/iothread.c
+++ b/iothread.c
@@ -174,6 +174,9 @@ static void iothread_set_aio_context_params(EventLoopBase *base, Error **errp)
aio_context_set_aio_params(iothread->ctx,
iothread->parent_obj.aio_max_batch,
errp);
+
+ aio_context_set_thread_pool_params(iothread->ctx, base->thread_pool_min,
+ base->thread_pool_max, errp);
}