From 3673493accca2fe335eeb34a1150bce2d40cbe6b Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Wed, 31 May 2023 11:13:45 +0800 Subject: [PATCH 1/4] support fetch server info without starting Proxy Signed-off-by: guo-shaoge --- contrib/tiflash-proxy | 2 +- dbms/src/Server/Server.cpp | 28 +++++++++------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/contrib/tiflash-proxy b/contrib/tiflash-proxy index 70da4ccad80..7848b2fc1fa 160000 --- a/contrib/tiflash-proxy +++ b/contrib/tiflash-proxy @@ -1 +1 @@ -Subproject commit 70da4ccad80bab4fe9235bd4e1fe203226347a2a +Subproject commit 7848b2fc1fabca45621375fcf26d84c5596494a0 diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index 09d83e2172d..f95e50a0b29 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -1022,25 +1022,15 @@ int Server::main(const std::vector & /*args*/) }); /// get CPU/memory/disk info of this server - if (tiflash_instance_wrap.proxy_helper) - { - diagnosticspb::ServerInfoRequest request; - request.set_tp(static_cast(1)); - diagnosticspb::ServerInfoResponse response; - std::string req = request.SerializeAsString(); - auto * helper = tiflash_instance_wrap.proxy_helper; - helper->fn_server_info(helper->proxy_ptr, strIntoView(&req), &response); - server_info.parseSysInfo(response); - setNumberOfLogicalCPUCores(server_info.cpu_info.logical_cores); - computeAndSetNumberOfPhysicalCPUCores(server_info.cpu_info.logical_cores, server_info.cpu_info.physical_cores); - LOG_INFO(log, "ServerInfo: {}", server_info.debugString()); - } - else - { - setNumberOfLogicalCPUCores(std::thread::hardware_concurrency()); - computeAndSetNumberOfPhysicalCPUCores(std::thread::hardware_concurrency(), std::thread::hardware_concurrency() / 2); - LOG_INFO(log, "TiFlashRaftProxyHelper is null, failed to get server info"); - } + diagnosticspb::ServerInfoRequest request; + diagnosticspb::ServerInfoResponse response; + request.set_tp(static_cast(1)); + std::string req = request.SerializeAsString(); + ffi_server_info_noproxy(intptr_t(&helper), strIntoView(&req), &response); + server_info.parseSysInfo(response); + setNumberOfLogicalCPUCores(server_info.cpu_info.logical_cores); + computeAndSetNumberOfPhysicalCPUCores(server_info.cpu_info.logical_cores, server_info.cpu_info.physical_cores); + LOG_INFO(log, "ServerInfo: {}", server_info.debugString()); grpc_log = Logger::get("grpc"); gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); From f9975554f994bb0d54eb348a321d0ffaa89f6f43 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Thu, 1 Jun 2023 11:04:41 +0800 Subject: [PATCH 2/4] change func name Signed-off-by: guo-shaoge --- dbms/src/Server/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index f95e50a0b29..84facc5dd5f 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -1026,7 +1026,7 @@ int Server::main(const std::vector & /*args*/) diagnosticspb::ServerInfoResponse response; request.set_tp(static_cast(1)); std::string req = request.SerializeAsString(); - ffi_server_info_noproxy(intptr_t(&helper), strIntoView(&req), &response); + ffi_get_server_info_from_proxy(intptr_t(&helper), strIntoView(&req), &response); server_info.parseSysInfo(response); setNumberOfLogicalCPUCores(server_info.cpu_info.logical_cores); computeAndSetNumberOfPhysicalCPUCores(server_info.cpu_info.logical_cores, server_info.cpu_info.physical_cores); From e1ce74a38691ae50a6959673fa3e8a77fdc1c399 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Thu, 1 Jun 2023 13:02:48 +0800 Subject: [PATCH 3/4] update proxy Signed-off-by: guo-shaoge --- contrib/tiflash-proxy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/tiflash-proxy b/contrib/tiflash-proxy index 7848b2fc1fa..601d803562c 160000 --- a/contrib/tiflash-proxy +++ b/contrib/tiflash-proxy @@ -1 +1 @@ -Subproject commit 7848b2fc1fabca45621375fcf26d84c5596494a0 +Subproject commit 601d803562cde9a7fe8d17120d073aea55ae1012 From 333bde650ed798f181c4b7d2d5bc748c6ce44d99 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Thu, 1 Jun 2023 14:06:07 +0800 Subject: [PATCH 4/4] fix cast Signed-off-by: guo-shaoge --- dbms/src/Server/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index 84facc5dd5f..b507a88402c 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -1026,7 +1026,7 @@ int Server::main(const std::vector & /*args*/) diagnosticspb::ServerInfoResponse response; request.set_tp(static_cast(1)); std::string req = request.SerializeAsString(); - ffi_get_server_info_from_proxy(intptr_t(&helper), strIntoView(&req), &response); + ffi_get_server_info_from_proxy(reinterpret_cast(&helper), strIntoView(&req), &response); server_info.parseSysInfo(response); setNumberOfLogicalCPUCores(server_info.cpu_info.logical_cores); computeAndSetNumberOfPhysicalCPUCores(server_info.cpu_info.logical_cores, server_info.cpu_info.physical_cores);