From 2f73337f4e4f01f00587dfbe315be41172039fa1 Mon Sep 17 00:00:00 2001 From: bomou Date: Tue, 10 Jun 2025 16:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9B=9E=E5=90=88=20600=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=2024.03=20=E9=80=9A=E8=BF=87=20lscpu=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=20CPU=20=E6=95=B0=E9=87=8F=E6=9C=89=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bomou --- .../process/threadpool/threadpool_controler.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gausskernel/process/threadpool/threadpool_controler.cpp b/src/gausskernel/process/threadpool/threadpool_controler.cpp index 9e45ae749..0416490ae 100644 --- a/src/gausskernel/process/threadpool/threadpool_controler.cpp +++ b/src/gausskernel/process/threadpool/threadpool_controler.cpp @@ -58,6 +58,8 @@ #include "communication/commproxy_interface.h" #include "utils/mem_snapshot.h" +#include + #ifdef HAVE_POLL_H #include #endif @@ -590,16 +592,13 @@ void ThreadPoolControler::GetCpuAndNumaNum(int32 *totalCpuNum, int32 *totalNumaN { char buf[BUFSIZE]; + *totalCpuNum = std::thread::hardware_concurrency(); + FILE* fp = NULL; if ((fp = popen("LANGUAGE=en_US.UTF-8;LANG=en_US.UTF-8;lscpu", "r")) != NULL) { while (fgets(buf, sizeof(buf), fp) != NULL) { - if (strncmp("CPU(s)", buf, strlen("CPU(s)")) == 0 && - strncmp("On-line CPU(s) list", buf, strlen("On-line CPU(s) list")) != 0 && - strncmp("NUMA node", buf, strlen("NUMA node")) != 0) { - char* loc = strchr(buf, ':'); - *totalCpuNum = pg_strtoint32(loc + 1); - } else if (strncmp("NUMA node(s)", buf, strlen("NUMA node(s)")) == 0) { + if (strncmp("NUMA node(s)", buf, strlen("NUMA node(s)")) == 0) { char* loc = strchr(buf, ':'); *totalNumaNum = pg_strtoint32(loc + 1); }