pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Minor performance improvements
11+ messages / 3 participants
[nested] [flat]

* Minor performance improvements
@ 2007-02-26 21:51 Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-26 22:46 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Stephen Denne @ 2007-02-26 21:51 UTC (permalink / raw)
  To: pgsql-jdbc

Four small optimizations in org.postgresql.core.PGStream:

1) The int to byte conversion is not needed in this method:

    public void SendChar(int val) throws IOException
    {
        pg_output.write((byte)val);
    }

(I found this while profiling a test that included about 5000 queries. This method was called half a million times, and actually had the third largest "own time" behind executeBatch and executeQuery)

2) The byte masks are not required in SendInteger4 and SendInteger2, as OutputStream.write(int) ignores the top 24 bits. Though if these are removed I think comments should be included instead to clarify that only the bottom eight bits get written.

3) The method with the signature: void Send(byte buf[], int off, int siz), 
Could be rewritten so that the test occurs once instead of twice: (buf.length - off) < siz

4) two new parameterless methods should be added to optimize int ReceiveIntegerR(int siz) when called with size 2 and 4, as calls with these parameter values are very common. The call sites should change to use the new methods.

Stephen Denne
Java Developer
Corporate Development
Datamail Ltd
1 Victoria Street
Petone 5012
PO Box 31249
Lower Hutt 5040
Tel: +64 4 568 8200 extension 8638
Fax: +64 4 568 9600
Website: www.datamail.co.nz


</PRE><div style="font-size:8pt;font-family:Tahoma,Arial; text-align:justify; color:gray;"><br><br><hr size="0">At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage.<br><br>This email with any attachments is confidential and may be subject to legal privilege.  If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.<hr size="0"><br><br></div>
</PRE><div style="font-size:8pt;font-family:Arial; text-align:center;"><br><br><hr size="0">
This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite.<br>
Please see <a href="http://www.dmzglobal.com/services/bqem.htm">http://www.dmzglobal.com/services/bqem.htm</a; for details.<br>
<hr size="0"><br><br></div>


^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-26 21:51 Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
@ 2007-02-26 22:46 ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Kris Jurka @ 2007-02-26 22:46 UTC (permalink / raw)
  To: Stephen Denne <Stephen.Denne@datamail.co.nz>; +Cc: pgsql-jdbc



On Tue, 27 Feb 2007, Stephen Denne wrote:

> Four small optimizations in org.postgresql.core.PGStream:
>

Could you share some more of your results with us?  What sort of 
improvment did you see by making these changes?  Or could you share your 
test case code so we can do some timing of our own?

> 2) The byte masks are not required in SendInteger4 and SendInteger2, as 
> OutputStream.write(int) ignores the top 24 bits. Though if these are 
> removed I think comments should be included instead to clarify that only 
> the bottom eight bits get written.

Would using a class member byte[] _int4buf = new byte[4], filling it, and 
passing this to Send(byte buf[]) be better by avoid repeated method calls?

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
@ 2007-02-27 03:08 Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 04:24 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Stephen Denne @ 2007-02-27 03:08 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

I'm sad to say that I have not created any micro-benchmark tests, and unfortunately the improvements are very minor, and far overshadowed by the variability I get from my system.

My code wasn't even using Send(byte buf[], int off, int siz).

The portion of my application that I am testing is essentially doing bulk loading. I'm using PreparedStatement of insert SQL, a lot of setXXX() and addBatch() calls, and the occasional executeBatch().
Running in Java5, using jdbc driver 8.2.504.jdbc3 connecting to PostgreSQL 8.2.3 with about 40Gb data and indexes in it, all on WinXP.

The test ends up performing about 5200 inserts.

The improvement I do see (which prompted my email) is in fewer bytecodes being used to perform the same functionality.

