This is an automated email from the ASF dual-hosted git repository.
earthchen pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new 8f2b4decdc End the 'read/write' combination operation early to improve
performance (#15666)
8f2b4decdc is described below
commit 8f2b4decdc618a50844ef3ab3dac6c7c1ca5c78a
Author: wb <[email protected]>
AuthorDate: Wed Sep 24 10:39:42 2025 +0800
End the 'read/write' combination operation early to improve performance
(#15666)
Co-authored-by: zrlw <[email protected]>
---
.../dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java
index 6d12d532d4..2aed6d2a74 100644
---
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java
+++
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java
@@ -51,6 +51,13 @@ public class ConsistentHashLoadBalance extends
AbstractLoadBalance {
String methodName = RpcUtils.getMethodName(invocation);
String key = invokers.get(0).getUrl().getServiceKey() + "." +
methodName;
int invokersHashCode = invokers.hashCode();
+ // If the detection is successful, return in advance. it may be
different from selector, but it doesn't matter
+ ConsistentHashSelector<T> oldSelector0;
+ if ((oldSelector0 = (ConsistentHashSelector<T>) selectors.get(key)) !=
null
+ && oldSelector0.identityHashCode == invokersHashCode) {
+ return oldSelector0.select(invocation);
+ }
+
// using the hashcode of invoker list to create consistent selector by
atomic computation.
ConsistentHashSelector<T> selector = (ConsistentHashSelector<T>)
selectors.compute(
key,