wacky micro-benchmark
Kirk Pepperdine
kirk.pepperdine at gmail.com
Tue Feb 12 00:35:26 PST 2008
I've been fiddling with the loop invariant hoisting optimization trying to
demonstrate how it works. In my first iteration I used a long to sum up the
invariant in a loop. First run with -Xint showed 7.6 seconds for the hoisted
version and 15.4 for the non-hoisted version. Pretty much as one would
predict. Running with -client I see 3.5 seconds for hoisted and 6.3 for
non-hoisted. A bit of surprise because I figured the client would hoist the
invariant but it appears not to have. Then things got weird when I ran with
-server. The hoisted code ran in 6.3 seconds and non hoisted in 6.4. Now, I
expected the values to be about the same but not towards the slower end of
the spectrum.
I of course immediately suspected that the benchmark is bad as that is
usually is the case more often than not. However after lots of fiddles
(checking for mono/poly morphic optimizations... etc) I was unable to get a
different result which now leaves me wondering, is there something with long
in loop invariants that results in a slower optimization than expected? And
why would the client compiler not hoist the invariant.
One of the fiddles was to change the longs to ints. The server compiler ran
in (hoisted) 46ms and (non-hoisted) 47ms respectively. Difficult to say
without further testing if they are really the same. Client testing was
1188ms and 1297ms respectively. Again difficult to say without further
testing if these are the same. For completeness the -Xint values are 99.2sand
126.5s.
It was very nice to see that without having any return value, the -server
compiler identified the methods as dead and replaced the call with a noop.
So, does anyone have any comments (including you are a moron for attempting
this ;-)) on why the long invariant hoisting bench appears to be broken.
--
Kind regards,
Kirk Pepperdine
http://www.kodewerk.com
http://www.javaperformancetuning.com
http//www.cretesoft.com
public int hoist( int a, int b) {
int total = Integer.MIN_VALUE;
int hoisted = a + b;
for ( int i = 0; i < LOOP_COUNT; i++)
total += hoisted;
return total;
}
public int nonHoist( int a, int b) {
int total = Integer.MIN_VALUE;
for ( int i = 0; i < LOOP_COUNT; i++)
total += (a + b);
return total;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20080212/476d6a76/attachment.html
More information about the hotspot-dev
mailing list