binglind opened a new issue #1605: [improvement] use ThreadLocalRandom instead 
of Random
URL: https://github.com/apache/rocketmq/issues/1605
 
 
   ** Performance improvement **
   
   Random is thread safe for use by multiple threads. But if multiple threads 
use the same instance of Random, the same seed is shared by multiple threads. 
It leads to contention between multiple threads and so to performance 
degradation.
   
   ThreadLocalRandom is solution to above problem. ThreadLocalRandom has a 
Random instance per thread and safeguards against contention.
   
   According to jmh benchmark
   Benchmark                                               Mode  Cnt     Score  
   Error  Units
   RandomBenchmark.random                   avgt   10  2616.198 ± 316.004  ns/op
   RandomBenchmark.threadRandom      avgt   10     3.764 ±   0.095  ns/op
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to