RFR: 8308804: Improve UUID.randomUUID performance with bulk/scalable PRNG access

Aleksey Shipilev shade at openjdk.org
Fri May 26 09:38:01 UTC 2023


On Fri, 26 May 2023 08:39:10 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/UUID.java line 260:
>> 
>>> 258:                         buf[c + 8] &= 0x3f;  /* clear variant        */
>>> 259:                         buf[c + 8] |= (byte) 0x80;  /* set to IETF variant  */
>>> 260:                     }
>> 
>> I'm not sure I understand the point about initialization. Why not just setting the required version bits right in UUID constructor without updating the array? This will be faster and simpler IMO.
>
> Right, we can do things straight on locals, without ever touching the heap, let's see...

Yup, that works beautifully.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14135#discussion_r1206499212


More information about the core-libs-dev mailing list