Re: Minor performance improvements
От | Stephen Denne |
---|---|
Тема | Re: Minor performance improvements |
Дата | |
Msg-id | F0238EBA67824444BC1CB4700960CB4802540178@dmpeints002.isotach.com обсуждение исходный текст |
Ответ на | Minor performance improvements ("Stephen Denne" <Stephen.Denne@datamail.co.nz>) |
Ответы |
Re: Minor performance improvements
(Kris Jurka <books@ejurka.com>)
|
Список | pgsql-jdbc |
I'm sad to say that I have not created any micro-benchmark tests, and unfortunately the improvements are very minor, andfar 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 insertSQL, 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 measurethe 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 (usingthe "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 valuesto _int4buf if you can write them into BufferedOutputStream's buffer? Most of the time you won't be going beyond theend of the buffer, so in general you'd be replacing three method calls with a call to System.arraycopy, which while extemelyfast, 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 couldyou 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 avoidrepeated method calls? Kris Jurka Disclaimer: At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any attachmentsis 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. __________________________________________________________________
В списке pgsql-jdbc по дате отправления: