Query parsing speedup patch

From: Mikko Tiihonen <mokki(at)elisanet(dot)fi>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Query parsing speedup patch
Date: 2006-07-25 19:35:01
Message-ID: 1153856101.27322.9.camel@dual.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I spent one day trying to to optimise the parsing of ResultSets from the
stream. The attached patch gives around 35% speedup when parsing larger
queries containing equal amount of int4, int8 or varchar columns
assuming the system is CPU bound. I think parsing of other field types
could be similarly optimised.

I also attached the test code which I used to test the performance.

VisibleBufferedInputStream
- from scratch implementation that replaces BufferedInputStream
* not synchronised
* allows direct access to the buffer[] avoiding useless copies
when converting to String
* has method for scanning the length of next null terminated string

PGStream:
- uses VisibleBuffereInputStream
* faster implementations for for ReceiveIntegerR and ReceiveString

Encoding, AbstractJdbc2ResultSet
- parses int and long values directly from byte[] -> number instead
of first creating a throw-away string

Also, what would you think of patches that change all Vectors to
ArrayList and Hashtables to HashMaps? The difference is not too visible
when benchmarking with one thread and CPU but I believe that in larger
machines the useless synchronisation can slow down the system by
flushing the CPU write buffers. Also JIT could more freely modify the
code when there are less synchronisation points.

Attachment Content-Type Size
query-parsing-speedup.patch text/x-patch 19.3 KB
BenchTest.java text/x-csrc 5.2 KB

Browse pgsql-jdbc by date

  From Date Subject
Next Message alan 2006-07-26 06:44:35 Re: Invalid column display size. Cannot be less than zero
Previous Message Kris Jurka 2006-07-25 18:57:23 Re: PreparedStatement clearParameters and setTimestamp