[PATCH] speed up java.util.Random
Paolo Bonzini
paolo.bonzini@lu.unisi.ch
Fri Nov 25 08:29:00 GMT 2005
I saw a PR some time ago about the slowness of java.util.Random in GNU
classpath. I cannot remember and cannot find the PR number, and
actually I cannot reproduce this slowness when comparing the classpath
implementation against the Sun implementation:
Sun JDK 1.4.2 4586 6038 6216 6254 6875 6952 6153.50
current classpath 3398 3586 3996 4169 4228 4962 4056.50
The huge variance is because I am compiling and running the benchmarks
with Sun's JITting virtual machine.
Still, inlining the next(int) method, while keeping the same result and
the synchronized behavior of java.util.Random, I could improve
performance by ~20%:
current classpath 3398 3586 3996 4169 4228 4962 4056.50
patched classpath 2585 2618 3465 3538 3606 3807 3269.83
I don't know how this can be contributed to GNU classpath. I attach a
patch with a changelog, and the tests I ran to validate my
implementation and to compare the relative speeds.
Paolo
2005-11-24 Paolo Bonzini <bonzini@gnu.org>
* java/util/Random.java: Rewrite, inlining the next(int) method
and synchronization blocks into the callers.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: RandomTest.java
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20051125/bff32c7d/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: RandomSpeed.java
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20051125/bff32c7d/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: faster-random.patch
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20051125/bff32c7d/attachment-0002.ksh>
More information about the Java-patches
mailing list