From c0e13393bdcedfc10c8488fe0f2570c2466c11e1 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 25 Oct 2022 17:54:36 +0800 Subject: [PATCH] dynamic adjust net_thread_count --- src/observer/ob_srv_network_frame.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/observer/ob_srv_network_frame.cpp b/src/observer/ob_srv_network_frame.cpp index 48d1c2c4f2..b9edde636a 100644 --- a/src/observer/ob_srv_network_frame.cpp +++ b/src/observer/ob_srv_network_frame.cpp @@ -59,7 +59,21 @@ static bool enable_new_sql_nio() static int get_default_net_thread_count() { - return max(6, get_cpu_num() / 8); + int cnt = 1; + int cpu_num = get_cpu_num(); + + if (cpu_num <= 4) { + cnt = 2; + } else if (cpu_num <= 8) { + cnt = 3; + } else if (cpu_num <= 16) { + cnt = 5; + } else if (cpu_num <= 32) { + cnt = 7; + } else { + cnt = max(8, get_cpu_num() / 6); + } + return cnt; } int ObSrvNetworkFrame::init() -- GitLab