This is an automated email from the ASF dual-hosted git repository. gavinchou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new c215bc95ac9 [opt](cloud) Fix frequent rlock for SystemInfoService.getClusterXxx() (#47203) c215bc95ac9 is described below commit c215bc95ac9add4a85b0665c67f5e47540165fae Author: Gavin Chou <ga...@selectdb.com> AuthorDate: Mon Jan 20 01:47:34 2025 +0800 [opt](cloud) Fix frequent rlock for SystemInfoService.getClusterXxx() (#47203) ReentrantLock may consume lots of CPU in some cases. Remove some redundant rlock to prevent the potential CPU issue. --- .../doris/cloud/system/CloudSystemInfoService.java | 56 +++++++--------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java index e366efb6595..a9a8146fc29 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java @@ -492,12 +492,7 @@ public class CloudSystemInfoService extends SystemInfoService { } public boolean containClusterName(String clusterName) { - rlock.lock(); - try { - return clusterNameToId.containsKey(clusterName); - } finally { - rlock.unlock(); - } + return clusterNameToId.containsKey(clusterName); } @Override @@ -550,27 +545,17 @@ public class CloudSystemInfoService extends SystemInfoService { } public List<Backend> getBackendsByClusterName(final String clusterName) { - rlock.lock(); - try { - String clusterId = clusterNameToId.getOrDefault(clusterName, ""); - if (clusterId.isEmpty()) { - return new ArrayList<>(); - } - // copy a new List - return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); - } finally { - rlock.unlock(); + String clusterId = clusterNameToId.getOrDefault(clusterName, ""); + if (clusterId.isEmpty()) { + return new ArrayList<>(); } + // copy a new List + return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); } public List<Backend> getBackendsByClusterId(final String clusterId) { - rlock.lock(); - try { - // copy a new List - return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); - } finally { - rlock.unlock(); - } + // copy a new List + return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); } public String getClusterNameByBeAddr(String beEndpoint) { @@ -588,27 +573,18 @@ public class CloudSystemInfoService extends SystemInfoService { } public List<String> getCloudClusterIds() { - rlock.lock(); - try { - return new ArrayList<>(clusterIdToBackend.keySet()); - } finally { - rlock.unlock(); - } + return new ArrayList<>(clusterIdToBackend.keySet()); } public String getCloudStatusByName(final String clusterName) { - rlock.lock(); - try { - String clusterId = clusterNameToId.getOrDefault(clusterName, ""); - if (Strings.isNullOrEmpty(clusterId)) { - // for rename cluster or dropped cluster - LOG.warn("cant find clusterId by clusteName {}", clusterName); - return ""; - } - return getCloudStatusByIdNoLock(clusterId); - } finally { - rlock.unlock(); + String clusterId = clusterNameToId.getOrDefault(clusterName, ""); + if (Strings.isNullOrEmpty(clusterId)) { + // for rename cluster or dropped cluster + LOG.warn("cant find clusterId by clusteName {}", clusterName); + return ""; } + // It is safe to return a null/empty status string, the caller handles it properly + return getCloudStatusByIdNoLock(clusterId); } public String getCloudStatusById(final String clusterId) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org