RFR [7192942] Optimizing calculation of power of 2 in HashMap
Mike Duigou
mike.duigou at oracle.com
Tue Jul 30 16:32:04 UTC 2013
Hi Ivan;
This looks like a good improvement. My only disappointment is that I didn't notice it when adding the roundUpToPowerOf2 method!
Do you need a sponsor to push the fix?
Mike
On Jul 30 2013, at 08:35 , Ivan Gerasimov wrote:
> Hello everybody!
>
> HashTable needs to calculate the power of two that is not less that the given number.
> This calculation used to be implemented as a relatively inefficient loop (that's why the issue 7192942 was created).
> The implementation was improved with http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/2e3cc7f599ca
>
> However it can be improved even more. I reused 7192942 number for this propose.
>
> Would you please help with reviewing?
> Here's the webrev: http://cr.openjdk.java.net/~igerasim/7192942/0/webrev/ <http://cr.openjdk.java.net/%7Eigerasim/7192942/0/webrev/>
>
> I also created a benchmark test to make sure the improvement is observable.
> Here's the jmh benchmark I used:
> http://cr.openjdk.java.net/~igerasim/bench/powoftwo/src/main/java/org/benches/PowerOfTwoBench.java <http://cr.openjdk.java.net/%7Eigerasim/bench/powoftwo/src/main/java/org/benches/PowerOfTwoBench.java>
>
> Benchmark Mode Thr Cnt Sec Mean Mean error Units
> o.b.PowerOfTwoBench.benchPowerOfTwoA avgt 1 20 5 60.697 0.850 msec/op
> o.b.PowerOfTwoBench.benchPowerOfTwoB avgt 1 20 5 53.013 0.940 msec/op
>
> The first line is for the current implementation and the second one is for the proposed change.
> Thus, the time gets reduced by 12%.
>
> Sincerely yours,
> Ivan
More information about the core-libs-dev
mailing list