Adding profiling in to such small methods also results in a larger impact (I'm using YourKit Java Profiler).

That said... this implementation was about 30% faster over about 88,000 calls:

    public void SendInteger4(int val) throws IOException
    {
        pg_output.write(val >> 24);
        pg_output.write(val >> 16);
        pg_output.write(val >> 8);
        pg_output.write(val);
    }

SendInteger2 was similarly improved.

These changes meant that SendChar usage was reduced from about 560,000 calls to about 40,000, making it difficult to measure the time saved by removing the double up of the int to byte conversion.

Interesting thought about using _int4buf, and it took me a while to make up my mind whether it would be faster or not (using the "Java Puzzlers" technique of deciding what I think some code would do before testing my assertions). 

I think the difference in the overall work you are doing is that you are adding a buffer to buffer copy. Why write the values to _int4buf if you can write them into BufferedOutputStream's buffer? Most of the time you won't be going beyond the end of the buffer, so in general you'd be replacing three method calls with a call to System.arraycopy, which while extemely fast, I think would be slower than not calling it at all.

Regards,
Stephen Denne.

-----Original Message-----
From: Kris Jurka [mailto:books@ejurka.com] 
Sent: Tuesday, 27 February 2007 11:47 a.m.
To: Stephen Denne
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Minor performance improvements



On Tue, 27 Feb 2007, Stephen Denne wrote:

> Four small optimizations in org.postgresql.core.PGStream:
>

Could you share some more of your results with us?  What sort of improvment did you see by making these changes?  Or could you share your test case code so we can do some timing of our own?

> 2) The byte masks are not required in SendInteger4 and SendInteger2, 
> as
> OutputStream.write(int) ignores the top 24 bits. Though if these are 
> removed I think comments should be included instead to clarify that 
> only the bottom eight bits get written.

Would using a class member byte[] _int4buf = new byte[4], filling it, and passing this to Send(byte buf[]) be better by avoid repeated method calls?

Kris Jurka

Disclaimer:
At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any attachments is confidential and may be subject to legal privilege.  If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.

__________________________________________________________________
  This email has been scanned by the DMZGlobal Business Quality 
              Electronic Messaging Suite.
Please see http://www.dmzglobal.com/services/bqem.htm for details.
__________________________________________________________________




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
@ 2007-02-27 04:24 ` Kris Jurka <books@ejurka.com>
  2007-02-27 08:21   ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Kris Jurka @ 2007-02-27 04:24 UTC (permalink / raw)
  To: Stephen Denne <Stephen.Denne@datamail.co.nz>; +Cc: pgsql-jdbc



On Tue, 27 Feb 2007, Stephen Denne wrote:

> I'm sad to say that I have not created any micro-benchmark tests, and 
> unfortunately the improvements are very minor, and far overshadowed by 
> the variability I get from my system.
>

I've created the attached test which tests the original code (Orig), your 
code (Two), and my suggestion of an int4buf (Three) and got the following 
surprising results:

jurka@tony:~/pg/jdbc/projects/perf/micro$ java -classpath . Tester Orig | 
sort -n
11335
11370
11468
11484
11487
jurka@tony:~/pg/jdbc/projects/perf/micro$ java -classpath . Tester Two | 
sort -n
12472
12476
12489
12492
12619
jurka@tony:~/pg/jdbc/projects/perf/micro$ java -classpath . Tester Three | 
sort -n
4259
4562
4564
4611
4689

This shows your code is actually slower than the original code, although I 
have no idea why that could be.  It shows the int4buf idea as a clear 
winner.  I'm a little suspicious of the whole test because of your numbers 
going up.  Could you take a look at this and possibly confirm the results? 
I'm not sure if windows has an equivalent to /dev/null, but I wanted to 
avoid any impact of disk io.

Kris Jurka

Attachments:

Tester.java (text/plain, 1.8K) download import java.io.*; public class Tester { public static void main(String args[]) throws Exception { if (args.length != 1) { System.err.println("Usage: java Tester <iml>"); System.exit(1); } Class c = Class.forName(args[0]); Test t = (Test)c.newInstance(); for (int i=0; i<5; i++) { t.test(); } t.close(); } } abstract class Test { protected OutputStream pg_output; Test() throws IOException { pg_output = new BufferedOutputStream(new FileOutputStream("/dev/null"), 8192); } void close() throws IOException { pg_output.close(); } void test() throws IOException { long start = System.currentTimeMillis(); for (int i=0; i<100000000; i++) { SendInteger4(i); } long stop = System.currentTimeMillis(); System.out.println(stop - start); } protected abstract void SendInteger4(int val) throws IOException; } class Orig extends Test { Orig() throws IOException { } private void SendChar(int val) throws IOException { pg_output.write((byte)val); } protected void SendInteger4(int val) throws IOException { SendChar((val >> 24)&255); SendChar((val >> 16)&255); SendChar((val >> 8)&255); SendChar(val&255); } } class Two extends Test { Two() throws IOException { } protected void SendInteger4(int val) throws IOException { pg_output.write(val >> 24); pg_output.write(val >> 16); pg_output.write(val >> 8); pg_output.write(val); } } class Three extends Test { private byte[] intbuf; Three() throws IOException { intbuf = new byte[4]; } protected void SendInteger4(int val) throws IOException { intbuf[0] = (byte)((val >> 24) & 255); intbuf[1] = (byte)((val >> 16) & 255); intbuf[2] = (byte)((val >> 8) & 255); intbuf[3] = (byte)((val) & 255); pg_output.write(intbuf); } }
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 04:24 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
@ 2007-02-27 08:21   ` Kris Jurka <books@ejurka.com>
  2007-02-27 10:46     ` Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 13:42     ` Re: Minor performance improvements Nelson Arape <narape@ica.luz.ve>
  0 siblings, 2 replies; 11+ messages in thread

