[ 
https://issues.apache.org/jira/browse/STORM-1650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15208942#comment-15208942
 ] 

ASF GitHub Bot commented on STORM-1650:
---------------------------------------

Github user revans2 commented on the pull request:

    https://github.com/apache/storm/pull/1250#issuecomment-200490900
  
    @hustfxj 
    
    If you want to close this pull request I will leave it up to you. In some 
situations the uniqueness of a number is important, and having Random emit 
truly unique values in a thread safe way is important.  This is specifically 
when creating the tuple IDs that will be used with acking.
    
    In other situations we are using Random to do sub-sampling where the 
uniqueness of the numbers is not critical.  The correctness of the system is 
not compromised if the numbers are repeated or poorly distributed.  The only 
concern for those situations would be if we violate a contract, like we 
generate a random number that is not within the range specified by the API, or 
we deadlock, etc.  Looking at the code here we will never violate those 
constraints.  The worst thing that happens is that we may repeat some "random" 
numbers in different threads because the compiler cached the seed in a local 
register and didn't write back to memory.  For me the extra performance can 
outweigh the less then ideal situation.
    
    Looking at ThreadLocalRandom, they are using unsafe operations and I don't 
know enough about the internal implementation to feel comfortable saying if it 
will or will not violate any of the constraints, but I don't think it will.


> improve performance by XORShiftRandom
> -------------------------------------
>
>                 Key: STORM-1650
>                 URL: https://issues.apache.org/jira/browse/STORM-1650
>             Project: Apache Storm
>          Issue Type: Improvement
>            Reporter: John Fang
>            Assignee: John Fang
>
> '''Implement a random number generator based on the XORShift algorithm 
> discovered by George Marsaglia. This RNG is observed 4.5 times faster than 
> {@link Random} in benchmark, with the cost that abandon thread-safety. So 
> it's recommended to create a new {@link XORShiftRandom} for each thread.'''



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to