Re: Performance tweaks - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Performance tweaks
Date
Msg-id 421BA910.9050706@opencloud.com
Whole thread Raw
In response to Re: Performance tweaks  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Oliver Jowett wrote:
> Ken Geis wrote:
>
>> I changed the line
>>
>>         byte[][] answer = new byte[l_nf][0];
>> to
>>         byte[][] answer = new byte[l_nf][];
>>
>> This gave ~1% increase on the benchmark I was running.
>
>
> Gah?! What JVM? Aren't the two forms equivalent?

Hmm, after some experimentation, they do produce different bytecode
(multianewarray vs. anewarray):

   public void testit() {
     byte[][] dummy = new byte[10][0];
     byte[][] dummy2 = new byte[10][];
   }

public void testit();
   Code:
    0:   bipush  10
    2:   iconst_0
    3:   multianewarray  #2,  2; //class "[[B"
    7:   astore_1
    8:   bipush  10
    10:  anewarray       #3; //class "[B"
    13:  astore_2
    14:  return

Interesting to know it makes a performance difference. What JVM did you
test on?

-O

pgsql-jdbc by date:

Previous
From: Alan Stange
Date:
Subject: Re: Performance tweaks
Next
From: Vadim Nasardinov
Date:
Subject: "multianewarray" vs. "anewarray" (was: Re: Performance tweaks)