Improving performance and reducing object allocations of java.util.UUID to/from string (original) (raw)

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu Jan 10 12:50:56 UTC 2013


On 01/09/2013 09:51 PM, Steven Schlansker wrote:

Hello again,

I sent this email a week ago and have received no replies. Is there any step I have missed necessary to contribute to the JDK libraries?

I think the crucial part is OCA, as per: http://openjdk.java.net/contribute/

I am very interested in making your lives easier, so please let me know if I am in the wrong place or are otherwise misguided.

You are at the correct place.

On the first glance, the change looks good for the start. A few comments though: a) Do you need the masks before or-ing with most/leastSigBits? b) Is there a more standard (and still performant) way to do the hex conversion? Look around JDK source, I think there should be something else needing the same kind of conversion. c) I'd go for making utility methods a bit more generic. For one, I would rather make decodeHex(String str, int start, int end), and encodeHex(char[] dest, int offset, int value).

Microbenchmark glitches: a) % is the integer division, and at the scale of the operations you are measuring, it could incur significant costs; the usual practice is having power-of-2 size, and then (i % size) -> (i & (size - 1)). b) Not sure if you want to stick with random UUIDs for comparisons. While the law of large numbers is on your side, 1000 random UUIDs might be not random enough.

-Aleksey.



More information about the core-libs-dev mailing list