You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/12/18 02:23:43 UTC

[GitHub] [rocketmq] xiaoyifang opened a new issue, #5729: [code disscussion] the use of threadlocal variabe in evenly distributed message logic?

xiaoyifang opened a new issue, #5729:
URL: https://github.com/apache/rocketmq/issues/5729

   https://github.com/apache/rocketmq/blob/81e3648e3fcb1995897db3960a4561d6047b696c/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java#L23-L35
   
   this threadLocal variable `threadLocalIndex` is used in many places and used to evenly distributed the message.
   
   IMO,I think threadlocal variable may not be a good idea,  a global variable should be more suitable.
   
   the threadlocal variable will has no problem especially when distibuting a large amount of message . But when the messages amount is small and messagequeue is a little bigger , there would be a chance to see the message is unevenly distributed.
   
   Why?
   
   ![image](https://user-images.githubusercontent.com/105986/208278330-39b37f18-b988-4606-badd-f02523c72b2b.png)
   
   
   
   I'm not very familiar with the distibution logic , so plz correct me if I'm wrong.
   


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

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


[GitHub] [rocketmq] ShadowySpirits commented on issue #5729: [code disscussion] the use of threadlocal variabe in evenly distributed message logic?

Posted by GitBox <gi...@apache.org>.
ShadowySpirits commented on issue #5729:
URL: https://github.com/apache/rocketmq/issues/5729#issuecomment-1357091670

   It is indeed uneven distribution when the number of messages is low. But it doesn't matter. IMO, only the uneven distribution of a large number of messages will have an impact on consumption. It may be a better choice to achieve eventual balance with less cost rather than absolute balance with complex consistency logic.


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

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


[GitHub] [rocketmq] xiaoyifang commented on issue #5729: [code disscussion] the use of threadlocal variabe in evenly distributed message logic?

Posted by GitBox <gi...@apache.org>.
xiaoyifang commented on issue #5729:
URL: https://github.com/apache/rocketmq/issues/5729#issuecomment-1357125675

   agreed ,
   
   another point is that the threadlocal can be replaced with a class variable. anyway it is not a big deal.


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

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


[GitHub] [rocketmq] xiaoyifang closed issue #5729: [code disscussion] the use of threadlocal variabe in evenly distributed message logic?

Posted by GitBox <gi...@apache.org>.
xiaoyifang closed issue #5729: [code disscussion] the use of threadlocal variabe in evenly distributed message logic?
URL: https://github.com/apache/rocketmq/issues/5729


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

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