You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/11/19 03:24:24 UTC

[GitHub] [rocketmq] XiaoyiPeng commented on a change in pull request #3509: [ISSUE #2516]: Fix the value of sendThreadPoolQueueHeadWaitTimeMills is 0 most of the time

XiaoyiPeng commented on a change in pull request #3509:
URL: https://github.com/apache/rocketmq/pull/3509#discussion_r752836279



##########
File path: broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
##########
@@ -650,10 +652,13 @@ public void protectBroker() {
 
     public long headSlowTimeMills(BlockingQueue<Runnable> q) {
         long slowTimeMills = 0;
-        final Runnable peek = q.peek();
-        if (peek != null) {
-            RequestTask rt = BrokerFastFailure.castRunnable(peek);
-            slowTimeMills = rt == null ? 0 : this.messageStore.now() - rt.getCreateTimestamp();
+        Optional<RequestTask> op = q.stream()

Review comment:
       Thanks for your review.
   
   It has nothing to do with thread safety, There is to reduce thread contention, `q` is polled by thread in `BrokerController#sendMessageExecutor` and will be peeked by thread in `BrokerController#scheduledExecutorService`  per second as shown below:
   
   ```
   this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
                   @Override
                   public void run() {
                       try {
                           BrokerController.this.printWaterMark();
                       } catch (Throwable e) {
                           log.error("printWaterMark error.", e);
                       }
                   }
               }, 10, 1, TimeUnit.SECONDS);
   ```
   You can look at the issue #2516 , get some context info first.




-- 
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@rocketmq.apache.org

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