From: Kris Jurka @ 2007-02-27 08:21 UTC (permalink / raw)
  To: Stephen Denne <Stephen.Denne@datamail.co.nz>; +Cc: pgsql-jdbc



On Mon, 26 Feb 2007, Kris Jurka wrote:

> I've created the attached test which tests the original code (Orig), your 
> code (Two), and my suggestion of an int4buf (Three) and got the following 
> surprising results:
>

Based on that test and a similar attached test for reading, I'm prepared 
to apply the attached patch.  Let me know what you think.

Kris Jurka

Attachments:

Read.java (text/plain, 1.9K) download import java.io.*; public class Read { public static void main(String args[]) throws Exception { if (args.length != 1) { System.err.println("Usage: java Read <impl>"); System.exit(1); } Class c = Class.forName(args[0]); Test t = (Test)c.newInstance(); for (int i=0; i<5; i++) { t.test(); } t.close(); } } abstract class Test { protected InputStream pg_input; Test() throws IOException { pg_input = new BufferedInputStream(new FileInputStream("/dev/zero"), 8192); } void close() throws IOException { pg_input.close(); } void test() throws IOException { long start = System.currentTimeMillis(); for (int i=0; i<100000000; i++) { ReceiveIntegerR(4); } long stop = System.currentTimeMillis(); System.out.println(stop - start); } protected abstract int ReceiveIntegerR(int siz) throws IOException; } class Orig extends Test { Orig() throws IOException { } protected int ReceiveIntegerR(int siz) throws IOException { int n = 0; for (int i = 0 ; i < siz ; i++) { int b = pg_input.read() & 0xFF; n = b | (n << 8); } switch (siz) { case 1: return (int)((byte)n); case 2: return (int)((short)n); default: return n; } } } class Two extends Test { Two() throws IOException { } protected int ReceiveIntegerR(int siz) throws IOException { int n = pg_input.read() & 0xFF; n = pg_input.read() | (n << 8); n = pg_input.read() | (n << 8); n = pg_input.read() | (n << 8); return n; } } class Three extends Test { private byte[] intbuf; Three() throws IOException { intbuf = new byte[4]; } protected int ReceiveIntegerR(int siz) throws IOException { pg_input.read(intbuf); return (intbuf[0] & 0xFF) << 24 | (intbuf[1] & 0xFF) << 16 | (intbuf[2] & 0xFF) << 8 | intbuf[3] & 0xFF; } }
pgstream-perf.patch.gz (application/octet-stream, 4.4K) download ^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 04:24 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  2007-02-27 08:21   ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
@ 2007-02-27 10:46     ` Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-28 06:08       ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Stephen Denne @ 2007-02-27 10:46 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

Sorry for the formatting of this message....

I tested using a ByteBuffer wrapped as an IntBuffer... quite good, but not the fastest.

I had a different implementation in mind for Send(byte buf[], int off, int siz) along the lines of:

int i = buf.length - off;

if (i < siz) {

pg_output.write(buf, off, i);

for (; i < siz; ++i) {

pg_output.write(0);

}

} else {

pg_output.write(buf, off, siz);

}

 
Is there a reason for removing pg_input.ensureBytes(siz)? I see you're checking the length of what was read instead. Is this always equivalent or sufficient? Does it block in diferent ways?
 
When converting ints to bytes, you do not need to mask with 255 (see int0 to int3 in java.nio.Bits).
 
Is it possible other people have code that is calling ReceiveIntegerR(int siz)?
 
Stephen Denne.

________________________________

From: Kris Jurka [mailto:books@ejurka.com]
Sent: Tue 27/02/2007 9:21 p.m.
To: Stephen Denne
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Minor performance improvements





On Mon, 26 Feb 2007, Kris Jurka wrote:

> I've created the attached test which tests the original code (Orig), your
> code (Two), and my suggestion of an int4buf (Three) and got the following
> surprising results:
>

Based on that test and a similar attached test for reading, I'm prepared
to apply the attached patch.  Let me know what you think.

Kris Jurka


</PRE><div style="font-size:8pt;font-family:Tahoma,Arial; text-align:justify; color:gray;"><br><br><hr size="0">At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage.<br><br>This email with any attachments is confidential and may be subject to legal privilege.  If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.<hr size="0"><br><br></div>
</PRE><div style="font-size:8pt;font-family:Arial; text-align:center;"><br><br><hr size="0">
This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite.<br>
Please see <a href="http://www.dmzglobal.com/services/bqem.htm">http://www.dmzglobal.com/services/bqem.htm</a; for details.<br>
<hr size="0"><br><br></div>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 04:24 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  2007-02-27 08:21   ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  2007-02-27 10:46     ` Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
@ 2007-02-28 06:08       ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Kris Jurka @ 2007-02-28 06:08 UTC (permalink / raw)
  To: Stephen Denne <Stephen.Denne@datamail.co.nz>; +Cc: pgsql-jdbc



