You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "lrhkobe (via GitHub)" <gi...@apache.org> on 2023/12/19 08:28:15 UTC

[PR] [ISSUE #4630] Fix concurrency problem and split task handle threadpool (eventmesh)

lrhkobe opened a new pull request, #4679:
URL: https://github.com/apache/eventmesh/pull/4679

   
   
   Fixes #<4630>.
   
   ### Motivation
   
   * Fix the concurrency problem of clients in the same group frequently subscribing and unsubscribing.
   * Split the task handle thread pool to avoid mutual influence between operation commands and message sending and receiving
   
   
   
   ### Modifications
   
   * Add concurrency control for operation of ClientGroupWrapper when close session;
   * Split task handle thread pool to istinguish between operation commands and message processing, add sendExecutorService,replyExecutorService and ackExecutorService for msg processing.
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE #4630] Fix concurrency problem and split task handle threadpool (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4679:
URL: https://github.com/apache/eventmesh/pull/4679#issuecomment-1862386076

   CI failed, please have a check. Besides, the `Fixes #<4630>.` in your PR text should be `Fixes #4630.`~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4630] Fix concurrency problem and split task handle threadpool (eventmesh)

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4679:
URL: https://github.com/apache/eventmesh/pull/4679#issuecomment-1862609293

   ## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: `55 lines` in your changes are missing coverage. Please review.
   > Comparison is base [(`03aa825`)](https://app.codecov.io/gh/apache/eventmesh/commit/03aa825897bcee9563ba1075ca4b0f4774664efb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 17.39% compared to head [(`fd97a7c`)](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 17.38%.
   > Report is 1 commits behind head on master.
   
   | [Files](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...che/eventmesh/runtime/boot/TCPThreadPoolGroup.java](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2Jvb3QvVENQVGhyZWFkUG9vbEdyb3VwLmphdmE=) | 0.00% | [19 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...che/eventmesh/runtime/boot/EventMeshTCPServer.java](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2Jvb3QvRXZlbnRNZXNoVENQU2VydmVyLmphdmE=) | 0.00% | [11 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ol/tcp/client/group/ClientSessionGroupMapping.java](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvdGNwL2NsaWVudC9ncm91cC9DbGllbnRTZXNzaW9uR3JvdXBNYXBwaW5nLmphdmE=) | 0.00% | [11 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...tmesh/runtime/metrics/tcp/EventMeshTcpMonitor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL21ldHJpY3MvdGNwL0V2ZW50TWVzaFRjcE1vbml0b3IuamF2YQ==) | 0.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ntime/configuration/EventMeshTCPConfiguration.java](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvbmZpZ3VyYXRpb24vRXZlbnRNZXNoVENQQ29uZmlndXJhdGlvbi5qYXZh) | 73.33% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...cp/client/rebalance/EventMeshRebalanceService.java](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvdGNwL2NsaWVudC9yZWJhbGFuY2UvRXZlbnRNZXNoUmViYWxhbmNlU2VydmljZS5qYXZh) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #4679      +/-   ##
   ============================================
   - Coverage     17.39%   17.38%   -0.01%     
     Complexity     1759     1759              
   ============================================
     Files           797      797              
     Lines         29795    29839      +44     
     Branches       2578     2577       -1     
   ============================================
   + Hits           5182     5188       +6     
   - Misses        24132    24168      +36     
   - Partials        481      483       +2     
   ```
   
   
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/eventmesh/pull/4679?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4630] Fix concurrency problem and split task handle threadpool (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4679:
URL: https://github.com/apache/eventmesh/pull/4679#discussion_r1431118403


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshTCPConfiguration.java:
##########
@@ -59,7 +59,28 @@ public class EventMeshTCPConfiguration extends CommonConfiguration {
     private int eventMeshTcpGlobalScheduler = 5;
 
     @ConfigFiled(field = "tcp.taskHandleExecutorPoolSize")
-    private int eventMeshTcpTaskHandleExecutorPoolSize = Runtime.getRuntime().availableProcessors();
+    private int eventMeshTcpTaskHandleExecutorPoolSize = 2 * Runtime.getRuntime().availableProcessors();
+
+    @ConfigFiled(field = "tcp.sendExecutorPoolSize")
+    private int eventMeshTcpMsgSendExecutorPoolSize = 2 * Runtime.getRuntime().availableProcessors();
+
+    @ConfigFiled(field = "tcp.replyExecutorPoolSize")
+    private int eventMeshTcpMsgReplyExecutorPoolSize = 2 * Runtime.getRuntime().availableProcessors();
+
+    @ConfigFiled(field = "tcp.ackExecutorPoolSize")
+    private int eventMeshTcpMsgAckExecutorPoolSize = 2 * Runtime.getRuntime().availableProcessors();
+

Review Comment:
   Although this is an IO-intensive scenario, with the original single thread pool being split into four, and each thread pool having twice the coreSize as before, the number of threads is 8 times the original. Considering that the 1-RTT time in EventMesh is relatively short, I suggest setting the `coreSize` of each thread pool to the number of physical CPU cores and the `maxSize` to double that. What do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4630] Fix concurrency problem and split task handle threadpool (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4679:
URL: https://github.com/apache/eventmesh/pull/4679#discussion_r1431177811


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/TCPThreadPoolGroup.java:
##########
@@ -45,9 +48,27 @@ public void initThreadPool() {
         taskHandleExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
             eventMeshTCPConfiguration.getEventMeshTcpTaskHandleExecutorPoolSize(),
             eventMeshTCPConfiguration.getEventMeshTcpTaskHandleExecutorPoolSize(),
-            new LinkedBlockingQueue<>(10_000),
+            new LinkedBlockingQueue<>(eventMeshTCPConfiguration.getEventMeshTcpTaskHandleExecutorQueueSize()),
             new EventMeshThreadFactory("eventMesh-tcp-task-handle", true));
 
+        sendExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+            eventMeshTCPConfiguration.getEventMeshTcpMsgSendExecutorPoolSize(),
+            eventMeshTCPConfiguration.getEventMeshTcpMsgSendExecutorPoolSize(),
+            new LinkedBlockingQueue<>(eventMeshTCPConfiguration.getEventMeshTcpMsgSendExecutorQueueSize()),
+            new EventMeshThreadFactory("eventMesh-tcp-msg-send", true));
+
+        replyExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+            eventMeshTCPConfiguration.getEventMeshTcpMsgReplyExecutorPoolSize(),
+            eventMeshTCPConfiguration.getEventMeshTcpMsgReplyExecutorPoolSize(),
+            new LinkedBlockingQueue<>(eventMeshTCPConfiguration.getEventMeshTcpMsgReplyExecutorQueueSize()),
+            new EventMeshThreadFactory("eventMesh-tcp-msg-reply", true));
+
+        ackExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+            eventMeshTCPConfiguration.getEventMeshTcpMsgAckExecutorPoolSize(),
+            eventMeshTCPConfiguration.getEventMeshTcpMsgAckExecutorPoolSize(),
+            new LinkedBlockingQueue<>(eventMeshTCPConfiguration.getEventMeshTcpMsgAckExecutorQueueSize()),
+            new EventMeshThreadFactory("eventMesh-tcp-msg-ack", true));
+
         broadcastMsgDownstreamExecutorService = ThreadPoolFactory.createThreadPoolExecutor(

Review Comment:
   Can we change the queue length from a hard-coded value to a configurable value for this ExecutorService, like that of ExecutorServices above?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java:
##########
@@ -167,12 +167,20 @@ private void closeSession(Session session) throws Exception {
 
             session.setSessionState(SessionState.CLOSED);
 
-            if (EventMeshConstants.PURPOSE_SUB.equals(session.getClient().getPurpose())) {
-                cleanClientGroupWrapperByCloseSub(session);
-            } else if (EventMeshConstants.PURPOSE_PUB.equals(session.getClient().getPurpose())) {
-                cleanClientGroupWrapperByClosePub(session);
-            } else {
-                log.error("client purpose config is error:{}", session.getClient().getPurpose());
+            final String clientGroup = session.getClient().getGroup();
+            if (!lockMap.containsKey(clientGroup)) {
+               lockMap.putIfAbsent(clientGroup, new Object());

Review Comment:
   Can `if (!lockMap.containsKey(clientGroup))` be omitted here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4630] Fix concurrency problem and split task handle threadpool (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo merged PR #4679:
URL: https://github.com/apache/eventmesh/pull/4679


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org