From 8bf7e176edcb4c4de4f4f188cd7887f3da328c92 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 0ccf89ec03c..261d82dd2ea 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 2265ae91288371901edba85c2b804da4f92d7e32 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 261d82dd2ea..f16579d0d48 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 45ab188f70c22394f54da6d16d0e918f4764ca3d 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 3640adf3de96ad0b5ca0ceebfcb77c478bcd23f2 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 f16579d0d48..6609ee59f38 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);