From f17fd3988285b65d2f83d83bf3fc4aff17d70b2b Mon Sep 17 00:00:00 2001 From: Uri Yagelnik Date: Wed, 24 Jul 2024 04:26:16 +0000 Subject: [PATCH] Improve CPU usage in tests with IO threads Signed-off-by: Uri Yagelnik --- src/io_threads.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/io_threads.c b/src/io_threads.c index 95d5895d03..c9345d72e0 100644 --- a/src/io_threads.c +++ b/src/io_threads.c @@ -164,9 +164,9 @@ void waitForClientIO(client *c) { void adjustIOThreadsByEventLoad(int numevents, int increase_only) { if (server.io_threads_num == 1) return; /* All I/O is being done by the main thread. */ debugServerAssertWithInfo(NULL, NULL, server.io_threads_num > 1); - - int target_threads = - server.events_per_io_thread == 0 ? server.io_threads_num : numevents / server.events_per_io_thread; + /* When events_per_io_thread is set to 0, we offload all events to the IO threads. + * This is used mainly for testing purposes. */ + int target_threads = server.events_per_io_thread == 0 ? (numevents + 1) : numevents / server.events_per_io_thread; target_threads = max(1, min(target_threads, server.io_threads_num));