On Tue, 27 Feb 2007, Stephen Denne wrote:

> I had a different implementation in mind for Send(byte buf[], int off, 
> int siz) along the lines of:
>

I'm not convinced this will be significantly faster, but it is slightly 
clearer, so I've incorporated it.

> Is there a reason for removing pg_input.ensureBytes(siz)? I see you're 
> checking the length of what was read instead. Is this always equivalent 
> or sufficient? Does it block in diferent ways?

Internally VisibleBufferedInputStream will end up calling ensureBytes in 
the read call.  I don't think the actual read length check is necessary, 
but it's the sort of thing that could easily break if we changed the 
VisbibleBufferedInputStream implementation.

> When converting ints to bytes, you do not need to mask with 255 (see 
> int0 to int3 in java.nio.Bits).

Yes, removed.

> Is it possible other people have code that is calling 
> ReceiveIntegerR(int siz)?
>

No, PGStream is an internal only class.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 04:24 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  2007-02-27 08:21   ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
@ 2007-02-27 13:42     ` Nelson Arape <narape@ica.luz.ve>
  2007-02-28 06:14       ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Nelson Arape @ 2007-02-27 13:42 UTC (permalink / raw)
  To: pgsql-jdbc

Hi Kris

I think that your patch could be better if instead of using the "signed" right 
shift operator (>>) followed by a bit mask, use directly the "unsigned" right 
shift operator (>>>)

So 
((val >> 24) & 0xFF)
would better as
val >>> 24

By the way great work folks

Nelson Arapé
A happy Postgres JDBC user in his first time post to the list

PS: Sorry for my english, not my native language

El Martes, 27 de Febrero de 2007 04:21, Kris Jurka escribió:
> On Mon, 26 Feb 2007, Kris Jurka wrote:
> > I've created the attached test which tests the original code (Orig), your
> > code (Two), and my suggestion of an int4buf (Three) and got the following
> > surprising results:
>
> Based on that test and a similar attached test for reading, I'm prepared
> to apply the attached patch.  Let me know what you think.
>
> Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
  2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
  2007-02-27 04:24 ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  2007-02-27 08:21   ` Re: Minor performance improvements Kris Jurka <books@ejurka.com>
  2007-02-27 13:42     ` Re: Minor performance improvements Nelson Arape <narape@ica.luz.ve>
@ 2007-02-28 06:14       ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Kris Jurka @ 2007-02-28 06:14 UTC (permalink / raw)
  To: Nelson Arape <narape@ica.luz.ve>; +Cc: pgsql-jdbc



On Tue, 27 Feb 2007, Nelson Arape wrote:

> I think that your patch could be better if instead of using the "signed" 
> right shift operator (>>) followed by a bit mask, use directly the 
> "unsigned" right shift operator (>>>)

Indeed that does improve things slightly.  I didn't even know that 
operator existed.

I've applied this patch:
http://gborg.postgresql.org/pipermail/pgjdbc-commit/2007-February/000594.html

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
@ 2007-02-27 05:29 Stephen Denne <Stephen.Denne@datamail.co.nz>
  0 siblings, 0 replies; 11+ messages in thread

From: Stephen Denne @ 2007-02-27 05:29 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

So it does.

I used 

pg_output = new BufferedOutputStream(new OutputStream() {public void write(int b) throws IOException {}}, 8192); 

And confirm that I get similar slowdown for my code, and much faster operation for your code.

The only thing I can think might be going on with your code is the hotspot compiler recognising the bytecode pattern in use, and using the fastest method it knows of filling that byte array.

SendInteger2 behaves the same surprising way.

Regards,
Stephen.

-----Original Message-----
From: Kris Jurka [mailto:books@ejurka.com] 
Sent: Tuesday, 27 February 2007 5:24 p.m.
To: Stephen Denne
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Minor performance improvements



On Tue, 27 Feb 2007, Stephen Denne wrote:

> I'm sad to say that I have not created any micro-benchmark tests, and 
> unfortunately the improvements are very minor, and far overshadowed by 
> the variability I get from my system.
>

I've created the attached test which tests the original code (Orig), your code (Two), and my suggestion of an int4buf (Three) and got the following surprising results:

jurka@tony:~/pg/jdbc/projects/perf/micro$ java -classpath . Tester Orig | sort -n
11335
11370
11468
11484
11487
jurka@tony:~/pg/jdbc/projects/perf/micro$ java -classpath . Tester Two | sort -n
12472
12476
12489
12492
12619
jurka@tony:~/pg/jdbc/projects/perf/micro$ java -classpath . Tester Three | sort -n
4259
4562
4564
4611
4689

This shows your code is actually slower than the original code, although I have no idea why that could be.  It shows the int4buf idea as a clear winner.  I'm a little suspicious of the whole test because of your numbers going up.  Could you take a look at this and possibly confirm the results? 
I'm not sure if windows has an equivalent to /dev/null, but I wanted to avoid any impact of disk io.

Kris Jurka

Disclaimer:
At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any attachments is confidential and may be subject to legal privilege.  If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.

__________________________________________________________________
  This email has been scanned by the DMZGlobal Business Quality 
              Electronic Messaging Suite.
Please see http://www.dmzglobal.com/services/bqem.htm for details.
__________________________________________________________________




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: Minor performance improvements
@ 2007-02-27 13:45 Nelson Arape <narape@ica.luz.ve>
  0 siblings, 0 replies; 11+ messages in thread

From: Nelson Arape @ 2007-02-27 13:45 UTC (permalink / raw)
  To: pgsql-jdbc

Post this time to the list, the last time I sent it to Kris directly, sorry 
for that
Hi Kris

I think that your patch could be better if instead of using the "signed" right 
shift operator (>>) followed by a bit mask, use directly the "unsigned" right 
shift operator (>>>)

So 
((val >> 24) & 0xFF)
would better as
val >>> 24

By the way great work folks

Nelson Arapé
A happy Postgres JDBC user in his first time post to the list

PS: Sorry for my english, not my native language

El Martes, 27 de Febrero de 2007 04:21, Kris Jurka escribió:
> On Mon, 26 Feb 2007, Kris Jurka wrote:
> > I've created the attached test which tests the original code (Orig), your
> > code (Two), and my suggestion of an int4buf (Three) and got the following
> > surprising results:
>
> Based on that test and a similar attached test for reading, I'm prepared
> to apply the attached patch.  Let me know what you think.
>
> Kris Jurka

^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2007-02-28 06:14 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-02-26 21:51 Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
2007-02-26 22:46 ` Kris Jurka <books@ejurka.com>
2007-02-27 03:08 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
2007-02-27 04:24 ` Kris Jurka <books@ejurka.com>
2007-02-27 08:21   ` Kris Jurka <books@ejurka.com>
2007-02-27 10:46     ` Stephen Denne <Stephen.Denne@datamail.co.nz>
2007-02-28 06:08       ` Kris Jurka <books@ejurka.com>
2007-02-27 13:42     ` Nelson Arape <narape@ica.luz.ve>
2007-02-28 06:14       ` Kris Jurka <books@ejurka.com>
2007-02-27 05:29 Re: Minor performance improvements Stephen Denne <Stephen.Denne@datamail.co.nz>
2007-02-27 13:45 Re: Minor performance improvements Nelson Arape <narape@ica.luz.ve>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox