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

Lars Hofhansl commented on PHOENIX-3070:
----------------------------------------

Oops... I was wrong by a factor of 1000 :(  (my mirco benchmark was 1m loops, 
not 1000 loops as I had throught).
So a call to {{randomUUID}} takes 3us (not 3ms). It still shows up in a 
profiler session (sampling, so it's real).

Note that I tested with a single Thread only and that both {{SecureRandom}} and 
{{Random}} are very multithreading unfriendly, whereas {{ThreadLocalRandom}} is 
not.


> Unnecessary use of UUID.randomUUID()
> ------------------------------------
>
>                 Key: PHOENIX-3070
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3070
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>
> I see {{UUID.randomUUID()}} used all over Phoenix a lot.
> {{randomUUID}} uses {{SecureRandom}} internally, which - on my machine - 
> takes almost 3ms, and that is _per UUID_!
> I don't think we need a UUIDs from a cryptographically sound random number 
> generator.
> We could do {{new UUID(random.nextLong(), random.nextLong())}}, which takes 
> 0.06ms (60us), or even better: {{new 
> UUID(ThreadLocalRandom.current().nextLong(), 
> ThreadLocalRandom.current().nextLong())}}, which takes less than 0.004ms 
> (4us) on my box.



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

Reply via email to