Re: bytea performance tweak

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Andreas Schmitz <schmitz(at)occamlabs(dot)de>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: bytea performance tweak
Date: 2011-06-22 07:57:53
Message-ID: BANLkTincjfaot3pNo6Acj6aGbKS+gX+9dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 22 June 2011 16:24, Oliver Jowett <oliver(at)opencloud(dot)com> wrote:

> I've seen enough weird performance behavior from the JIT in the past
> to be inherently suspicious of anything that claims to be a speedup
> without numbers to back it up.
> If we have a benchmark to work from, then I'm sure there's even more
> performance we can squeeze out of it.

FWIW here's a quick microbenchmark.
Andreas' patch is about 5x faster than the current code.
A version using a one-dimensional lookup array is marginally faster again (7%).

$ java -server -version; uname -a; time java -server -classpath . Benchmark 5
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
Linux downpour 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC
2011 x86_64 x86_64 x86_64 GNU/Linux
original code, 1000 1161632 iterations in
5018679 us 4.32 us/iteration
2D array lookup, 1000 6025844 iterations in
4948308 us 0.82 us/iteration
1D array lookup, 1000 6361396 iterations in
4996605 us 0.79 us/iteration
original code, 100000 9196 iterations in
5019373 us 545.82 us/iteration
2D array lookup, 100000 57049 iterations in
4999200 us 87.63 us/iteration
1D array lookup, 100000 61162 iterations in
5000197 us 81.75 us/iteration

real 1m55.117s
user 1m55.400s
sys 0m0.210s

(I also tried some variations with induction variables but got no real
speedup and enough weird results to make me think it's confusing the
JIT)

There is also a bug in the original patch that I noticed along the way
(the initialization of HEX_LOOKUP doesn't use lo2/hi2) - fixed in the
benchmark code.

Oliver

Attachment Content-Type Size
Benchmark.java text/x-java 6.5 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andreas Schmitz 2011-06-22 14:17:12 Re: bytea performance tweak
Previous Message Oliver Jowett 2011-06-22 04:24:50 Re: bytea performance tweak