wacky micro-benchmark

John Rose John.Rose at Sun.COM
Tue Feb 12 01:57:29 PST 2008

Hi, Kirk.  You seem to be measuring noise.

Can someone on this list please produce
the standard URL about "10 mistakes you
shouldn't make when playing with
HotSpot and micro-benchmarks"?

The server compiler routinely hoists
values like a+b for you, since it uses
global value numbering.  It is therefore
compiling the same SSA graph in
both cases.

If you want to measure stuff like that,
you need to look at the disassembled
code and make sure your cases differ
in the way you expect.  I think you'd
be surprised (and find intriguing things
to ponder) if you were to study the
output code.  That's what I do when
I'm trying to figure out what the JIT
is thinking.

If you can find or build a "fastdebug"
version of the server JVM, run it
with -XX:+PrintOptoAssembly.

Best wishes,
-- John

P.S.  There's a Gnu-based disassembler also
which has internally been integrated with
HotSpot, but for various almost-forgettable
legal reasons we cannot easily release
it, yet.  Maybe some kind soul outside
of Sun can re-integrate it into HotSpot as a
hygenically factored disassembler.so.
The flag -XX:+PrintAssembly requires
this separate module, and when it
works it produces truly wonderful output.

On Feb 12, 2008, at 12:35 AM, Kirk Pepperdine wrote:

>     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;
>     }

More information about the hotspot-dev mailing list