You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/02/06 04:24:32 UTC

[dubbo] branch 3.0 updated: refactor: Optimize performance (#9578)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new e979803  refactor: Optimize performance (#9578)
e979803 is described below

commit e9798036c8b6b4bdd998378437968408a5ae8f63
Author: 桔子 <ju...@qq.com>
AuthorDate: Sun Feb 6 12:24:20 2022 +0800

    refactor: Optimize performance (#9578)
    
    * refactor: Optimize performance
    
    If there is already an element in the queue, it is no longer requested
    
    * refactor: Optimize queue memory
---
 .../org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java
index 6439c46..301cede 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java
@@ -81,11 +81,14 @@ public class ForkingClusterInvoker<T> extends AbstractClusterInvoker<T> {
             }
             RpcContext.getServiceContext().setInvokers((List) selected);
             final AtomicInteger count = new AtomicInteger();
-            final BlockingQueue<Object> ref = new LinkedBlockingQueue<>();
+            final BlockingQueue<Object> ref = new LinkedBlockingQueue<>(1);
             for (final Invoker<T> invoker : selected) {
                 URL consumerUrl = RpcContext.getServiceContext().getConsumerUrl();
                 executor.execute(() -> {
                     try {
+                        if (ref.size() > 0) {
+                            return;
+                        }
                         Result result = invokeWithContextAsync(invoker, invocation, consumerUrl);
                         ref.offer(result);
                     } catch (Throwable e) {