pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedUnnessecary use of new Integer(n) in AbstractJdbc2ResultSet
8+ messages / 4 participants
[nested] [flat]
* Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-23 16:24 Daniel Migowski <dmigowski@ikoffice.de>
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Migowski @ 2011-04-23 16:24 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
I am using the postgresql driver 8.3-604-jdbc3, and noticed something strange in my profiling reports:
In Line 2518 of AbstractJdbc2ResultSet, in function findColumnIndex, there is a call to "new Integer(n)", which takes 2% overall time in my app! It should be replaced by "Integer.valueOf(n)", because this doesn't create any new instances on Integer for the usecase found here!
Regards,
Daniel Migowski
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 02:21 Kris Jurka <books@ejurka.com>
parent: Daniel Migowski <dmigowski@ikoffice.de>
0 siblings, 0 replies; 8+ messages in thread
From: Kris Jurka @ 2011-04-25 02:21 UTC (permalink / raw)
To: Daniel Migowski <dmigowski@ikoffice.de>; +Cc: pgsql-jdbc
On Sat, 23 Apr 2011, Daniel Migowski wrote:
> I am using the postgresql driver 8.3-604-jdbc3, and noticed something
> strange in my profiling reports:
>
> In Line 2518 of AbstractJdbc2ResultSet, in function findColumnIndex, there
> is a call to "new Integer(n)", which takes 2% overall time in my app! It
> should be replaced by "Integer.valueOf(n)", because this doesn't create any
> new instances on Integer for the usecase found here!
>
Integer.valueOf appeared in JDK 1.5 and we currently still support JDK
1.4. There's been talk of ditching 1.4 support, but that hasn't
officially happened yet and isn't something we'd do for older driver
releases.
Kris Jurka
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 04:23 Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Grittner @ 2011-04-25 04:23 UTC (permalink / raw)
To: books@ejurka.com; dmigowski@ikoffice.de; +Cc: pgsql-jdbc
Kris Jurka wrote:
> Integer.valueOf appeared in JDK 1.5 and we currently still support
> JDK 1.4. There's been talk of ditching 1.4 support, but that hasn't
> officially happened yet and isn't something we'd do for older
> driver releases.
Would it be practical to do it in the JDBC4 build?
On a related note, are we using the -target switch to build for the
lowest supported release (1.4 for JDBC3 and 1.6 for JDBC4)? If not,
would that be practical?
(I'm not very good at reading or writing ant....)
-Kevin
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 04:50 Kris Jurka <books@ejurka.com>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 8+ messages in thread
From: Kris Jurka @ 2011-04-25 04:50 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: dmigowski@ikoffice.de; pgsql-jdbc
On 4/24/2011 9:23 PM, Kevin Grittner wrote:
> Kris Jurka wrote:
>
>> Integer.valueOf appeared in JDK 1.5 and we currently still support
>> JDK 1.4. There's been talk of ditching 1.4 support, but that hasn't
>> officially happened yet and isn't something we'd do for older
>> driver releases.
>
> Would it be practical to do it in the JDBC4 build?
In this case, yes, but not in general. findColumn is pretty localized,
so duplicating it's code in an inherited class wouldn't be too bad.
> On a related note, are we using the -target switch to build for the
> lowest supported release (1.4 for JDBC3 and 1.6 for JDBC4)? If not,
> would that be practical?
No, the -target switch is really pretty useless for our purposes. We
must build with the actual JDK we want to use. -target only affects the
generated class files, but we need the correct API version to build
against. Since we're implementing things like the Connection interface,
the -target switch doesn't magically change the interface definition to
the version in the original JDK.
Kris Jurka
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 10:54 Lew <noone@lewscanon.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 8+ messages in thread
From: Lew @ 2011-04-25 10:54 UTC (permalink / raw)
To: pgsql-jdbc
On 04/25/2011 12:50 AM, Kris Jurka wrote:
> On 4/24/2011 9:23 PM, Kevin Grittner wrote:
>> Kris Jurka wrote:
>>
>>> Integer.valueOf appeared in JDK 1.5 and we currently still support
>>> JDK 1.4. There's been talk of ditching 1.4 support, but that hasn't
>>> officially happened yet and isn't something we'd do for older
>>> driver releases.
>>
>> Would it be practical to do it in the JDBC4 build?
>
> In this case, yes, but not in general. findColumn is pretty localized, so
> duplicating it's code in an inherited class wouldn't be too bad.
>
>> On a related note, are we using the -target switch to build for the
>> lowest supported release (1.4 for JDBC3 and 1.6 for JDBC4)? If not,
>> would that be practical?
>
> No, the -target switch is really pretty useless for our purposes. We must
> build with the actual JDK we want to use. -target only affects the generated
> class files, but we need the correct API version to build against. Since we're
> implementing things like the Connection interface, the -target switch doesn't
> magically change the interface definition to the version in the original JDK.
Yeah, you have to use -bootclasspath to get the right rt.jar if you use -target.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 15:46 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: Lew <noone@lewscanon.com>
0 siblings, 2 replies; 8+ messages in thread
From: Kevin Grittner @ 2011-04-25 15:46 UTC (permalink / raw)
To: Lew <noone@lewscanon.com>; pgsql-jdbc
Lew <noone@lewscanon.com> wrote:
> On 04/25/2011 12:50 AM, Kris Jurka wrote:
>> On 4/24/2011 9:23 PM, Kevin Grittner wrote:
>>> On a related note, are we using the -target switch to build for
>>> the lowest supported release (1.4 for JDBC3 and 1.6 for JDBC4)?
>>> If not, would that be practical?
>>
>> No, the -target switch is really pretty useless for our purposes.
>> We must build with the actual JDK we want to use. -target only
>> affects the generated class files
Right, it specifies the earliest JVM version on which the class
files can be run based on the bytecode level. This is separate from
but related to the library against which it is compiled -- pointing
to an earlier library ensures that a class or method from a later
version won't be referenced. The jar files available for download
use an earlier bytecode version than needed, which limits
performance unnecessarily. We can't actually run on those earlier
versions because of the classes and methods reference.
I just downloaded the "postgresql-9.1dev-900" jars, and I find that
the -jdbc3 jar has a bytecode version compatible with a JDK 1.0 and
1.1 JVMs, even though we reference classes and methods which aren't
available until later JVMs. The -jdbc4 jar is compiled for a JDK
1.4 JVM, even though it references classes and methods not included
until 1.6. Now, this doesn't hurt functionality, since a later 1.X
JVM is guaranteed to run earlier 1.X bytecode, but optimizations
added in later JVMs can't be compiled in, so the bytecode will run
slower.
> Yeah, you have to use -bootclasspath to get the right rt.jar if
> you use -target.
I guess I didn't make my point very clearly. I don't want to
compile with an *earlier* target. The *default* is to compile with
the earlier bytecode target. It won't actually *run* on the earlier
JVMs because we're using the later API, so we're just hurting
performance by *not* forcing the '-target 1.4' for -jdbc3 and
'-target 1.6' for -jdbc4.
If you don't believe me, look at this page for the bytecode level
values stored in offsets 4 to 7 of a class file:
http://stackoverflow.com/questions/1293308/java-api-to-find-out-the-jdk-version-a-class-file-is-comp...
and unzip the jar files to see how that's set.
-Kevin
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 16:44 Lew <noone@lewscanon.com>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
1 sibling, 0 replies; 8+ messages in thread
From: Lew @ 2011-04-25 16:44 UTC (permalink / raw)
To: pgsql-jdbc
Kevin Grittner wrote:
> Lew wrote:
>> Yeah, you have to use -bootclasspath to get the right rt.jar if
>> you use -target.
>
> I guess I didn't make my point very clearly. I don't want to
> compile with an *earlier* target. The *default* is to compile with
> the earlier bytecode target. It won't actually *run* on the earlier
> JVMs because we're using the later API, so we're just hurting
> performance by *not* forcing the '-target 1.4' for -jdbc3 and
> '-target 1.6' for -jdbc4.
>
> If you don't believe me, look at this page for the bytecode level
Oh, I believe you!
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet
@ 2011-04-25 21:06 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
1 sibling, 0 replies; 8+ messages in thread
From: Kevin Grittner @ 2011-04-25 21:06 UTC (permalink / raw)
To: Lew <noone@lewscanon.com>; pgsql-jdbc; Kevin Grittner <Kevin.Grittner@wicourts.gov>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:
> I just downloaded the "postgresql-9.1dev-900" jars, and I find
> that the -jdbc3 jar has a bytecode version compatible with a JDK
> 1.0 and 1.1 JVMs, even though we reference classes and methods
> which aren't available until later JVMs.
I just double-checked, and found that I'd messed up my initial check
on that. The right target level is used for each. Sorry for the
noise.
-Kevin
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2011-04-25 21:06 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-04-23 16:24 Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet Daniel Migowski <dmigowski@ikoffice.de>
2011-04-25 02:21 ` Kris Jurka <books@ejurka.com>
2011-04-25 04:23 Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-25 04:50 ` Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet Kris Jurka <books@ejurka.com>
2011-04-25 10:54 ` Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet Lew <noone@lewscanon.com>
2011-04-25 15:46 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-25 16:44 ` Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet Lew <noone@lewscanon.com>
2011-04-25 21:06 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
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