Skip site navigation (1) Skip section navigation (2)

Re: Performance tweaks

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Ken Geis <kgeis(at)speakeasy(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Performance tweaks
Date: 2005-02-22 21:50:08
Message-ID: 421BA910.9050706@opencloud.com (view raw or flat)
Thread:
Lists: 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

In response to

pgsql-jdbc by date

Next:From: Vadim NasardinovDate: 2005-02-22 21:57:04
Subject: "multianewarray" vs. "anewarray" (was: Re: Performance tweaks)
Previous:From: Alan StangeDate: 2005-02-22 21:48:57
Subject: Re: Performance tweaks

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group