pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRE: High memory usage [PATCH]
46+ messages / 9 participants
[nested] [flat]
* RE: High memory usage [PATCH]
@ 2001-06-20 03:40 Rainer Mager <rmager@vgkk.com>
0 siblings, 2 replies; 46+ messages in thread
From: Rainer Mager @ 2001-06-20 03:40 UTC (permalink / raw)
To: pgsql-admin
Attached is my patch to the official 7.1.2 PreparedStatement.java class.
This seems to work quite well for me in a test case. To try to reproduce the
seen problem I will need to test all night. I'll report tomorrow.
BTW, this is my first attempt at making a unified diff so I might have done
something wrong. If this diff doesn't apply please tell me.
--Rainer
> -----Original Message-----
> From: pgsql-admin-owner@postgresql.org
> [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Rainer Mager
> Sent: Wednesday, June 20, 2001 9:08 AM
> To: Tom Lane
> Cc: PostgreSQL Admin
> Subject: RE: [ADMIN] High memory usage
>
>
> I'll work on a patch but if someone has already done this I would be
> grateful.
Attachments:
PreparedStatement.java.diff (application/octet-stream, 3.5K) download
--- PreparedStatement.java Sat Feb 17 01:45:00 2001
+++ PreparedStatement.java.new Wed Jun 20 12:34:57 2001
@@ -39,10 +39,12 @@
// Some performance caches
private StringBuffer sbuf = new StringBuffer();
- // We use ThreadLocal for SimpleDateFormat's because they are not that
- // thread safe, so each calling thread has its own object.
- private ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
- private ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
+ // Because SimpleDateFormat is not thread safe we create one for each
+ // PreparedStatemnt here AND synchronize on it for each usage.
+ // We can NOT use ThreadLocal because they are not freed until the thread
+ // completes. This would be a memory leak for long running threads.
+ private SimpleDateFormat df = null;
+ private SimpleDateFormat tsdf = null;
/**
* Constructor for the PreparedStatement class.
@@ -90,9 +92,6 @@
* New in 7.1 - overides Statement.close() to dispose of a few local objects
*/
public void close() throws SQLException {
- // free the ThreadLocal caches
- tl_df.set(null);
-
super.close();
}
@@ -332,14 +331,18 @@
*/
public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
- if(df==null) {
+ // The df DateFormat is initialized here to delay creation until needed.
+ if( df == null ) {
+ synchronized( this ) {
+ if( df == null ) {
df = new SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
+ }
+ }
}
- set(parameterIndex, df.format(x));
-
+ // We must synchronize here because SimpleDateFormat is not thread safe.
+ synchronized( df ) {
+ set( parameterIndex, df.format(x) );
// The above is how the date should be handled.
//
// However, in JDK's prior to 1.1.6 (confirmed with the
@@ -351,6 +354,7 @@
//
//set(parameterIndex, df.format(new java.util.Date(x.getTime()+86400000)));
}
+ }
/**
* Set a parameter to a java.sql.Time value. The driver converts
@@ -375,17 +379,22 @@
*/
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
- if(df==null) {
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- tl_tsdf.set(df);
+ // The tsdf DateFormat is initialized here to delay creation until needed.
+ if( tsdf == null ) {
+ synchronized( this ) {
+ if( tsdf == null ) {
+ tsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ tsdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+ }
}
- df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ // We must synchronize here because SimpleDateFormat is not thread safe.
+ synchronized( tsdf ) {
// Use the shared StringBuffer
synchronized(sbuf) {
sbuf.setLength(0);
- sbuf.append("'").append(df.format(x)).append('.').append(x.getNanos()/10000000).append("+00'");
+ sbuf.append("'").append(tsdf.format(x)).append('.').append(x.getNanos()/10000000).append("+00'");
set(parameterIndex, sbuf.toString());
}
@@ -393,6 +402,7 @@
// to be identical. Pays to read the docs ;-)
//set(parameterIndex,"'"+x.toString()+"'");
}
+ }
/**
* When a very large ASCII value is input to a LONGVARCHAR parameter,
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: High memory usage [PATCH]
@ 2001-06-21 02:08 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Rainer Mager <rmager@vgkk.com>
1 sibling, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-21 02:08 UTC (permalink / raw)
To: Rainer Mager <rmager@vgkk.com>; +Cc: pgsql-admin
Patch format looks good to me. I will wait to see what others say about
its content.
> Attached is my patch to the official 7.1.2 PreparedStatement.java class.
> This seems to work quite well for me in a test case. To try to reproduce the
> seen problem I will need to test all night. I'll report tomorrow.
>
> BTW, this is my first attempt at making a unified diff so I might have done
> something wrong. If this diff doesn't apply please tell me.
>
> --Rainer
>
> > -----Original Message-----
> > From: pgsql-admin-owner@postgresql.org
> > [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Rainer Mager
> > Sent: Wednesday, June 20, 2001 9:08 AM
> > To: Tom Lane
> > Cc: PostgreSQL Admin
> > Subject: RE: [ADMIN] High memory usage
> >
> >
> > I'll work on a patch but if someone has already done this I would be
> > grateful.
[ Attachment, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-21 22:23 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Rainer Mager <rmager@vgkk.com>
1 sibling, 1 reply; 46+ messages in thread
From: Bruce Momjian @ 2001-06-21 22:23 UTC (permalink / raw)
To: Rainer Mager <rmager@vgkk.com>; +Cc: PostgreSQL jdbc list <pgsql-jdbc@postgresql.org>; PostgreSQL-patches <pgsql-patches@postgresql.org>
JDBC folks, can you comment on this patch? Thanks.
> Attached is my patch to the official 7.1.2 PreparedStatement.java class.
> This seems to work quite well for me in a test case. To try to reproduce the
> seen problem I will need to test all night. I'll report tomorrow.
>
> BTW, this is my first attempt at making a unified diff so I might have done
> something wrong. If this diff doesn't apply please tell me.
>
> --Rainer
>
> > -----Original Message-----
> > From: pgsql-admin-owner@postgresql.org
> > [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Rainer Mager
> > Sent: Wednesday, June 20, 2001 9:08 AM
> > To: Tom Lane
> > Cc: PostgreSQL Admin
> > Subject: RE: [ADMIN] High memory usage
> >
> >
> > I'll work on a patch but if someone has already done this I would be
> > grateful.
[ Attachment, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Attachments:
/bjm/diff (text/plain, 3.5K) download
--- PreparedStatement.java Sat Feb 17 01:45:00 2001
+++ PreparedStatement.java.new Wed Jun 20 12:34:57 2001
@@ -39,10 +39,12 @@
// Some performance caches
private StringBuffer sbuf = new StringBuffer();
- // We use ThreadLocal for SimpleDateFormat's because they are not that
- // thread safe, so each calling thread has its own object.
- private ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
- private ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
+ // Because SimpleDateFormat is not thread safe we create one for each
+ // PreparedStatemnt here AND synchronize on it for each usage.
+ // We can NOT use ThreadLocal because they are not freed until the thread
+ // completes. This would be a memory leak for long running threads.
+ private SimpleDateFormat df = null;
+ private SimpleDateFormat tsdf = null;
/**
* Constructor for the PreparedStatement class.
@@ -90,9 +92,6 @@
* New in 7.1 - overides Statement.close() to dispose of a few local objects
*/
public void close() throws SQLException {
- // free the ThreadLocal caches
- tl_df.set(null);
-
super.close();
}
@@ -332,14 +331,18 @@
*/
public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
- if(df==null) {
+ // The df DateFormat is initialized here to delay creation until needed.
+ if( df == null ) {
+ synchronized( this ) {
+ if( df == null ) {
df = new SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
+ }
+ }
}
- set(parameterIndex, df.format(x));
-
+ // We must synchronize here because SimpleDateFormat is not thread safe.
+ synchronized( df ) {
+ set( parameterIndex, df.format(x) );
// The above is how the date should be handled.
//
// However, in JDK's prior to 1.1.6 (confirmed with the
@@ -351,6 +354,7 @@
//
//set(parameterIndex, df.format(new java.util.Date(x.getTime()+86400000)));
}
+ }
/**
* Set a parameter to a java.sql.Time value. The driver converts
@@ -375,17 +379,22 @@
*/
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
- if(df==null) {
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- tl_tsdf.set(df);
+ // The tsdf DateFormat is initialized here to delay creation until needed.
+ if( tsdf == null ) {
+ synchronized( this ) {
+ if( tsdf == null ) {
+ tsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ tsdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+ }
}
- df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ // We must synchronize here because SimpleDateFormat is not thread safe.
+ synchronized( tsdf ) {
// Use the shared StringBuffer
synchronized(sbuf) {
sbuf.setLength(0);
- sbuf.append("'").append(df.format(x)).append('.').append(x.getNanos()/10000000).append("+00'");
+ sbuf.append("'").append(tsdf.format(x)).append('.').append(x.getNanos()/10000000).append("+00'");
set(parameterIndex, sbuf.toString());
}
@@ -393,6 +402,7 @@
// to be identical. Pays to read the docs ;-)
//set(parameterIndex,"'"+x.toString()+"'");
}
+ }
/**
* When a very large ASCII value is input to a LONGVARCHAR parameter,
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 00:33 Dave Cramer <Dave@micro-automation.net>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-22 00:33 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; Rainer Mager <rmager@vgkk.com>; +Cc: PostgreSQL jdbc list <pgsql-jdbc@postgresql.org>
my two cents worth...
1) what is the problem that this is trying to solve, I assume from the
subject that it is some sort of high memory usage?
2) I am trying to understand how a statement would ever be used by more than
one thread at a time? I would think that it would be impossible to share
statements across threads.
3) The double locking method used is alledgedly unsafe on SMP machines
http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double_p.html.
Dave
----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "Rainer Mager" <rmager@vgkk.com>
Cc: "PostgreSQL jdbc list" <pgsql-jdbc@postgresql.org>; "PostgreSQL-patches"
<pgsql-patches@postgresql.org>
Sent: Thursday, June 21, 2001 6:23 PM
Subject: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>
> JDBC folks, can you comment on this patch? Thanks.
>
>
> > Attached is my patch to the official 7.1.2 PreparedStatement.java class.
> > This seems to work quite well for me in a test case. To try to reproduce
the
> > seen problem I will need to test all night. I'll report tomorrow.
> >
> > BTW, this is my first attempt at making a unified diff so I might have
done
> > something wrong. If this diff doesn't apply please tell me.
> >
> > --Rainer
> >
> > > -----Original Message-----
> > > From: pgsql-admin-owner@postgresql.org
> > > [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Rainer Mager
> > > Sent: Wednesday, June 20, 2001 9:08 AM
> > > To: Tom Lane
> > > Cc: PostgreSQL Admin
> > > Subject: RE: [ADMIN] High memory usage
> > >
> > >
> > > I'll work on a patch but if someone has already done this I would be
> > > grateful.
>
> [ Attachment, skipping... ]
>
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman@candle.pha.pa.us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
----------------------------------------------------------------------------
----
> --- PreparedStatement.java Sat Feb 17 01:45:00 2001
> +++ PreparedStatement.java.new Wed Jun 20 12:34:57 2001
> @@ -39,10 +39,12 @@
> // Some performance caches
> private StringBuffer sbuf = new StringBuffer();
>
> - // We use ThreadLocal for SimpleDateFormat's because they are not
that
> - // thread safe, so each calling thread has its own object.
> - private ThreadLocal tl_df = new ThreadLocal(); // setDate()
SimpleDateFormat
> - private ThreadLocal tl_tsdf = new ThreadLocal(); //
setTimestamp() SimpleDateFormat
> + // Because SimpleDateFormat is not thread safe we create one for each
> + // PreparedStatemnt here AND synchronize on it for each usage.
> + // We can NOT use ThreadLocal because they are not freed until the
thread
> + // completes. This would be a memory leak for long running threads.
> + private SimpleDateFormat df = null;
> + private SimpleDateFormat tsdf = null;
>
> /**
> * Constructor for the PreparedStatement class.
> @@ -90,9 +92,6 @@
> * New in 7.1 - overides Statement.close() to dispose of a few
local objects
> */
> public void close() throws SQLException {
> - // free the ThreadLocal caches
> - tl_df.set(null);
> -
> super.close();
> }
>
> @@ -332,14 +331,18 @@
> */
> public void setDate(int parameterIndex, java.sql.Date x) throws
SQLException
> {
> - SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
> - if(df==null) {
> + // The df DateFormat is initialized here to delay creation until needed.
> + if( df == null ) {
> + synchronized( this ) {
> + if( df == null ) {
> df = new SimpleDateFormat("''yyyy-MM-dd''");
> - tl_df.set(df);
> + }
> + }
> }
>
> - set(parameterIndex, df.format(x));
> -
> + // We must synchronize here because SimpleDateFormat is not thread safe.
> + synchronized( df ) {
> + set( parameterIndex, df.format(x) );
> // The above is how the date should be handled.
> //
> // However, in JDK's prior to 1.1.6 (confirmed with the
> @@ -351,6 +354,7 @@
> //
> //set(parameterIndex, df.format(new
java.util.Date(x.getTime()+86400000)));
> }
> + }
>
> /**
> * Set a parameter to a java.sql.Time value. The driver converts
> @@ -375,17 +379,22 @@
> */
> public void setTimestamp(int parameterIndex, Timestamp x) throws
SQLException
> {
> - SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
> - if(df==null) {
> - df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> - tl_tsdf.set(df);
> + // The tsdf DateFormat is initialized here to delay creation until
needed.
> + if( tsdf == null ) {
> + synchronized( this ) {
> + if( tsdf == null ) {
> + tsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> + tsdf.setTimeZone(TimeZone.getTimeZone("GMT"));
> + }
> + }
> }
> - df.setTimeZone(TimeZone.getTimeZone("GMT"));
>
> + // We must synchronize here because SimpleDateFormat is not thread safe.
> + synchronized( tsdf ) {
> // Use the shared StringBuffer
> synchronized(sbuf) {
> sbuf.setLength(0);
> -
sbuf.append("'").append(df.format(x)).append('.').append(x.getNanos()/100000
00).append("+00'");
> +
sbuf.append("'").append(tsdf.format(x)).append('.').append(x.getNanos()/1000
0000).append("+00'");
> set(parameterIndex, sbuf.toString());
> }
>
> @@ -393,6 +402,7 @@
> // to be identical. Pays to read the docs ;-)
> //set(parameterIndex,"'"+x.toString()+"'");
> }
> + }
>
> /**
> * When a very large ASCII value is input to a LONGVARCHAR parameter,
>
----------------------------------------------------------------------------
----
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 04:56 Rainer Mager <rmager@vgkk.com>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 2 replies; 46+ messages in thread
From: Rainer Mager @ 2001-06-22 04:56 UTC (permalink / raw)
To: Dave Cramer <Dave@micro-automation.net>; Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: PostgreSQL jdbc list <pgsql-jdbc@postgresql.org>
Good questions, I'll answer what I can...
> 1) what is the problem that this is trying to solve, I assume from the
> subject that it is some sort of high memory usage?
Yes it involves memory usage and a memory leak. Basically, the way the code
was before the patch, each instantiation of a PreparedStatement created 2
new ThreadLocal objects. According to Sun's Javadocs, these objects are not
freed until the thread is completed. For a single thread app or main thread
of an application (in our case a server) the thread NEVER goes away.
Therefore these ThreadLocal objects just keep adding up and using memory,
forever.
The patch removes the use of these ThreadLocals.
> 2) I am trying to understand how a statement would ever be used
> by more than
> one thread at a time? I would think that it would be impossible to share
> statements across threads.
This I can't really answer. The code appeared to be written to be thread
safe so I attempted to continue that. Whether thread safe for a Statement is
necessary or not I can't directly say. Although, I agree with you, I can't
imagine a need to use a single Statement in multiple threads.
> 3) The double locking method used is alledgedly unsafe on SMP machines
> http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double_p.html.
Interesting. I wasn't aware of this. If question #2 is answered such that
thread safe isn't necessary, then this problem goes away pretty easily. If
thread safety is needed then this would have to be rewritten, I can look
into doing this if you like.
> Dave
--Rainer
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 11:42 Gunnar Rønning <gunnar@polygnosis.com>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 1 reply; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-22 11:42 UTC (permalink / raw)
To: Dave Cramer <Dave@micro-automation.net>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; Rainer Mager <rmager@vgkk.com>; PostgreSQL jdbc list <pgsql-jdbc@postgresql.org>
* "Dave Cramer" <Dave@micro-automation.net> wrote:
|
| my two cents worth...
|
| 1) what is the problem that this is trying to solve, I assume from the
| subject that it is some sort of high memory usage?
I would like to know as well.
| 2) I am trying to understand how a statement would ever be used by more than
| one thread at a time? I would think that it would be impossible to share
| statements across threads.
Quite easy. Just the same way as you share any other object across threads
and according to the JDBC spec requires that the driver shoudl be thread
safe.
| 3) The double locking method used is alledgedly unsafe on SMP machines
| http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double_p.html.
Yup, double checked locking is not going to guarantee that you get
properly initialized objects with the current Java spec.
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 13:19 Dave Cramer <davec@sentricity.com>
parent: Gunnar Rønning <gunnar@polygnosis.com>
0 siblings, 1 reply; 46+ messages in thread
From: Dave Cramer @ 2001-06-22 13:19 UTC (permalink / raw)
To: gunnar@polygnosis.com; +Cc: 'Bruce Momjian' <pgman@candle.pha.pa.us>; 'Rainer Mager' <rmager@vgkk.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
On the thread safe issue: I am having a hard time understanding how one
would share a statement across threads. I would expect that threadsafe
just means don't use static buffers so that I can have multiple
statements in multiple threads. I don't think it is possible to have two
threads concurrently doing a query using one statement. This being said,
I don't thing it is necessary to go to great lengths to lock within the
statement as long as all the members within the statement are
non-static.
Comments?
-----Original Message-----
From: gunnar@polygnosis.com [mailto:gunnar@polygnosis.com]
Sent: June 22, 2001 7:42 AM
To: Dave Cramer
Cc: Bruce Momjian; Rainer Mager; PostgreSQL jdbc list
Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
* "Dave Cramer" <Dave@micro-automation.net> wrote:
|
| my two cents worth...
|
| 1) what is the problem that this is trying to solve, I assume from the
| subject that it is some sort of high memory usage?
I would like to know as well.
| 2) I am trying to understand how a statement would ever be used by
more than
| one thread at a time? I would think that it would be impossible to
share
| statements across threads.
Quite easy. Just the same way as you share any other object across
threads
and according to the JDBC spec requires that the driver shoudl be thread
safe.
| 3) The double locking method used is alledgedly unsafe on SMP machines
| http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double_p.html.
Yup, double checked locking is not going to guarantee that you get
properly initialized objects with the current Java spec.
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 14:02 Gunnar Rønning <gunnar@polygnosis.com>
parent: Dave Cramer <davec@sentricity.com>
0 siblings, 0 replies; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-22 14:02 UTC (permalink / raw)
To: Dave Cramer <davec@sentricity.com>; +Cc: 'Bruce Momjian' <pgman@candle.pha.pa.us>; 'Rainer Mager' <rmager@vgkk.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
* "Dave Cramer" <davec@sentricity.com> wrote:
|
| On the thread safe issue: I am having a hard time understanding how one
| would share a statement across threads. I would expect that threadsafe
| just means don't use static buffers so that I can have multiple
| statements in multiple threads. I don't think it is possible to have two
| threads concurrently doing a query using one statement. This being said,
| I don't thing it is necessary to go to great lengths to lock within the
| statement as long as all the members within the statement are
| non-static.
|
| Comments?
According to the spec. you should be able to reference the same statement
from several threads at the same time. I never do this myself but there
might be scenarios where this is feasible, ie. another thread calls
Statement.cancel() to cancel the execution of a long running statement.
I definitaly think the JDBC driver for PostgreSQL needs more attention from
the community. It seems like Peter Mount has very little time to spend on it,
unfortunately that is the case with me as well(as long as I don't get paid
for it...). Among other things I would love to see better support for
BLOBs, but I for now we will have to go with MySQL :-(
regards,
Gunnar
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 14:13 Gunnar Rønning <gunnar@polygnosis.com>
parent: Rainer Mager <rmager@vgkk.com>
1 sibling, 2 replies; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-22 14:13 UTC (permalink / raw)
To: Rainer Mager <rmager@vgkk.com>; +Cc: Dave Cramer <Dave@micro-automation.net>; Bruce Momjian <pgman@candle.pha.pa.us>; PostgreSQL jdbc list <pgsql-jdbc@postgresql.org>
* "Rainer Mager" <rmager@vgkk.com> wrote:
|
| Interesting. I wasn't aware of this. If question #2 is answered such that
| thread safe isn't necessary, then this problem goes away pretty easily. If
| thread safety is needed then this would have to be rewritten, I can look
| into doing this if you like.
Thread safety is required by the spec. Do you have "JDBC API tutorial and
reference, 2 ed." from Addison Wesley ? This book contains a section for
JDBC driver writers and explains this issue.
regards,
Gunnar
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 14:34 Dave Cramer <Dave@micro-automation.net>
parent: Rainer Mager <rmager@vgkk.com>
1 sibling, 0 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-22 14:34 UTC (permalink / raw)
To: 'Rainer Mager' <rmager@vgkk.com>; 'Bruce Momjian' <pgman@candle.pha.pa.us>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
I am going to have a look at the spec in more detail to see how they
expect the driver to be used within threads
I am in a similar situation wrt using the driver in server and will
check if the memory usage is better.
Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Rainer Mager
Sent: June 22, 2001 12:56 AM
To: Dave Cramer; Bruce Momjian
Cc: PostgreSQL jdbc list
Subject: RE: [JDBC] Re: [ADMIN] High memory usage [PATCH]
Good questions, I'll answer what I can...
> 1) what is the problem that this is trying to solve, I assume from the
> subject that it is some sort of high memory usage?
Yes it involves memory usage and a memory leak. Basically, the way the
code
was before the patch, each instantiation of a PreparedStatement created
2
new ThreadLocal objects. According to Sun's Javadocs, these objects are
not
freed until the thread is completed. For a single thread app or main
thread
of an application (in our case a server) the thread NEVER goes away.
Therefore these ThreadLocal objects just keep adding up and using
memory,
forever.
The patch removes the use of these ThreadLocals.
> 2) I am trying to understand how a statement would ever be used
> by more than
> one thread at a time? I would think that it would be impossible to
share
> statements across threads.
This I can't really answer. The code appeared to be written to be thread
safe so I attempted to continue that. Whether thread safe for a
Statement is
necessary or not I can't directly say. Although, I agree with you, I
can't
imagine a need to use a single Statement in multiple threads.
> 3) The double locking method used is alledgedly unsafe on SMP machines
> http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double_p.html.
Interesting. I wasn't aware of this. If question #2 is answered such
that
thread safe isn't necessary, then this problem goes away pretty easily.
If
thread safety is needed then this would have to be rewritten, I can look
into doing this if you like.
> Dave
--Rainer
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 14:42 Michael Stephenson <mstephenson@tirin.openworld.co.uk>
parent: Gunnar Rønning <gunnar@polygnosis.com>
1 sibling, 1 reply; 46+ messages in thread
From: Michael Stephenson @ 2001-06-22 14:42 UTC (permalink / raw)
To: PostgreSQL jdbc list <pgsql-jdbc@postgresql.org>
[snip]
Wouldn't it be more elegant simply to make the ThreadLocal's static (as
I'd have thought was probably the intention of the original author), this
would remove the possiblity of any memory leaks in a single threaded
environment, and have the same affect ultimately in a multithreaded
environment?
Michael Stephenson
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 15:20 Dave Cramer <dave@fastcrypt.com>
parent: Michael Stephenson <mstephenson@tirin.openworld.co.uk>
0 siblings, 0 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-22 15:20 UTC (permalink / raw)
To: 'Michael Stephenson' <mstephenson@tirin.openworld.co.uk>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>
Yes, this is the correct approach, great advice!
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Michael Stephenson
Sent: June 22, 2001 10:42 AM
To: PostgreSQL jdbc list
Subject: [JDBC] Re: Re: [ADMIN] High memory usage [PATCH]
[snip]
Wouldn't it be more elegant simply to make the ThreadLocal's static (as
I'd have thought was probably the intention of the original author),
this
would remove the possiblity of any memory leaks in a single threaded
environment, and have the same affect ultimately in a multithreaded
environment?
Michael Stephenson
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://www.postgresql.org/search.mpl
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-22 19:09 Dave Cramer <Dave@micro-automation.net>
parent: Gunnar Rønning <gunnar@polygnosis.com>
1 sibling, 2 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-22 19:09 UTC (permalink / raw)
To: 'Gunnar Rønning' <gunnar@polygnosis.com>; 'Rainer Mager' <rmager@vgkk.com>; +Cc: 'Bruce Momjian' <pgman@candle.pha.pa.us>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Here is a patch which inspired by Michael Stephens that should work
Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar Rønning
Sent: June 22, 2001 10:14 AM
To: Rainer Mager
Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
* "Rainer Mager" <rmager@vgkk.com> wrote:
|
| Interesting. I wasn't aware of this. If question #2 is answered such
that
| thread safe isn't necessary, then this problem goes away pretty
easily. If
| thread safety is needed then this would have to be rewritten, I can
look
| into doing this if you like.
Thread safety is required by the spec. Do you have "JDBC API tutorial
and
reference, 2 ed." from Addison Wesley ? This book contains a section for
JDBC driver writers and explains this issue.
regards,
Gunnar
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Attachments:
PreparedStatement.diff (application/octet-stream, 2.8K) download
*** PreparedStatement.java Fri Jun 22 14:52:45 2001
--- PreparedStatement.new Fri Jun 22 14:51:29 2001
***************
*** 41,48 ****
// We use ThreadLocal for SimpleDateFormat's because they are not that
// thread safe, so each calling thread has its own object.
! private ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
! private ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
/**
* Constructor for the PreparedStatement class.
--- 41,48 ----
// We use ThreadLocal for SimpleDateFormat's because they are not that
// thread safe, so each calling thread has its own object.
! private static ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
! private static ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
/**
* Constructor for the PreparedStatement class.
***************
*** 64,69 ****
--- 64,78 ----
this.sql = sql;
this.connection = connection;
+
+ // might just as well create it here, so we don't take the hit later
+
+ SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''");
+ tl_df.set(df);
+
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ tl_tsdf.set(df);
+
for (i = 0; i < sql.length(); ++i)
{
int c = sql.charAt(i);
***************
*** 89,98 ****
/**
* New in 7.1 - overides Statement.close() to dispose of a few local objects
*/
! public void close() throws SQLException {
// free the ThreadLocal caches
tl_df.set(null);
!
super.close();
}
--- 98,108 ----
/**
* New in 7.1 - overides Statement.close() to dispose of a few local objects
*/
! public void close() throws SQLException
! {
// free the ThreadLocal caches
tl_df.set(null);
! tl_tsdf.set(null);
super.close();
}
***************
*** 333,342 ****
public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
{
SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
- if(df==null) {
- df = new SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
- }
set(parameterIndex, df.format(x));
--- 343,348 ----
***************
*** 376,385 ****
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
{
SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
- if(df==null) {
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- tl_tsdf.set(df);
- }
df.setTimeZone(TimeZone.getTimeZone("GMT"));
// Use the shared StringBuffer
--- 382,387 ----
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-23 03:00 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-23 03:00 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Gunnar Rønning' <gunnar@polygnosis.com>; 'Rainer Mager' <rmager@vgkk.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Your patch has been added to the PostgreSQL unapplied patches list at:
http://candle.pha.pa.us/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
> Here is a patch which inspired by Michael Stephens that should work
>
> Dave
>
>
> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
> Sent: June 22, 2001 10:14 AM
> To: Rainer Mager
> Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
> Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>
> * "Rainer Mager" <rmager@vgkk.com> wrote:
> |
>
> | Interesting. I wasn't aware of this. If question #2 is answered such
> that
> | thread safe isn't necessary, then this problem goes away pretty
> easily. If
> | thread safety is needed then this would have to be rewritten, I can
> look
> | into doing this if you like.
>
> Thread safety is required by the spec. Do you have "JDBC API tutorial
> and
> reference, 2 ed." from Addison Wesley ? This book contains a section for
>
> JDBC driver writers and explains this issue.
>
> regards,
>
> Gunnar
>
> --
> Gunnar R?nning - gunnar@polygnosis.com
> Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 01:53 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 1 reply; 46+ messages in thread
From: Bruce Momjian @ 2001-06-25 01:53 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Gunnar Rønning' <gunnar@polygnosis.com>; 'Rainer Mager' <rmager@vgkk.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Patch applied. Thanks.
> Here is a patch which inspired by Michael Stephens that should work
>
> Dave
>
>
> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
> Sent: June 22, 2001 10:14 AM
> To: Rainer Mager
> Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
> Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>
> * "Rainer Mager" <rmager@vgkk.com> wrote:
> |
>
> | Interesting. I wasn't aware of this. If question #2 is answered such
> that
> | thread safe isn't necessary, then this problem goes away pretty
> easily. If
> | thread safety is needed then this would have to be rewritten, I can
> look
> | into doing this if you like.
>
> Thread safety is required by the spec. Do you have "JDBC API tutorial
> and
> reference, 2 ed." from Addison Wesley ? This book contains a section for
>
> JDBC driver writers and explains this issue.
>
> regards,
>
> Gunnar
>
> --
> Gunnar R?nning - gunnar@polygnosis.com
> Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 04:36 Barry Lind <blind@xythos.com>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 46+ messages in thread
From: Barry Lind @ 2001-06-25 04:36 UTC (permalink / raw)
To: pgsql-patches@postgresql.org; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
Since this patch got applied before I got around to commenting on it, I
have submitted a new patch to address my issues with the original patch.
The problem with the patch as applied is that is always creates the
SimpleDateFormat objects in the constructor of the PreparedStatement
regardless of whether or not they will ever be used in the
PreparedStatement. I have reverted back to the old behavior that only
creates them if necessary in the setDate and setTimestamp methods.
I also removed the close() method. It's only purpose was to free these
two SimpleDateFormat objects. I think it is much better to leave these
two objects cached on the thread so that other PreparedStatements can
use them. (This was the intention of a patch I submitted back in
February where I was trying to remove as many object creations as
possible to improve performance. That patch as written needed to get
pulled because of the problem that SimpleDataFormat objects are not
thread safe. Peter then added the ThreadLocal code to try to solve the
performance problem, but introduced the memory leak that originated this
email thread.) I think the cost of at most two SimpleDateFormat objects
being cached on each thead is worth the benefits of less object creation
and subsequent garbage collection.
thanks,
--Barry
Bruce Momjian wrote:
> Patch applied. Thanks.
>
>
>>Here is a patch which inspired by Michael Stephens that should work
>>
>>Dave
>>
>>
>>-----Original Message-----
>>From: pgsql-jdbc-owner@postgresql.org
>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>Sent: June 22, 2001 10:14 AM
>>To: Rainer Mager
>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>
>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>|
>>
>>| Interesting. I wasn't aware of this. If question #2 is answered such
>>that
>>| thread safe isn't necessary, then this problem goes away pretty
>>easily. If
>>| thread safety is needed then this would have to be rewritten, I can
>>look
>>| into doing this if you like.
>>
>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>and
>>reference, 2 ed." from Addison Wesley ? This book contains a section for
>>
>>JDBC driver writers and explains this issue.
>>
>>regards,
>>
>> Gunnar
>>
>>--
>>Gunnar R?nning - gunnar@polygnosis.com
>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>
>>
>
> [ Attachment, skipping... ]
>
>
Attachments:
patch.txt (text/plain, 1.9K) download
*** ./interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java.orig Sun Jun 24 21:05:29 2001
--- ./interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java Sun Jun 24 21:13:15 2001
***************
*** 65,78 ****
this.sql = sql;
this.connection = connection;
- // might just as well create it here, so we don't take the hit later
-
- SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
-
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- tl_tsdf.set(df);
-
for (i = 0; i < sql.length(); ++i)
{
int c = sql.charAt(i);
--- 65,70 ----
***************
*** 95,111 ****
templateStrings[i] = (String)v.elementAt(i);
}
- /**
- * New in 7.1 - overides Statement.close() to dispose of a few local objects
- */
- public void close() throws SQLException
- {
- // free the ThreadLocal caches
- tl_df.set(null);
- tl_tsdf.set(null);
- super.close();
- }
-
/**
* A Prepared SQL query is executed and its ResultSet is returned
*
--- 87,92 ----
***************
*** 343,348 ****
--- 324,333 ----
public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
{
SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
+ if(df==null) {
+ df = new SimpleDateFormat("''yyyy-MM-dd''");
+ tl_df.set(df);
+ }
set(parameterIndex, df.format(x));
***************
*** 382,387 ****
--- 367,376 ----
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
{
SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
+ if(df==null) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ tl_tsdf.set(df);
+ }
df.setTimeZone(TimeZone.getTimeZone("GMT"));
// Use the shared StringBuffer
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 12:11 Dave Cramer <Dave@micro-automation.net>
parent: Barry Lind <blind@xythos.com>
1 sibling, 2 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-25 12:11 UTC (permalink / raw)
To: 'Barry Lind' <blind@xythos.com>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Barry,
My patch was attempting to maintain some sort of thread safety. I do not
think the if (df==null) test is thread-safe. It would need to be
synchronized.
However, as I have mentioned in a couple of previous posts; I'm not sure
thread-safety is worthwhile. The driver appears to be thread safe in
that multiple threads can each use different instances of connections,
and statements, and resultset's however I don't think it is thread safe
in the sense that multiple threads could use the same instance of the
above objects. The JDBC guide suggests that the driver s/b threadsafe in
this sense (multiple threads....same object). The guide suggests that
one thread may instigate the retrieval of a result set, and another
would display it.
Where this is leading is: What kind of thread safety are we trying to
achieve?
If it's only one instance per thread then, I would have to agree that
Barry's patch s/b applied.
P.S.
Is there a formal process within the postgres group for making these
kind of decisions.
If not I would like to suggest adopting the apache groups +1,-1 voting
approach.
-----Original Message-----
From: Barry Lind [mailto:blind@xythos.com]
Sent: June 25, 2001 12:37 AM
To: pgsql-patches@postgresql.org
Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
Subject: Re: [ADMIN] High memory usage [PATCH]
Since this patch got applied before I got around to commenting on it, I
have submitted a new patch to address my issues with the original patch.
The problem with the patch as applied is that is always creates the
SimpleDateFormat objects in the constructor of the PreparedStatement
regardless of whether or not they will ever be used in the
PreparedStatement. I have reverted back to the old behavior that only
creates them if necessary in the setDate and setTimestamp methods.
I also removed the close() method. It's only purpose was to free these
two SimpleDateFormat objects. I think it is much better to leave these
two objects cached on the thread so that other PreparedStatements can
use them. (This was the intention of a patch I submitted back in
February where I was trying to remove as many object creations as
possible to improve performance. That patch as written needed to get
pulled because of the problem that SimpleDataFormat objects are not
thread safe. Peter then added the ThreadLocal code to try to solve the
performance problem, but introduced the memory leak that originated this
email thread.) I think the cost of at most two SimpleDateFormat objects
being cached on each thead is worth the benefits of less object creation
and subsequent garbage collection.
thanks,
--Barry
Bruce Momjian wrote:
> Patch applied. Thanks.
>
>
>>Here is a patch which inspired by Michael Stephens that should work
>>
>>Dave
>>
>>
>>-----Original Message-----
>>From: pgsql-jdbc-owner@postgresql.org
>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>Sent: June 22, 2001 10:14 AM
>>To: Rainer Mager
>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>
>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>|
>>
>>| Interesting. I wasn't aware of this. If question #2 is answered such
>>that
>>| thread safe isn't necessary, then this problem goes away pretty
>>easily. If
>>| thread safety is needed then this would have to be rewritten, I can
>>look
>>| into doing this if you like.
>>
>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>and
>>reference, 2 ed." from Addison Wesley ? This book contains a section
for
>>
>>JDBC driver writers and explains this issue.
>>
>>regards,
>>
>> Gunnar
>>
>>--
>>Gunnar R?nning - gunnar@polygnosis.com
>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>
>>---------------------------(end of
broadcast)---------------------------
>>TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org
>>
>>
>
> [ Attachment, skipping... ]
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 14:59 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 1 reply; 46+ messages in thread
From: Bruce Momjian @ 2001-06-25 14:59 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Barry Lind' <blind@xythos.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Barry, let me back out Dave's change until we can all agree on it, OK?
It is easy to do.
> Barry,
>
> My patch was attempting to maintain some sort of thread safety. I do not
> think the if (df==null) test is thread-safe. It would need to be
> synchronized.
>
> However, as I have mentioned in a couple of previous posts; I'm not sure
> thread-safety is worthwhile. The driver appears to be thread safe in
> that multiple threads can each use different instances of connections,
> and statements, and resultset's however I don't think it is thread safe
> in the sense that multiple threads could use the same instance of the
> above objects. The JDBC guide suggests that the driver s/b threadsafe in
> this sense (multiple threads....same object). The guide suggests that
> one thread may instigate the retrieval of a result set, and another
> would display it.
>
>
> Where this is leading is: What kind of thread safety are we trying to
> achieve?
>
> If it's only one instance per thread then, I would have to agree that
> Barry's patch s/b applied.
>
> P.S.
>
> Is there a formal process within the postgres group for making these
> kind of decisions.
>
> If not I would like to suggest adopting the apache groups +1,-1 voting
> approach.
>
> -----Original Message-----
> From: Barry Lind [mailto:blind@xythos.com]
> Sent: June 25, 2001 12:37 AM
> To: pgsql-patches@postgresql.org
> Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
> Subject: Re: [ADMIN] High memory usage [PATCH]
>
> Since this patch got applied before I got around to commenting on it, I
> have submitted a new patch to address my issues with the original patch.
>
> The problem with the patch as applied is that is always creates the
> SimpleDateFormat objects in the constructor of the PreparedStatement
> regardless of whether or not they will ever be used in the
> PreparedStatement. I have reverted back to the old behavior that only
> creates them if necessary in the setDate and setTimestamp methods.
>
> I also removed the close() method. It's only purpose was to free these
> two SimpleDateFormat objects. I think it is much better to leave these
> two objects cached on the thread so that other PreparedStatements can
> use them. (This was the intention of a patch I submitted back in
> February where I was trying to remove as many object creations as
> possible to improve performance. That patch as written needed to get
> pulled because of the problem that SimpleDataFormat objects are not
> thread safe. Peter then added the ThreadLocal code to try to solve the
> performance problem, but introduced the memory leak that originated this
>
> email thread.) I think the cost of at most two SimpleDateFormat objects
>
> being cached on each thead is worth the benefits of less object creation
>
> and subsequent garbage collection.
>
> thanks,
> --Barry
>
>
> Bruce Momjian wrote:
>
> > Patch applied. Thanks.
> >
> >
> >>Here is a patch which inspired by Michael Stephens that should work
> >>
> >>Dave
> >>
> >>
> >>-----Original Message-----
> >>From: pgsql-jdbc-owner@postgresql.org
> >>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
> >>Sent: June 22, 2001 10:14 AM
> >>To: Rainer Mager
> >>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
> >>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
> >>
> >>* "Rainer Mager" <rmager@vgkk.com> wrote:
> >>|
> >>
> >>| Interesting. I wasn't aware of this. If question #2 is answered such
> >>that
> >>| thread safe isn't necessary, then this problem goes away pretty
> >>easily. If
> >>| thread safety is needed then this would have to be rewritten, I can
> >>look
> >>| into doing this if you like.
> >>
> >>Thread safety is required by the spec. Do you have "JDBC API tutorial
> >>and
> >>reference, 2 ed." from Addison Wesley ? This book contains a section
> for
> >>
> >>JDBC driver writers and explains this issue.
> >>
> >>regards,
> >>
> >> Gunnar
> >>
> >>--
> >>Gunnar R?nning - gunnar@polygnosis.com
> >>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
> >>
> >>---------------------------(end of
> broadcast)---------------------------
> >>TIP 1: subscribe and unsubscribe commands go to
> majordomo@postgresql.org
> >>
> >>
> >
> > [ Attachment, skipping... ]
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 15:39 Barry Lind <barry@xythos.com>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 3 replies; 46+ messages in thread
From: Barry Lind @ 2001-06-25 15:39 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Dave,
The patch I submitted is thread safe. The "if (df==null)" check is
dealing with a ThreadLocal variable. By definition a ThreadLocal
variable can't be used by any other thread since each thread has its own
copy. (Unless the code goes and hands the object off to some other
thread thus causing threading issues, which it doesn't in this case).
Thus I believe the patch I submitted is perfectly thread safe.
To your more general questions:
I think thread safety is very important for all of the JDBC objects.
There are no restrictions placed on what a user could do with these
objects. It is perfectly legal to create a Statement in one thread,
hand that statement off to two or more other threads to access. Now I
wouldn't recommend doing this, but the spec permits it.
As far as procedures and voting, I also believe that something needs to
be done for the JDBC code base. Since Peter has apparently disappeared
(I haven't seen a post from him in about two months, and the
jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
doesn't even have the 7.1 code yet) I think the core group needs to step
in and provide some direction for the JDBC code base. Whether that is
appointing someone new as the official/unofficial JDBC guru or adopting
some other process, I don't know. What I do know is that the JDBC code
base is suffering from lack of attention and direction.
Issues that I am concerned about in the JDBC code base are:
- get/setXXXStream methods are not really spec compliant
- the 'bytea' datatype (i.e. binary) isn't supported, and can't be
without backward compatibility problems because the get/setBytes methods
currently assume that binary means BLOB.
- performance/performance/performance - lots of work could/should be
done to improve performance. Some good work was started last year but
nothing came of it.
- updateable cursors - I beleive some work is being done here by
various parties on the list, but I have some serious concerns about
if/how such functionality can/should be supported.
thanks,
--Barry
Dave Cramer wrote:
> Barry,
>
> My patch was attempting to maintain some sort of thread safety. I do not
> think the if (df==null) test is thread-safe. It would need to be
> synchronized.
>
> However, as I have mentioned in a couple of previous posts; I'm not sure
> thread-safety is worthwhile. The driver appears to be thread safe in
> that multiple threads can each use different instances of connections,
> and statements, and resultset's however I don't think it is thread safe
> in the sense that multiple threads could use the same instance of the
> above objects. The JDBC guide suggests that the driver s/b threadsafe in
> this sense (multiple threads....same object). The guide suggests that
> one thread may instigate the retrieval of a result set, and another
> would display it.
>
>
> Where this is leading is: What kind of thread safety are we trying to
> achieve?
>
> If it's only one instance per thread then, I would have to agree that
> Barry's patch s/b applied.
>
> P.S.
>
> Is there a formal process within the postgres group for making these
> kind of decisions.
>
> If not I would like to suggest adopting the apache groups +1,-1 voting
> approach.
>
> -----Original Message-----
> From: Barry Lind [mailto:blind@xythos.com]
> Sent: June 25, 2001 12:37 AM
> To: pgsql-patches@postgresql.org
> Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
> Subject: Re: [ADMIN] High memory usage [PATCH]
>
> Since this patch got applied before I got around to commenting on it, I
> have submitted a new patch to address my issues with the original patch.
>
> The problem with the patch as applied is that is always creates the
> SimpleDateFormat objects in the constructor of the PreparedStatement
> regardless of whether or not they will ever be used in the
> PreparedStatement. I have reverted back to the old behavior that only
> creates them if necessary in the setDate and setTimestamp methods.
>
> I also removed the close() method. It's only purpose was to free these
> two SimpleDateFormat objects. I think it is much better to leave these
> two objects cached on the thread so that other PreparedStatements can
> use them. (This was the intention of a patch I submitted back in
> February where I was trying to remove as many object creations as
> possible to improve performance. That patch as written needed to get
> pulled because of the problem that SimpleDataFormat objects are not
> thread safe. Peter then added the ThreadLocal code to try to solve the
> performance problem, but introduced the memory leak that originated this
>
> email thread.) I think the cost of at most two SimpleDateFormat objects
>
> being cached on each thead is worth the benefits of less object creation
>
> and subsequent garbage collection.
>
> thanks,
> --Barry
>
>
> Bruce Momjian wrote:
>
>
>>Patch applied. Thanks.
>>
>>
>>
>>>Here is a patch which inspired by Michael Stephens that should work
>>>
>>>Dave
>>>
>>>
>>>-----Original Message-----
>>>From: pgsql-jdbc-owner@postgresql.org
>>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>Sent: June 22, 2001 10:14 AM
>>>To: Rainer Mager
>>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>
>>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>>|
>>>
>>>| Interesting. I wasn't aware of this. If question #2 is answered such
>>>that
>>>| thread safe isn't necessary, then this problem goes away pretty
>>>easily. If
>>>| thread safety is needed then this would have to be rewritten, I can
>>>look
>>>| into doing this if you like.
>>>
>>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>and
>>>reference, 2 ed." from Addison Wesley ? This book contains a section
>>>
> for
>
>>>JDBC driver writers and explains this issue.
>>>
>>>regards,
>>>
>>> Gunnar
>>>
>>>--
>>>Gunnar R?nning - gunnar@polygnosis.com
>>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>
>>>---------------------------(end of
>>>
> broadcast)---------------------------
>
>>>TIP 1: subscribe and unsubscribe commands go to
>>>
> majordomo@postgresql.org
>
>>>
>>[ Attachment, skipping... ]
>>
>>
>>
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 15:41 Barry Lind <barry@xythos.com>
parent: Barry Lind <blind@xythos.com>
1 sibling, 1 reply; 46+ messages in thread
From: Barry Lind @ 2001-06-25 15:41 UTC (permalink / raw)
To: pgsql-patches@postgresql.org; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Barry Lind wrote:
> Since this patch got applied before I got around to commenting on it, I
> have submitted a new patch to address my issues with the original patch.
>
> The problem with the patch as applied is that is always creates the
> SimpleDateFormat objects in the constructor of the PreparedStatement
> regardless of whether or not they will ever be used in the
> PreparedStatement. I have reverted back to the old behavior that only
> creates them if necessary in the setDate and setTimestamp methods.
>
> I also removed the close() method. It's only purpose was to free these
> two SimpleDateFormat objects. I think it is much better to leave these
> two objects cached on the thread so that other PreparedStatements can
> use them. (This was the intention of a patch I submitted back in
> February where I was trying to remove as many object creations as
> possible to improve performance. That patch as written needed to get
> pulled because of the problem that SimpleDataFormat objects are not
> thread safe. Peter then added the ThreadLocal code to try to solve the
> performance problem, but introduced the memory leak that originated this
> email thread.) I think the cost of at most two SimpleDateFormat objects
> being cached on each thead is worth the benefits of less object creation
> and subsequent garbage collection.
>
> thanks,
> --Barry
>
>
> Bruce Momjian wrote:
>
>> Patch applied. Thanks.
>>
>>
>>> Here is a patch which inspired by Michael Stephens that should work
>>>
>>> Dave
>>>
>>>
>>> -----Original Message-----
>>> From: pgsql-jdbc-owner@postgresql.org
>>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>> Sent: June 22, 2001 10:14 AM
>>> To: Rainer Mager
>>> Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>> Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>
>>> * "Rainer Mager" <rmager@vgkk.com> wrote:
>>> |
>>>
>>> | Interesting. I wasn't aware of this. If question #2 is answered such
>>> that
>>> | thread safe isn't necessary, then this problem goes away pretty
>>> easily. If
>>> | thread safety is needed then this would have to be rewritten, I can
>>> look
>>> | into doing this if you like.
>>>
>>> Thread safety is required by the spec. Do you have "JDBC API tutorial
>>> and reference, 2 ed." from Addison Wesley ? This book contains a
>>> section for
>>>
>>> JDBC driver writers and explains this issue.
>>>
>>> regards,
>>> Gunnar
>>>
>>> --
>>> Gunnar R?nning - gunnar@polygnosis.com
>>> Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>
>>> ---------------------------(end of broadcast)---------------------------
>>> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>>
>>>
>>
>> [ Attachment, skipping... ]
>>
>>
>
>
> ------------------------------------------------------------------------
>
> *** ./interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java.orig Sun Jun 24 21:05:29 2001
> --- ./interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java Sun Jun 24 21:13:15 2001
> ***************
> *** 65,78 ****
> this.sql = sql;
> this.connection = connection;
>
> - // might just as well create it here, so we don't take the hit later
> -
> - SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''");
> - tl_df.set(df);
> -
> - df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> - tl_tsdf.set(df);
> -
> for (i = 0; i < sql.length(); ++i)
> {
> int c = sql.charAt(i);
> --- 65,70 ----
> ***************
> *** 95,111 ****
> templateStrings[i] = (String)v.elementAt(i);
> }
>
> - /**
> - * New in 7.1 - overides Statement.close() to dispose of a few local objects
> - */
> - public void close() throws SQLException
> - {
> - // free the ThreadLocal caches
> - tl_df.set(null);
> - tl_tsdf.set(null);
> - super.close();
> - }
> -
> /**
> * A Prepared SQL query is executed and its ResultSet is returned
> *
> --- 87,92 ----
> ***************
> *** 343,348 ****
> --- 324,333 ----
> public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
> {
> SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
> + if(df==null) {
> + df = new SimpleDateFormat("''yyyy-MM-dd''");
> + tl_df.set(df);
> + }
>
> set(parameterIndex, df.format(x));
>
> ***************
> *** 382,387 ****
> --- 367,376 ----
> public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
> {
> SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
> + if(df==null) {
> + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> + tl_tsdf.set(df);
> + }
> df.setTimeZone(TimeZone.getTimeZone("GMT"));
>
> // Use the shared StringBuffer
>
> patch.txt
>
> Content-Type:
>
> text/plain
> Content-Encoding:
>
> 7bit
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 17:41 Barry Lind <barry@xythos.com>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 46+ messages in thread
From: Barry Lind @ 2001-06-25 17:41 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
Bruce,
I don't think you need to back out Dave's patch. It works fine as it
is. I just think it can be improved upon.
thanks,
--Barry
Bruce Momjian wrote:
> Barry, let me back out Dave's change until we can all agree on it, OK?
> It is easy to do.
>
>
>>Barry,
>>
>>My patch was attempting to maintain some sort of thread safety. I do not
>>think the if (df==null) test is thread-safe. It would need to be
>>synchronized.
>>
>>However, as I have mentioned in a couple of previous posts; I'm not sure
>>thread-safety is worthwhile. The driver appears to be thread safe in
>>that multiple threads can each use different instances of connections,
>>and statements, and resultset's however I don't think it is thread safe
>>in the sense that multiple threads could use the same instance of the
>>above objects. The JDBC guide suggests that the driver s/b threadsafe in
>>this sense (multiple threads....same object). The guide suggests that
>>one thread may instigate the retrieval of a result set, and another
>>would display it.
>>
>>
>>Where this is leading is: What kind of thread safety are we trying to
>>achieve?
>>
>>If it's only one instance per thread then, I would have to agree that
>>Barry's patch s/b applied.
>>
>>P.S.
>>
>>Is there a formal process within the postgres group for making these
>>kind of decisions.
>>
>>If not I would like to suggest adopting the apache groups +1,-1 voting
>>approach.
>>
>>-----Original Message-----
>>From: Barry Lind [mailto:blind@xythos.com]
>>Sent: June 25, 2001 12:37 AM
>>To: pgsql-patches@postgresql.org
>>Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
>>Subject: Re: [ADMIN] High memory usage [PATCH]
>>
>>Since this patch got applied before I got around to commenting on it, I
>>have submitted a new patch to address my issues with the original patch.
>>
>>The problem with the patch as applied is that is always creates the
>>SimpleDateFormat objects in the constructor of the PreparedStatement
>>regardless of whether or not they will ever be used in the
>>PreparedStatement. I have reverted back to the old behavior that only
>>creates them if necessary in the setDate and setTimestamp methods.
>>
>>I also removed the close() method. It's only purpose was to free these
>>two SimpleDateFormat objects. I think it is much better to leave these
>>two objects cached on the thread so that other PreparedStatements can
>>use them. (This was the intention of a patch I submitted back in
>>February where I was trying to remove as many object creations as
>>possible to improve performance. That patch as written needed to get
>>pulled because of the problem that SimpleDataFormat objects are not
>>thread safe. Peter then added the ThreadLocal code to try to solve the
>>performance problem, but introduced the memory leak that originated this
>>
>>email thread.) I think the cost of at most two SimpleDateFormat objects
>>
>>being cached on each thead is worth the benefits of less object creation
>>
>>and subsequent garbage collection.
>>
>>thanks,
>>--Barry
>>
>>
>>Bruce Momjian wrote:
>>
>>
>>>Patch applied. Thanks.
>>>
>>>
>>>
>>>>Here is a patch which inspired by Michael Stephens that should work
>>>>
>>>>Dave
>>>>
>>>>
>>>>-----Original Message-----
>>>>From: pgsql-jdbc-owner@postgresql.org
>>>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>>Sent: June 22, 2001 10:14 AM
>>>>To: Rainer Mager
>>>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>>
>>>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>>>|
>>>>
>>>>| Interesting. I wasn't aware of this. If question #2 is answered such
>>>>that
>>>>| thread safe isn't necessary, then this problem goes away pretty
>>>>easily. If
>>>>| thread safety is needed then this would have to be rewritten, I can
>>>>look
>>>>| into doing this if you like.
>>>>
>>>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>>and
>>>>reference, 2 ed." from Addison Wesley ? This book contains a section
>>>>
>>for
>>
>>>>JDBC driver writers and explains this issue.
>>>>
>>>>regards,
>>>>
>>>> Gunnar
>>>>
>>>>--
>>>>Gunnar R?nning - gunnar@polygnosis.com
>>>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>>
>>>>---------------------------(end of
>>>>
>>broadcast)---------------------------
>>
>>>>TIP 1: subscribe and unsubscribe commands go to
>>>>
>>majordomo@postgresql.org
>>
>>>>
>>>[ Attachment, skipping... ]
>>>
>>>
>>>
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>
>>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 18:49 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Barry Lind <barry@xythos.com>
0 siblings, 1 reply; 46+ messages in thread
From: Bruce Momjian @ 2001-06-25 18:49 UTC (permalink / raw)
To: Barry Lind <barry@xythos.com>; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
> Bruce,
>
> I don't think you need to back out Dave's patch. It works fine as it
> is. I just think it can be improved upon.
OK, you just let me know.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 19:53 Dave Cramer <Dave@micro-automation.net>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-25 19:53 UTC (permalink / raw)
To: 'Bruce Momjian' <pgman@candle.pha.pa.us>; 'Barry Lind' <barry@xythos.com>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Bruce, Barry,
How about checking for the existence of the date object in the
constructor? This would mean that it would only be created once per
thread.
Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Bruce Momjian
Sent: June 25, 2001 2:50 PM
To: Barry Lind
Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
Subject: Re: [JDBC] RE: [ADMIN] High memory usage [PATCH]
> Bruce,
>
> I don't think you need to back out Dave's patch. It works fine as it
> is. I just think it can be improved upon.
OK, you just let me know.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania
19026
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 20:03 Barry Lind <barry@xythos.com>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 1 reply; 46+ messages in thread
From: Barry Lind @ 2001-06-25 20:03 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Bruce Momjian' <pgman@candle.pha.pa.us>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
I like that idea. Best of both worlds. I will redo my patch to do that
and resubmit.
thanks,
--Barry
Dave Cramer wrote:
> Bruce, Barry,
>
> How about checking for the existence of the date object in the
> constructor? This would mean that it would only be created once per
> thread.
>
> Dave
>
>
> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Bruce Momjian
> Sent: June 25, 2001 2:50 PM
> To: Barry Lind
> Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
> Subject: Re: [JDBC] RE: [ADMIN] High memory usage [PATCH]
>
>
>>Bruce,
>>
>>I don't think you need to back out Dave's patch. It works fine as it
>>is. I just think it can be improved upon.
>>
>
> OK, you just let me know.
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 21:43 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Barry Lind <barry@xythos.com>
0 siblings, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-25 21:43 UTC (permalink / raw)
To: Barry Lind <barry@xythos.com>; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
Thanks.
>
> I like that idea. Best of both worlds. I will redo my patch to do that
> and resubmit.
>
> thanks,
> --Barry
>
>
> Dave Cramer wrote:
>
> > Bruce, Barry,
> >
> > How about checking for the existence of the date object in the
> > constructor? This would mean that it would only be created once per
> > thread.
> >
> > Dave
> >
> >
> > -----Original Message-----
> > From: pgsql-jdbc-owner@postgresql.org
> > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Bruce Momjian
> > Sent: June 25, 2001 2:50 PM
> > To: Barry Lind
> > Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
> > Subject: Re: [JDBC] RE: [ADMIN] High memory usage [PATCH]
> >
> >
> >>Bruce,
> >>
> >>I don't think you need to back out Dave's patch. It works fine as it
> >>is. I just think it can be improved upon.
> >>
> >
> > OK, you just let me know.
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 22:44 Barry Lind <barry@xythos.com>
parent: Barry Lind <barry@xythos.com>
2 siblings, 1 reply; 46+ messages in thread
From: Barry Lind @ 2001-06-25 22:44 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Dave,
The patch I submitted is thread safe. The "if (df==null)" check is
dealing with a ThreadLocal variable. By definition a ThreadLocal
variable can't be used by any other thread since each thread has its own
copy. (Unless the code goes and hands the object off to some other
thread thus causing threading issues, which it doesn't in this case).
Thus I believe the patch I submitted is perfectly thread safe.
To your more general questions:
I think thread safety is very important for all of the JDBC objects.
There are no restrictions placed on what a user could do with these
objects. It is perfectly legal to create a Statement in one thread,
hand that statement off to two or more other threads to access. Now I
wouldn't recommend doing this, but the spec permits it.
As far as procedures and voting, I also believe that something needs to
be done for the JDBC code base. Since Peter has apparently disappeared
(I haven't seen a post from him in about two months, and the
jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
doesn't even have the 7.1 code yet) I think the core group needs to step
in and provide some direction for the JDBC code base. Whether that is
appointing someone new as the official/unofficial JDBC guru or adopting
some other process, I don't know. What I do know is that the JDBC code
base is suffering from lack of attention and direction.
Issues that I am concerned about in the JDBC code base are:
- get/setXXXStream methods are not really spec compliant
- the 'bytea' datatype (i.e. binary) isn't supported, and can't be
without backward compatibility problems because the get/setBytes methods
currently assume that binary means BLOB.
- performance/performance/performance - lots of work could/should be
done to improve performance. Some good work was started last year but
nothing came of it.
- updateable cursors - I beleive some work is being done here by
various parties on the list, but I have some serious concerns about
if/how such functionality can/should be supported.
thanks,
--Barry
> Dave Cramer wrote:
>
>> Barry,
>>
>> My patch was attempting to maintain some sort of thread safety. I do not
>> think the if (df==null) test is thread-safe. It would need to be
>> synchronized.
>>
>> However, as I have mentioned in a couple of previous posts; I'm not sure
>> thread-safety is worthwhile. The driver appears to be thread safe in
>> that multiple threads can each use different instances of connections,
>> and statements, and resultset's however I don't think it is thread safe
>> in the sense that multiple threads could use the same instance of the
>> above objects. The JDBC guide suggests that the driver s/b threadsafe in
>> this sense (multiple threads....same object). The guide suggests that
>> one thread may instigate the retrieval of a result set, and another
>> would display it.
>>
>>
>> Where this is leading is: What kind of thread safety are we trying to
>> achieve?
>> If it's only one instance per thread then, I would have to agree that
>> Barry's patch s/b applied.
>>
>> P.S.
>> Is there a formal process within the postgres group for making these
>> kind of decisions.
>> If not I would like to suggest adopting the apache groups +1,-1 voting
>> approach.
>>
>> -----Original Message-----
>> From: Barry Lind [mailto:blind@xythos.com] Sent: June 25, 2001 12:37 AM
>> To: pgsql-patches@postgresql.org
>> Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
>> Subject: Re: [ADMIN] High memory usage [PATCH]
>>
>> Since this patch got applied before I got around to commenting on it,
>> I have submitted a new patch to address my issues with the original
>> patch.
>>
>> The problem with the patch as applied is that is always creates the
>> SimpleDateFormat objects in the constructor of the PreparedStatement
>> regardless of whether or not they will ever be used in the
>> PreparedStatement. I have reverted back to the old behavior that only
>> creates them if necessary in the setDate and setTimestamp methods.
>>
>> I also removed the close() method. It's only purpose was to free
>> these two SimpleDateFormat objects. I think it is much better to
>> leave these two objects cached on the thread so that other
>> PreparedStatements can use them. (This was the intention of a patch I
>> submitted back in February where I was trying to remove as many object
>> creations as possible to improve performance. That patch as written
>> needed to get pulled because of the problem that SimpleDataFormat
>> objects are not thread safe. Peter then added the ThreadLocal code to
>> try to solve the performance problem, but introduced the memory leak
>> that originated this
>>
>> email thread.) I think the cost of at most two SimpleDateFormat objects
>>
>> being cached on each thead is worth the benefits of less object creation
>>
>> and subsequent garbage collection.
>>
>> thanks,
>> --Barry
>>
>>
>> Bruce Momjian wrote:
>>
>>
>>> Patch applied. Thanks.
>>>
>>>
>>>
>>>> Here is a patch which inspired by Michael Stephens that should work
>>>>
>>>> Dave
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: pgsql-jdbc-owner@postgresql.org
>>>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>> Sent: June 22, 2001 10:14 AM
>>>> To: Rainer Mager
>>>> Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>> Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>>
>>>> * "Rainer Mager" <rmager@vgkk.com> wrote:
>>>> |
>>>>
>>>> | Interesting. I wasn't aware of this. If question #2 is answered such
>>>> that
>>>> | thread safe isn't necessary, then this problem goes away pretty
>>>> easily. If
>>>> | thread safety is needed then this would have to be rewritten, I can
>>>> look
>>>> | into doing this if you like.
>>>>
>>>> Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>> and reference, 2 ed." from Addison Wesley ? This book contains a
>>>> section
>>>>
>> for
>>
>>>> JDBC driver writers and explains this issue.
>>>>
>>>> regards,
>>>> Gunnar
>>>>
>>>> --
>>>> Gunnar R?nning - gunnar@polygnosis.com
>>>> Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>>
>>>> ---------------------------(end of
>>>>
>> broadcast)---------------------------
>>
>>>> TIP 1: subscribe and unsubscribe commands go to
>>>>
>> majordomo@postgresql.org
>>
>>>>
>>> [ Attachment, skipping... ]
>>>
>>>
>>>
>>
>>
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-25 22:46 Barry Lind <barry@xythos.com>
parent: Barry Lind <barry@xythos.com>
0 siblings, 1 reply; 46+ messages in thread
From: Barry Lind @ 2001-06-25 22:46 UTC (permalink / raw)
To: pgsql-patches@postgresql.org; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
resending since I sent it from the wrong email address last time.
Since this patch got applied before I got around to commenting on it,
I have submitted a new patch to address my issues with the original
patch.
The problem with the patch as applied is that is always creates the
SimpleDateFormat objects in the constructor of the PreparedStatement
regardless of whether or not they will ever be used in the
PreparedStatement. I have reverted back to the old behavior that only
creates them if necessary in the setDate and setTimestamp methods.
I also removed the close() method. It's only purpose was to free
these two SimpleDateFormat objects. I think it is much better to
leave these two objects cached on the thread so that other
PreparedStatements can use them. (This was the intention of a patch I
submitted back in February where I was trying to remove as many object
creations as possible to improve performance. That patch as written
needed to get pulled because of the problem that SimpleDataFormat
objects are not thread safe. Peter then added the ThreadLocal code to
try to solve the performance problem, but introduced the memory leak
that originated this email thread.) I think the cost of at most two
SimpleDateFormat objects being cached on each thead is worth the
benefits of less object creation and subsequent garbage collection.
thanks,
--Barry
>> Bruce Momjian wrote:
>>
>>> Patch applied. Thanks.
>>>
>>>
>>>> Here is a patch which inspired by Michael Stephens that should work
>>>>
>>>> Dave
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: pgsql-jdbc-owner@postgresql.org
>>>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>> Sent: June 22, 2001 10:14 AM
>>>> To: Rainer Mager
>>>> Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>> Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>>
>>>> * "Rainer Mager" <rmager@vgkk.com> wrote:
>>>> |
>>>>
>>>> | Interesting. I wasn't aware of this. If question #2 is answered such
>>>> that
>>>> | thread safe isn't necessary, then this problem goes away pretty
>>>> easily. If
>>>> | thread safety is needed then this would have to be rewritten, I can
>>>> look
>>>> | into doing this if you like.
>>>>
>>>> Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>> and reference, 2 ed." from Addison Wesley ? This book contains a
>>>> section for
>>>>
>>>> JDBC driver writers and explains this issue.
>>>>
>>>> regards,
>>>> Gunnar
>>>>
>>>> --
>>>> Gunnar R?nning - gunnar@polygnosis.com
>>>> Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>>
>>>> ---------------------------(end of
>>>> broadcast)---------------------------
>>>> TIP 1: subscribe and unsubscribe commands go to
>>>> majordomo@postgresql.org
>>>>
>>>>
>>>
>>> [ Attachment, skipping... ]
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> ***
>> ./interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java.orig
>> Sun Jun 24 21:05:29 2001
>> --- ./interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
>> Sun Jun 24 21:13:15 2001
>> ***************
>> *** 65,78 ****
>> this.sql = sql;
>> this.connection = connection;
>>
>> - // might just as well create it here, so we don't take the
>> hit later
>> - - SimpleDateFormat df = new
>> SimpleDateFormat("''yyyy-MM-dd''");
>> - tl_df.set(df);
>> -
>> - df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
>> - tl_tsdf.set(df);
>> - for (i = 0; i < sql.length(); ++i)
>> {
>> int c = sql.charAt(i);
>> --- 65,70 ----
>> ***************
>> *** 95,111 ****
>> templateStrings[i] = (String)v.elementAt(i);
>> }
>> - /**
>> - * New in 7.1 - overides Statement.close() to dispose of a
>> few local objects
>> - */
>> - public void close() throws SQLException
>> - {
>> - // free the ThreadLocal caches
>> - tl_df.set(null);
>> - tl_tsdf.set(null);
>> - super.close();
>> - }
>> - /**
>> * A Prepared SQL query is executed and its ResultSet is returned
>> *
>> --- 87,92 ----
>> ***************
>> *** 343,348 ****
>> --- 324,333 ----
>> public void setDate(int parameterIndex, java.sql.Date x) throws
>> SQLException
>> {
>> SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
>> + if(df==null) {
>> + df = new SimpleDateFormat("''yyyy-MM-dd''");
>> + tl_df.set(df);
>> + }
>> set(parameterIndex, df.format(x));
>> ***************
>> *** 382,387 ****
>> --- 367,376 ----
>> public void setTimestamp(int parameterIndex, Timestamp x) throws
>> SQLException
>> {
>> SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
>> + if(df==null) {
>> + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
>> + tl_tsdf.set(df);
>> + }
>> df.setTimeZone(TimeZone.getTimeZone("GMT"));
>> // Use the shared StringBuffer
>>
>> patch.txt
>>
>> Content-Type:
>>
>> text/plain
>> Content-Encoding:
>>
>> 7bit
>>
>>
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 01:04 Dave Cramer <Dave@micro-automation.net>
parent: Barry Lind <barry@xythos.com>
2 siblings, 4 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-26 01:04 UTC (permalink / raw)
To: 'Barry Lind' <barry@xythos.com>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Barry,
My understanding of the problem is as follows:
The if (anyvar == null) check is flawed in an SMP environment; according
to the spec anyvar can be in the process of being created the jvm could
set anyvar to point to the memory it is going to assign it to but not
complete the creation of the object. You end up with a non-null, but
invalid anyvar. This is the crux of the double locking flaw. While I
hope most compiler writers would be smarter than that, apparently it is
possible according to the spec.
Well if we make the driver completely thread-safe we are going to take a
real performance hit. Personally I would prefer to code assuming it is
not completely thread-safe and have a lightweight driver.
I am willing to take on some of the work for the driver, but I think the
process s/b a group process. I have learned a lot in this particular
thread.
As I already mentioned I would like to see a voting procedure like the
apache group.
Regarding the catch-22 with Blob, etc. I think we need to make a harsh
decision here. Either break the existing code, or create another driver
codebase. If we don't do something we will be doomed to non-compliance.
This will hurt the driver in the not too distant future. There are a lot
of tools out there which the driver needs to be compatible with.
I had a look at the updateable cursors and it looks possible. Do you
know who is working on it?
Dave
-----Original Message-----
From: Barry Lind [mailto:barry@xythos.com]
Sent: June 25, 2001 11:39 AM
To: Dave@micro-automation.net
Cc: 'PostgreSQL jdbc list'
Subject: Re: [ADMIN] High memory usage [PATCH]
Dave,
The patch I submitted is thread safe. The "if (df==null)" check is
dealing with a ThreadLocal variable. By definition a ThreadLocal
variable can't be used by any other thread since each thread has its own
copy. (Unless the code goes and hands the object off to some other
thread thus causing threading issues, which it doesn't in this case).
Thus I believe the patch I submitted is perfectly thread safe.
To your more general questions:
I think thread safety is very important for all of the JDBC objects.
There are no restrictions placed on what a user could do with these
objects. It is perfectly legal to create a Statement in one thread,
hand that statement off to two or more other threads to access. Now I
wouldn't recommend doing this, but the spec permits it.
As far as procedures and voting, I also believe that something needs to
be done for the JDBC code base. Since Peter has apparently disappeared
(I haven't seen a post from him in about two months, and the
jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
doesn't even have the 7.1 code yet) I think the core group needs to step
in and provide some direction for the JDBC code base. Whether that is
appointing someone new as the official/unofficial JDBC guru or adopting
some other process, I don't know. What I do know is that the JDBC code
base is suffering from lack of attention and direction.
Issues that I am concerned about in the JDBC code base are:
- get/setXXXStream methods are not really spec compliant
- the 'bytea' datatype (i.e. binary) isn't supported, and can't be
without backward compatibility problems because the get/setBytes methods
currently assume that binary means BLOB.
- performance/performance/performance - lots of work could/should be
done to improve performance. Some good work was started last year but
nothing came of it.
- updateable cursors - I beleive some work is being done here by
various parties on the list, but I have some serious concerns about
if/how such functionality can/should be supported.
thanks,
--Barry
Dave Cramer wrote:
> Barry,
>
> My patch was attempting to maintain some sort of thread safety. I do
not
> think the if (df==null) test is thread-safe. It would need to be
> synchronized.
>
> However, as I have mentioned in a couple of previous posts; I'm not
sure
> thread-safety is worthwhile. The driver appears to be thread safe in
> that multiple threads can each use different instances of connections,
> and statements, and resultset's however I don't think it is thread
safe
> in the sense that multiple threads could use the same instance of the
> above objects. The JDBC guide suggests that the driver s/b threadsafe
in
> this sense (multiple threads....same object). The guide suggests that
> one thread may instigate the retrieval of a result set, and another
> would display it.
>
>
> Where this is leading is: What kind of thread safety are we trying to
> achieve?
>
> If it's only one instance per thread then, I would have to agree that
> Barry's patch s/b applied.
>
> P.S.
>
> Is there a formal process within the postgres group for making these
> kind of decisions.
>
> If not I would like to suggest adopting the apache groups +1,-1 voting
> approach.
>
> -----Original Message-----
> From: Barry Lind [mailto:blind@xythos.com]
> Sent: June 25, 2001 12:37 AM
> To: pgsql-patches@postgresql.org
> Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
> Subject: Re: [ADMIN] High memory usage [PATCH]
>
> Since this patch got applied before I got around to commenting on it,
I
> have submitted a new patch to address my issues with the original
patch.
>
> The problem with the patch as applied is that is always creates the
> SimpleDateFormat objects in the constructor of the PreparedStatement
> regardless of whether or not they will ever be used in the
> PreparedStatement. I have reverted back to the old behavior that only
> creates them if necessary in the setDate and setTimestamp methods.
>
> I also removed the close() method. It's only purpose was to free
these
> two SimpleDateFormat objects. I think it is much better to leave
these
> two objects cached on the thread so that other PreparedStatements can
> use them. (This was the intention of a patch I submitted back in
> February where I was trying to remove as many object creations as
> possible to improve performance. That patch as written needed to get
> pulled because of the problem that SimpleDataFormat objects are not
> thread safe. Peter then added the ThreadLocal code to try to solve
the
> performance problem, but introduced the memory leak that originated
this
>
> email thread.) I think the cost of at most two SimpleDateFormat
objects
>
> being cached on each thead is worth the benefits of less object
creation
>
> and subsequent garbage collection.
>
> thanks,
> --Barry
>
>
> Bruce Momjian wrote:
>
>
>>Patch applied. Thanks.
>>
>>
>>
>>>Here is a patch which inspired by Michael Stephens that should work
>>>
>>>Dave
>>>
>>>
>>>-----Original Message-----
>>>From: pgsql-jdbc-owner@postgresql.org
>>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>Sent: June 22, 2001 10:14 AM
>>>To: Rainer Mager
>>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>
>>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>>|
>>>
>>>| Interesting. I wasn't aware of this. If question #2 is answered
such
>>>that
>>>| thread safe isn't necessary, then this problem goes away pretty
>>>easily. If
>>>| thread safety is needed then this would have to be rewritten, I can
>>>look
>>>| into doing this if you like.
>>>
>>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>and
>>>reference, 2 ed." from Addison Wesley ? This book contains a section
>>>
> for
>
>>>JDBC driver writers and explains this issue.
>>>
>>>regards,
>>>
>>> Gunnar
>>>
>>>--
>>>Gunnar R?nning - gunnar@polygnosis.com
>>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>
>>>---------------------------(end of
>>>
> broadcast)---------------------------
>
>>>TIP 1: subscribe and unsubscribe commands go to
>>>
> majordomo@postgresql.org
>
>>>
>>[ Attachment, skipping... ]
>>
>>
>>
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 01:25 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Dave Cramer <Dave@micro-automation.net>
3 siblings, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-26 01:25 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Barry Lind' <barry@xythos.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
> I am willing to take on some of the work for the driver, but I
> think the process s/b a group process. I have learned a lot in
> this particular thread. As I already mentioned I would like to
> see a voting procedure like the apache group.
I am not keen on a hard-wired voting process because it makes winners
and losers. I vote only as a last resort. I usually give patches two
days and if there is no comment and it looks good, I apply it. If
anyone objects before or after it is applied, it gets reversed out and
we discuss it.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 01:27 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Barry Lind <barry@xythos.com>
2 siblings, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-26 01:27 UTC (permalink / raw)
To: Barry Lind <barry@xythos.com>; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
> As far as procedures and voting, I also believe that something needs to
> be done for the JDBC code base. Since Peter has apparently disappeared
> (I haven't seen a post from him in about two months, and the
> jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
> doesn't even have the 7.1 code yet) I think the core group needs to step
> in and provide some direction for the JDBC code base. Whether that is
> appointing someone new as the official/unofficial JDBC guru or adopting
> some other process, I don't know. What I do know is that the JDBC code
> base is suffering from lack of attention and direction.
See my earlier post. We don't have official maintainers of the main
code and I don't see a need for one in the interfaces. We can discuss
issues just like we are doing now. I most cases groups get better
results and single maintainers.
You guys are the official maintainers now. :-)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 01:32 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Barry Lind <barry@xythos.com>
0 siblings, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-26 01:32 UTC (permalink / raw)
To: Barry Lind <barry@xythos.com>; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
> As far as procedures and voting, I also believe that something needs to
> be done for the JDBC code base. Since Peter has apparently disappeared
> (I haven't seen a post from him in about two months, and the
> jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
> doesn't even have the 7.1 code yet) I think the core group needs to step
> in and provide some direction for the JDBC code base. Whether that is
> appointing someone new as the official/unofficial JDBC guru or adopting
> some other process, I don't know. What I do know is that the JDBC code
> base is suffering from lack of attention and direction.
Let me add I have been concerned about the jdbc interface for the past
year. With you people involved, I am no longer concerned.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [PATCHES] Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 01:44 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Barry Lind <barry@xythos.com>
0 siblings, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-26 01:44 UTC (permalink / raw)
To: Barry Lind <barry@xythos.com>; +Cc: pgsql-patches@postgresql.org, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
> resending since I sent it from the wrong email address last time.
>
>
>
> Since this patch got applied before I got around to commenting on it,
>
> I have submitted a new patch to address my issues with the original
> patch.
>
> The problem with the patch as applied is that is always creates the
> SimpleDateFormat objects in the constructor of the PreparedStatement
> regardless of whether or not they will ever be used in the
> PreparedStatement. I have reverted back to the old behavior that only
> creates them if necessary in the setDate and setTimestamp methods.
Barry, did I miss the actual patch you sent?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 13:24 Gunnar Rønning <gunnar@polygnosis.com>
parent: Dave Cramer <Dave@micro-automation.net>
1 sibling, 1 reply; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-26 13:24 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Bruce Momjian' <pgman@candle.pha.pa.us>; 'Barry Lind' <barry@xythos.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
* "Dave Cramer" <Dave@micro-automation.net> wrote:
|
| Bruce, Barry,
|
| How about checking for the existence of the date object in the
| constructor? This would mean that it would only be created once per
| thread.
|
I only briefly reviewd the code in PreparedStatement yeaterday with respect
to the usage of the SimpleDateFormat, my comments :
- Why the ThreadLocal usage, and not just syncronize on the same
SimpleDateFormat ?
- It seems to that the SimpleDateFormat is never modified after creation.
Wouldn't this mean that we actually could assign the SimpleDateFormat
object to a static member, so we only had to create the object once.
Or is concurrent usage of SimpleDateFormat.format() unsafe ?
I would prefer the latter if safe, as we would get less object creation and
synchronization.
regards,
Gunnar
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 13:37 Michael Stephenson <mstephenson@tirin.openworld.co.uk>
parent: Gunnar Rønning <gunnar@polygnosis.com>
0 siblings, 1 reply; 46+ messages in thread
From: Michael Stephenson @ 2001-06-26 13:37 UTC (permalink / raw)
To: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
> I only briefly reviewd the code in PreparedStatement yeaterday with respect
> to the usage of the SimpleDateFormat, my comments :
>
> - Why the ThreadLocal usage, and not just syncronize on the same
> SimpleDateFormat ?
This won't scale. :o)
> - It seems to that the SimpleDateFormat is never modified after creation.
> Wouldn't this mean that we actually could assign the SimpleDateFormat
> object to a static member, so we only had to create the object once.
> Or is concurrent usage of SimpleDateFormat.format() unsafe ?
SimpleDateFormat.format() and SimpleDateFormat.parse() are not threadsafe,
I believe the relevant 'bug' is 4228335.
> I would prefer the latter if safe, as we would get less object creation and
> synchronization.
The latter is what we used to have until it became clear that it wasn't
threadsafe.
I think the ThreadLocal solution is the best one available in the
circumstances.
Michael xxx
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 13:47 Gunnar Rønning <gunnar@polygnosis.com>
parent: Michael Stephenson <mstephenson@tirin.openworld.co.uk>
0 siblings, 1 reply; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-26 13:47 UTC (permalink / raw)
To: Michael Stephenson <mstephenson@tirin.openworld.co.uk>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
* Michael Stephenson <mstephenson@tirin.openworld.co.uk> wrote:
|
| > - Why the ThreadLocal usage, and not just syncronize on the same
| > SimpleDateFormat ?
|
| This won't scale. :o)
|
Why ? Performance measurements I have seen and also done before has indicated
that synchronization is faster than the usage of ThreadLocal.
cheers,
Gunnar
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 15:21 Michael Stephenson <mstephenson@tirin.openworld.co.uk>
parent: Gunnar Rønning <gunnar@polygnosis.com>
0 siblings, 2 replies; 46+ messages in thread
From: Michael Stephenson @ 2001-06-26 15:21 UTC (permalink / raw)
To: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>; Gunnar Rønning <gunnar@polygnosis.com>
> | This won't scale. :o)
>
> Why ? Performance measurements I have seen and also done before has indicated
> that synchronization is faster than the usage of ThreadLocal.
I've just ran a couple of hugely simplified test (basically starting a
couple of thousand threads doing sdf.parse() with either synchronization
or ThreadLocals a couple of times).
With hot spot VM's (I used Sun JDK 1.3.0_02) the difference appears to be
pretty much non existant either way.
With non hot spot VM's (I used Sun JDK 1.2.2) it seems to have a clearer
pattern, the more threads you have the better the ThreadLocal method
performs, and which performs best depends on how many times each Thread
does the format operation (ie how often setDate is called).
For instance with 1000 threads, if they call setDate less than 5 times
the synchronization method seems to be quickest, 5 or more then the
ThreadLocal method performs better.
By the time you have 3000 threads, it only needs to be called 3 times
before the ThreadLocal method becomes quicker. By 5000 threads, if it's
called even twice per thread the syncronization method is 25% slower.
This is fairly inconclusive either way, because clearly different people
use this code in different ways, but I think backs up waht I said about
ThreadLocal's being more scalable, even if they are less efficient in
smaller cases.
I personally would advocate applying a patch similar to below to the
current cvs source.
Michael xxx
inline patch 1: PreparedStatement.java (+18/-23 lines) download inline-1.patch
--- PreparedStatement.java.orig Tue Jun 26 16:11:16 2001
+++ PreparedStatement.java Tue Jun 26 16:16:26 2001
@@ -44,6 +44,9 @@
private static ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
private static ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
+ private SimpleDateFormat sdSdf; // setDate SimpleDateFormat
+ private SimpleDateFormat stSdf; // setTimeStamp SimpleDateFormat
+
/**
* Constructor for the PreparedStatement class.
* Split the SQL statement into segments - separated by the arguments.
@@ -65,13 +68,18 @@
this.sql = sql;
this.connection = connection;
- // might just as well create it here, so we don't take the hit later
- SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
-
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- tl_tsdf.set(df);
+ // set up our SimpleDateFormats
+ sdSdf = (SimpleDateFormat)tl_df.get();
+ if (sdSdf == null) {
+ sdSdf = new SimpleDateFormat("''yyyy-MM-dd''");
+ tl_df.set(sdSdf);
+ }
+ stSdf = (SimpleDateFormat)tl_tsdf.get();
+ if (stSdf == null) {
+ stSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ tl_tsdf.set(df);
+ }
for (i = 0; i < sql.length(); ++i)
{
@@ -95,17 +103,6 @@
templateStrings[i] = (String)v.elementAt(i);
}
- /**
- * New in 7.1 - overides Statement.close() to dispose of a few local objects
- */
- public void close() throws SQLException
- {
- // free the ThreadLocal caches
- tl_df.set(null);
- tl_tsdf.set(null);
- super.close();
- }
-
/**
* A Prepared SQL query is executed and its ResultSet is returned
*
@@ -342,9 +339,7 @@
*/
public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
-
- set(parameterIndex, df.format(x));
+ set(parameterIndex, sdSdf.format(x));
// The above is how the date should be handled.
//
@@ -381,13 +376,13 @@
*/
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
- df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ stSdf.setTimeZone(TimeZone.getTimeZone("GMT"));
// Use the shared StringBuffer
synchronized(sbuf) {
sbuf.setLength(0);
- sbuf.append("'").append(df.format(x)).append('.').append(x.getNanos()/10000000).append("+00'");
+ sbuf.append("'").append(stSdf.format(x)).append('.')
+ .append(x.getNanos()/10000000).append("+00'");
set(parameterIndex, sbuf.toString());
}
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 16:21 Dave Cramer <Dave@micro-automation.net>
parent: Michael Stephenson <mstephenson@tirin.openworld.co.uk>
1 sibling, 0 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-26 16:21 UTC (permalink / raw)
To: 'Michael Stephenson' <mstephenson@tirin.openworld.co.uk>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Michael,
Barry pointed out that it isn't necessary for the constructor to be
called from the same thread that is accessing the SimpleDateFormat
objects. I think this requires the test to be done when the objects are
being accessed?
Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Michael Stephenson
Sent: June 26, 2001 11:21 AM
To: 'PostgreSQL jdbc list'; Gunnar Rønning
Subject: Re: [JDBC] Re: RE: [ADMIN] High memory usage [PATCH]
> | This won't scale. :o)
>
> Why ? Performance measurements I have seen and also done before has
indicated
> that synchronization is faster than the usage of ThreadLocal.
I've just ran a couple of hugely simplified test (basically starting a
couple of thousand threads doing sdf.parse() with either synchronization
or ThreadLocals a couple of times).
With hot spot VM's (I used Sun JDK 1.3.0_02) the difference appears to
be
pretty much non existant either way.
With non hot spot VM's (I used Sun JDK 1.2.2) it seems to have a clearer
pattern, the more threads you have the better the ThreadLocal method
performs, and which performs best depends on how many times each Thread
does the format operation (ie how often setDate is called).
For instance with 1000 threads, if they call setDate less than 5 times
the synchronization method seems to be quickest, 5 or more then the
ThreadLocal method performs better.
By the time you have 3000 threads, it only needs to be called 3 times
before the ThreadLocal method becomes quicker. By 5000 threads, if it's
called even twice per thread the syncronization method is 25% slower.
This is fairly inconclusive either way, because clearly different people
use this code in different ways, but I think backs up waht I said about
ThreadLocal's being more scalable, even if they are less efficient in
smaller cases.
I personally would advocate applying a patch similar to below to the
current cvs source.
Michael xxx
inline patch 1: PreparedStatement.java (+0/-0 lines) download inline-1.patch
--- PreparedStatement.java.orig Tue Jun 26 16:11:16 2001
+++ PreparedStatement.java Tue Jun 26 16:16:26 2001
@@ -44,6 +44,9 @@
private static ThreadLocal tl_df = new ThreadLocal(); //
setDate() SimpleDateFormat
private static ThreadLocal tl_tsdf = new ThreadLocal(); //
setTimestamp() SimpleDateFormat
+ private SimpleDateFormat sdSdf; // setDate SimpleDateFormat
+ private SimpleDateFormat stSdf; // setTimeStamp
SimpleDateFormat
+
/**
* Constructor for the PreparedStatement class.
* Split the SQL statement into segments - separated by the
arguments.
@@ -65,13 +68,18 @@
this.sql = sql;
this.connection = connection;
- // might just as well create it here, so we don't take
the hit later
- SimpleDateFormat df = new
SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
-
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- tl_tsdf.set(df);
+ // set up our SimpleDateFormats
+ sdSdf = (SimpleDateFormat)tl_df.get();
+ if (sdSdf == null) {
+ sdSdf = new SimpleDateFormat("''yyyy-MM-dd''");
+ tl_df.set(sdSdf);
+ }
+ stSdf = (SimpleDateFormat)tl_tsdf.get();
+ if (stSdf == null) {
+ stSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ tl_tsdf.set(df);
+ }
for (i = 0; i < sql.length(); ++i)
{
@@ -95,17 +103,6 @@
templateStrings[i] = (String)v.elementAt(i);
}
- /**
- * New in 7.1 - overides Statement.close() to dispose of a few
local objects
- */
- public void close() throws SQLException
- {
- // free the ThreadLocal caches
- tl_df.set(null);
- tl_tsdf.set(null);
- super.close();
- }
-
/**
* A Prepared SQL query is executed and its ResultSet is
returned
*
@@ -342,9 +339,7 @@
*/
public void setDate(int parameterIndex, java.sql.Date x) throws
SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
-
- set(parameterIndex, df.format(x));
+ set(parameterIndex, sdSdf.format(x));
// The above is how the date should be handled.
//
@@ -381,13 +376,13 @@
*/
public void setTimestamp(int parameterIndex, Timestamp x) throws
SQLException
{
- SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
- df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ stSdf.setTimeZone(TimeZone.getTimeZone("GMT"));
// Use the shared StringBuffer
synchronized(sbuf) {
sbuf.setLength(0);
-
sbuf.append("'").append(df.format(x)).append('.').append(x.getNanos()/10
000000).append("+00'");
+ sbuf.append("'").append(stSdf.format(x)).append('.')
+ .append(x.getNanos()/10000000).append("+00'");
set(parameterIndex, sbuf.toString());
}
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 16:26 Gunnar Rønning <gunnar@polygnosis.com>
parent: Michael Stephenson <mstephenson@tirin.openworld.co.uk>
1 sibling, 1 reply; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-26 16:26 UTC (permalink / raw)
To: Michael Stephenson <mstephenson@tirin.openworld.co.uk>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
* Michael Stephenson <mstephenson@tirin.openworld.co.uk> wrote:
|
| I've just ran a couple of hugely simplified test (basically starting a
| couple of thousand threads doing sdf.parse() with either synchronization
| or ThreadLocals a couple of times).
|
I agree that the tests are pretty inconclusive. We need something that
simulates real usage better. What platform are you testing on Linux ?
If so with native threads or green threads ?
|
| I personally would advocate applying a patch similar to below to the
| current cvs source.
|
This I don't understand, was your intention to remove thread safety with this
patch ? Looking at the way you introduce SimpleDateFormat as an instance
variable it seems so.
| Michael xxx
|
| --- PreparedStatement.java.orig Tue Jun 26 16:11:16 2001
| +++ PreparedStatement.java Tue Jun 26 16:16:26 2001
| @@ -44,6 +44,9 @@
| private static ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
| private static ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
|
| + private SimpleDateFormat sdSdf; // setDate SimpleDateFormat
| + private SimpleDateFormat stSdf; // setTimeStamp SimpleDateFormat
| +
| /**
| * Constructor for the PreparedStatement class.
| * Split the SQL statement into segments - separated by the arguments.
| @@ -65,13 +68,18 @@
| this.sql = sql;
| this.connection = connection;
|
| - // might just as well create it here, so we don't take the hit later
|
| - SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''");
| - tl_df.set(df);
| -
| - df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
| - tl_tsdf.set(df);
| + // set up our SimpleDateFormats
| + sdSdf = (SimpleDateFormat)tl_df.get();
| + if (sdSdf == null) {
| + sdSdf = new SimpleDateFormat("''yyyy-MM-dd''");
| + tl_df.set(sdSdf);
| + }
| + stSdf = (SimpleDateFormat)tl_tsdf.get();
| + if (stSdf == null) {
| + stSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
| + tl_tsdf.set(df);
| + }
|
| for (i = 0; i < sql.length(); ++i)
| {
| @@ -95,17 +103,6 @@
| templateStrings[i] = (String)v.elementAt(i);
| }
|
| - /**
| - * New in 7.1 - overides Statement.close() to dispose of a few local objects
| - */
| - public void close() throws SQLException
| - {
| - // free the ThreadLocal caches
| - tl_df.set(null);
| - tl_tsdf.set(null);
| - super.close();
| - }
| -
| /**
| * A Prepared SQL query is executed and its ResultSet is returned
| *
| @@ -342,9 +339,7 @@
| */
| public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
| {
| - SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
| -
| - set(parameterIndex, df.format(x));
| + set(parameterIndex, sdSdf.format(x));
|
| // The above is how the date should be handled.
| //
| @@ -381,13 +376,13 @@
| */
| public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
| {
| - SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
| - df.setTimeZone(TimeZone.getTimeZone("GMT"));
| + stSdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
| // Use the shared StringBuffer
| synchronized(sbuf) {
| sbuf.setLength(0);
| - sbuf.append("'").append(df.format(x)).append('.').append(x.getNanos()/10000000).append("+00'");
| + sbuf.append("'").append(stSdf.format(x)).append('.')
| + .append(x.getNanos()/10000000).append("+00'");
| set(parameterIndex, sbuf.toString());
| }
|
|
|
|
| ---------------------------(end of broadcast)---------------------------
| TIP 2: you can get off all lists at once with the unregister command
| (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
|
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 16:26 Barry Lind <barry@xythos.com>
parent: Dave Cramer <Dave@micro-automation.net>
3 siblings, 0 replies; 46+ messages in thread
From: Barry Lind @ 2001-06-26 16:26 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Dave,
I disagree with your understanding of the double locking issue. You
state "The if (anyvar == null) check is flawed in an SMP environment".
This statement would more correctly read "The if (anyvar == null) check
is flawed in an SMP environment where multiple threads are accessing
anyvar". If only one thread is accessing the variable (as is the case
in this code since the variable is a local variable that comes from a
ThreadLocal object) then there isn't any problem. If the variable in
question here where a member variable, then I would agree with you that
this if check could be problematic.
thanks,
--Barry
Dave Cramer wrote:
> Barry,
>
> My understanding of the problem is as follows:
>
> The if (anyvar == null) check is flawed in an SMP environment; according
> to the spec anyvar can be in the process of being created the jvm could
> set anyvar to point to the memory it is going to assign it to but not
> complete the creation of the object. You end up with a non-null, but
> invalid anyvar. This is the crux of the double locking flaw. While I
> hope most compiler writers would be smarter than that, apparently it is
> possible according to the spec.
>
> Well if we make the driver completely thread-safe we are going to take a
> real performance hit. Personally I would prefer to code assuming it is
> not completely thread-safe and have a lightweight driver.
>
> I am willing to take on some of the work for the driver, but I think the
> process s/b a group process. I have learned a lot in this particular
> thread.
> As I already mentioned I would like to see a voting procedure like the
> apache group.
>
> Regarding the catch-22 with Blob, etc. I think we need to make a harsh
> decision here. Either break the existing code, or create another driver
> codebase. If we don't do something we will be doomed to non-compliance.
> This will hurt the driver in the not too distant future. There are a lot
> of tools out there which the driver needs to be compatible with.
>
> I had a look at the updateable cursors and it looks possible. Do you
> know who is working on it?
>
> Dave
>
>
>
> -----Original Message-----
> From: Barry Lind [mailto:barry@xythos.com]
> Sent: June 25, 2001 11:39 AM
> To: Dave@micro-automation.net
> Cc: 'PostgreSQL jdbc list'
> Subject: Re: [ADMIN] High memory usage [PATCH]
>
> Dave,
>
> The patch I submitted is thread safe. The "if (df==null)" check is
> dealing with a ThreadLocal variable. By definition a ThreadLocal
> variable can't be used by any other thread since each thread has its own
>
> copy. (Unless the code goes and hands the object off to some other
> thread thus causing threading issues, which it doesn't in this case).
> Thus I believe the patch I submitted is perfectly thread safe.
>
> To your more general questions:
>
> I think thread safety is very important for all of the JDBC objects.
> There are no restrictions placed on what a user could do with these
> objects. It is perfectly legal to create a Statement in one thread,
> hand that statement off to two or more other threads to access. Now I
> wouldn't recommend doing this, but the spec permits it.
>
> As far as procedures and voting, I also believe that something needs to
> be done for the JDBC code base. Since Peter has apparently disappeared
> (I haven't seen a post from him in about two months, and the
> jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
>
> doesn't even have the 7.1 code yet) I think the core group needs to step
>
> in and provide some direction for the JDBC code base. Whether that is
> appointing someone new as the official/unofficial JDBC guru or adopting
> some other process, I don't know. What I do know is that the JDBC code
> base is suffering from lack of attention and direction.
>
> Issues that I am concerned about in the JDBC code base are:
> - get/setXXXStream methods are not really spec compliant
> - the 'bytea' datatype (i.e. binary) isn't supported, and can't be
> without backward compatibility problems because the get/setBytes methods
>
> currently assume that binary means BLOB.
> - performance/performance/performance - lots of work could/should be
> done to improve performance. Some good work was started last year but
> nothing came of it.
> - updateable cursors - I beleive some work is being done here by
> various parties on the list, but I have some serious concerns about
> if/how such functionality can/should be supported.
>
> thanks,
> --Barry
>
>
> Dave Cramer wrote:
>
>
>>Barry,
>>
>>My patch was attempting to maintain some sort of thread safety. I do
>>
> not
>
>>think the if (df==null) test is thread-safe. It would need to be
>>synchronized.
>>
>>However, as I have mentioned in a couple of previous posts; I'm not
>>
> sure
>
>>thread-safety is worthwhile. The driver appears to be thread safe in
>>that multiple threads can each use different instances of connections,
>>and statements, and resultset's however I don't think it is thread
>>
> safe
>
>>in the sense that multiple threads could use the same instance of the
>>above objects. The JDBC guide suggests that the driver s/b threadsafe
>>
> in
>
>>this sense (multiple threads....same object). The guide suggests that
>>one thread may instigate the retrieval of a result set, and another
>>would display it.
>>
>>
>>Where this is leading is: What kind of thread safety are we trying to
>>achieve?
>>
>>If it's only one instance per thread then, I would have to agree that
>>Barry's patch s/b applied.
>>
>>P.S.
>>
>>Is there a formal process within the postgres group for making these
>>kind of decisions.
>>
>>If not I would like to suggest adopting the apache groups +1,-1 voting
>>approach.
>>
>>-----Original Message-----
>>From: Barry Lind [mailto:blind@xythos.com]
>>Sent: June 25, 2001 12:37 AM
>>To: pgsql-patches@postgresql.org
>>Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
>>Subject: Re: [ADMIN] High memory usage [PATCH]
>>
>>Since this patch got applied before I got around to commenting on it,
>>
> I
>
>>have submitted a new patch to address my issues with the original
>>
> patch.
>
>>The problem with the patch as applied is that is always creates the
>>SimpleDateFormat objects in the constructor of the PreparedStatement
>>regardless of whether or not they will ever be used in the
>>PreparedStatement. I have reverted back to the old behavior that only
>>
>
>>creates them if necessary in the setDate and setTimestamp methods.
>>
>>I also removed the close() method. It's only purpose was to free
>>
> these
>
>>two SimpleDateFormat objects. I think it is much better to leave
>>
> these
>
>>two objects cached on the thread so that other PreparedStatements can
>>use them. (This was the intention of a patch I submitted back in
>>February where I was trying to remove as many object creations as
>>possible to improve performance. That patch as written needed to get
>>pulled because of the problem that SimpleDataFormat objects are not
>>thread safe. Peter then added the ThreadLocal code to try to solve
>>
> the
>
>>performance problem, but introduced the memory leak that originated
>>
> this
>
>>email thread.) I think the cost of at most two SimpleDateFormat
>>
> objects
>
>>being cached on each thead is worth the benefits of less object
>>
> creation
>
>>and subsequent garbage collection.
>>
>>thanks,
>>--Barry
>>
>>
>>Bruce Momjian wrote:
>>
>>
>>
>>>Patch applied. Thanks.
>>>
>>>
>>>
>>>
>>>>Here is a patch which inspired by Michael Stephens that should work
>>>>
>>>>Dave
>>>>
>>>>
>>>>-----Original Message-----
>>>>From: pgsql-jdbc-owner@postgresql.org
>>>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>>Sent: June 22, 2001 10:14 AM
>>>>To: Rainer Mager
>>>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>>
>>>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>>>|
>>>>
>>>>| Interesting. I wasn't aware of this. If question #2 is answered
>>>>
> such
>
>>>>that
>>>>| thread safe isn't necessary, then this problem goes away pretty
>>>>easily. If
>>>>| thread safety is needed then this would have to be rewritten, I can
>>>>look
>>>>| into doing this if you like.
>>>>
>>>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>>and
>>>>reference, 2 ed." from Addison Wesley ? This book contains a section
>>>>
>>>>
>>for
>>
>>
>>>>JDBC driver writers and explains this issue.
>>>>
>>>>regards,
>>>>
>>>> Gunnar
>>>>
>>>>--
>>>>Gunnar R?nning - gunnar@polygnosis.com
>>>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>>
>>>>---------------------------(end of
>>>>
>>>>
>>broadcast)---------------------------
>>
>>
>>>>TIP 1: subscribe and unsubscribe commands go to
>>>>
>>>>
>>majordomo@postgresql.org
>>
>>
>>>[ Attachment, skipping... ]
>>>
>>>
>>>
>>>
>>
>
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 16:32 Gunnar Rønning <gunnar@polygnosis.com>
parent: Dave Cramer <Dave@micro-automation.net>
3 siblings, 1 reply; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-26 16:32 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'Barry Lind' <barry@xythos.com>; 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
* "Dave Cramer" <Dave@micro-automation.net> wrote:
|
| Regarding the catch-22 with Blob, etc. I think we need to make a harsh
| decision here. Either break the existing code, or create another driver
| codebase. If we don't do something we will be doomed to non-compliance.
| This will hurt the driver in the not too distant future. There are a lot
| of tools out there which the driver needs to be compatible with.
|
I would say that it is better to break existing code that depends on
broken behaviour than being out of sync with the standard. Not following
the JDBC standard is just asking for a fork - there are a lot of
object relational tools out there and if want these to work with postgresql
we have no choice.
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 16:34 Barry Lind <barry@xythos.com>
parent: Dave Cramer <Dave@micro-automation.net>
3 siblings, 1 reply; 46+ messages in thread
From: Barry Lind @ 2001-06-26 16:34 UTC (permalink / raw)
To: Dave@micro-automation.net; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Dave,
I don't personally know who is working on updateable cursors, but if you
search the email archives, there have been a number of emails on this
topic over the last couple of months.
My issue with updateable cursors it that I think this should be
functionality provided by the backend, not patched on to the JDBC
driver. My reasoning here is that updateable cursors are very limited
in what you can do (single table selects, no where clause, etc). In
order to handle this it means that JDBC code is going to need to start
parsing the SQL statement to do this. I don't like the idea of having a
SQL parser on the client when one already exists on the server. You
start running into issues about everytime the server gets a patch to
support some new syntax in the SQL statement that the client parser also
needs to be updated. In my years at Oracle this was always a problem
where the client tools ended up breaking everytime the server added some
new syntax support.
Having said all of that, I think updateable cursors is a good feature,
but I think the majority of the work should be done in the backend and
not in the JDBC driver. The added benefit of this is that then all
front ends have access to this functionality.
thanks,
--Barry
Dave Cramer wrote:
> Barry,
>
> My understanding of the problem is as follows:
>
> The if (anyvar == null) check is flawed in an SMP environment; according
> to the spec anyvar can be in the process of being created the jvm could
> set anyvar to point to the memory it is going to assign it to but not
> complete the creation of the object. You end up with a non-null, but
> invalid anyvar. This is the crux of the double locking flaw. While I
> hope most compiler writers would be smarter than that, apparently it is
> possible according to the spec.
>
> Well if we make the driver completely thread-safe we are going to take a
> real performance hit. Personally I would prefer to code assuming it is
> not completely thread-safe and have a lightweight driver.
>
> I am willing to take on some of the work for the driver, but I think the
> process s/b a group process. I have learned a lot in this particular
> thread.
> As I already mentioned I would like to see a voting procedure like the
> apache group.
>
> Regarding the catch-22 with Blob, etc. I think we need to make a harsh
> decision here. Either break the existing code, or create another driver
> codebase. If we don't do something we will be doomed to non-compliance.
> This will hurt the driver in the not too distant future. There are a lot
> of tools out there which the driver needs to be compatible with.
>
> I had a look at the updateable cursors and it looks possible. Do you
> know who is working on it?
>
> Dave
>
>
>
> -----Original Message-----
> From: Barry Lind [mailto:barry@xythos.com]
> Sent: June 25, 2001 11:39 AM
> To: Dave@micro-automation.net
> Cc: 'PostgreSQL jdbc list'
> Subject: Re: [ADMIN] High memory usage [PATCH]
>
> Dave,
>
> The patch I submitted is thread safe. The "if (df==null)" check is
> dealing with a ThreadLocal variable. By definition a ThreadLocal
> variable can't be used by any other thread since each thread has its own
>
> copy. (Unless the code goes and hands the object off to some other
> thread thus causing threading issues, which it doesn't in this case).
> Thus I believe the patch I submitted is perfectly thread safe.
>
> To your more general questions:
>
> I think thread safety is very important for all of the JDBC objects.
> There are no restrictions placed on what a user could do with these
> objects. It is perfectly legal to create a Statement in one thread,
> hand that statement off to two or more other threads to access. Now I
> wouldn't recommend doing this, but the spec permits it.
>
> As far as procedures and voting, I also believe that something needs to
> be done for the JDBC code base. Since Peter has apparently disappeared
> (I haven't seen a post from him in about two months, and the
> jdbc.postgresql.org website hasn't been updated for about 4 mounths - it
>
> doesn't even have the 7.1 code yet) I think the core group needs to step
>
> in and provide some direction for the JDBC code base. Whether that is
> appointing someone new as the official/unofficial JDBC guru or adopting
> some other process, I don't know. What I do know is that the JDBC code
> base is suffering from lack of attention and direction.
>
> Issues that I am concerned about in the JDBC code base are:
> - get/setXXXStream methods are not really spec compliant
> - the 'bytea' datatype (i.e. binary) isn't supported, and can't be
> without backward compatibility problems because the get/setBytes methods
>
> currently assume that binary means BLOB.
> - performance/performance/performance - lots of work could/should be
> done to improve performance. Some good work was started last year but
> nothing came of it.
> - updateable cursors - I beleive some work is being done here by
> various parties on the list, but I have some serious concerns about
> if/how such functionality can/should be supported.
>
> thanks,
> --Barry
>
>
> Dave Cramer wrote:
>
>
>>Barry,
>>
>>My patch was attempting to maintain some sort of thread safety. I do
>>
> not
>
>>think the if (df==null) test is thread-safe. It would need to be
>>synchronized.
>>
>>However, as I have mentioned in a couple of previous posts; I'm not
>>
> sure
>
>>thread-safety is worthwhile. The driver appears to be thread safe in
>>that multiple threads can each use different instances of connections,
>>and statements, and resultset's however I don't think it is thread
>>
> safe
>
>>in the sense that multiple threads could use the same instance of the
>>above objects. The JDBC guide suggests that the driver s/b threadsafe
>>
> in
>
>>this sense (multiple threads....same object). The guide suggests that
>>one thread may instigate the retrieval of a result set, and another
>>would display it.
>>
>>
>>Where this is leading is: What kind of thread safety are we trying to
>>achieve?
>>
>>If it's only one instance per thread then, I would have to agree that
>>Barry's patch s/b applied.
>>
>>P.S.
>>
>>Is there a formal process within the postgres group for making these
>>kind of decisions.
>>
>>If not I would like to suggest adopting the apache groups +1,-1 voting
>>approach.
>>
>>-----Original Message-----
>>From: Barry Lind [mailto:blind@xythos.com]
>>Sent: June 25, 2001 12:37 AM
>>To: pgsql-patches@postgresql.org
>>Cc: Dave@micro-automation.net; 'PostgreSQL jdbc list'
>>Subject: Re: [ADMIN] High memory usage [PATCH]
>>
>>Since this patch got applied before I got around to commenting on it,
>>
> I
>
>>have submitted a new patch to address my issues with the original
>>
> patch.
>
>>The problem with the patch as applied is that is always creates the
>>SimpleDateFormat objects in the constructor of the PreparedStatement
>>regardless of whether or not they will ever be used in the
>>PreparedStatement. I have reverted back to the old behavior that only
>>
>
>>creates them if necessary in the setDate and setTimestamp methods.
>>
>>I also removed the close() method. It's only purpose was to free
>>
> these
>
>>two SimpleDateFormat objects. I think it is much better to leave
>>
> these
>
>>two objects cached on the thread so that other PreparedStatements can
>>use them. (This was the intention of a patch I submitted back in
>>February where I was trying to remove as many object creations as
>>possible to improve performance. That patch as written needed to get
>>pulled because of the problem that SimpleDataFormat objects are not
>>thread safe. Peter then added the ThreadLocal code to try to solve
>>
> the
>
>>performance problem, but introduced the memory leak that originated
>>
> this
>
>>email thread.) I think the cost of at most two SimpleDateFormat
>>
> objects
>
>>being cached on each thead is worth the benefits of less object
>>
> creation
>
>>and subsequent garbage collection.
>>
>>thanks,
>>--Barry
>>
>>
>>Bruce Momjian wrote:
>>
>>
>>
>>>Patch applied. Thanks.
>>>
>>>
>>>
>>>
>>>>Here is a patch which inspired by Michael Stephens that should work
>>>>
>>>>Dave
>>>>
>>>>
>>>>-----Original Message-----
>>>>From: pgsql-jdbc-owner@postgresql.org
>>>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar R?nning
>>>>Sent: June 22, 2001 10:14 AM
>>>>To: Rainer Mager
>>>>Cc: Dave Cramer; Bruce Momjian; PostgreSQL jdbc list
>>>>Subject: Re: [JDBC] Re: [ADMIN] High memory usage [PATCH]
>>>>
>>>>* "Rainer Mager" <rmager@vgkk.com> wrote:
>>>>|
>>>>
>>>>| Interesting. I wasn't aware of this. If question #2 is answered
>>>>
> such
>
>>>>that
>>>>| thread safe isn't necessary, then this problem goes away pretty
>>>>easily. If
>>>>| thread safety is needed then this would have to be rewritten, I can
>>>>look
>>>>| into doing this if you like.
>>>>
>>>>Thread safety is required by the spec. Do you have "JDBC API tutorial
>>>>and
>>>>reference, 2 ed." from Addison Wesley ? This book contains a section
>>>>
>>>>
>>for
>>
>>
>>>>JDBC driver writers and explains this issue.
>>>>
>>>>regards,
>>>>
>>>> Gunnar
>>>>
>>>>--
>>>>Gunnar R?nning - gunnar@polygnosis.com
>>>>Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>>>>
>>>>---------------------------(end of
>>>>
>>>>
>>broadcast)---------------------------
>>
>>
>>>>TIP 1: subscribe and unsubscribe commands go to
>>>>
>>>>
>>majordomo@postgresql.org
>>
>>
>>>[ Attachment, skipping... ]
>>>
>>>
>>>
>>>
>>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 16:35 Michael Stephenson <mstephenson@tirin.openworld.co.uk>
parent: Gunnar Rønning <gunnar@polygnosis.com>
0 siblings, 0 replies; 46+ messages in thread
From: Michael Stephenson @ 2001-06-26 16:35 UTC (permalink / raw)
To: Gunnar Rønning <gunnar@polygnosis.com>; +Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
> I agree that the tests are pretty inconclusive. We need something that
> simulates real usage better. What platform are you testing on Linux ?
> If so with native threads or green threads ?
Linux, I'm using native threads with the hot spot I'm using native
threads, which as I said was performing pretty much identically in both
cases. The non hot spot machine was using green threads which is where the
difference in performance was measurable.
> | I personally would advocate applying a patch similar to below to the
> | current cvs source.
>
> This I don't understand, was your intention to remove thread safety with this
> patch ? Looking at the way you introduce SimpleDateFormat as an instance
> variable it seems so.
Yeah, the patch is rubbish, I did it that way to remove the
(comparitively expensive) ThreadLocal.get inside the setDate and
SetTimeStamp, which is clearly stupid.
Michael xxx
^ permalink raw reply [nested|flat] 46+ messages in thread
* RE: RE: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 17:02 Dave Cramer <Dave@micro-automation.net>
parent: Gunnar Rønning <gunnar@polygnosis.com>
0 siblings, 0 replies; 46+ messages in thread
From: Dave Cramer @ 2001-06-26 17:02 UTC (permalink / raw)
To: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
My only thought was that we could leave the existing driver in place for
people who are depending on it. In retrospect this isn't a good idea. I
would recommend breaking existing code to make the driver compatible
with the standard.
--dc--
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Gunnar Rønning
Sent: June 26, 2001 12:32 PM
To: Dave@micro-automation.net
Cc: 'Barry Lind'; 'PostgreSQL jdbc list'
Subject: Re: [JDBC] RE: [ADMIN] High memory usage [PATCH]
* "Dave Cramer" <Dave@micro-automation.net> wrote:
|
| Regarding the catch-22 with Blob, etc. I think we need to make a harsh
| decision here. Either break the existing code, or create another
driver
| codebase. If we don't do something we will be doomed to
non-compliance.
| This will hurt the driver in the not too distant future. There are a
lot
| of tools out there which the driver needs to be compatible with.
|
I would say that it is better to break existing code that depends on
broken behaviour than being out of sync with the standard. Not following
the JDBC standard is just asking for a fork - there are a lot of
object relational tools out there and if want these to work with
postgresql
we have no choice.
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-26 19:19 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Barry Lind <barry@xythos.com>
0 siblings, 1 reply; 46+ messages in thread
From: Bruce Momjian @ 2001-06-26 19:19 UTC (permalink / raw)
To: Barry Lind <barry@xythos.com>; +Cc: Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
>
> Having said all of that, I think updateable cursors is a good feature,
> but I think the majority of the work should be done in the backend and
> not in the JDBC driver. The added benefit of this is that then all
> front ends have access to this functionality.
Agreed. This is a backend issue. Updated TODO:
* JDBC
* Comprehensive test suite. This may be available already.
* Updateable resultSet (must be done in backend code)
* Improved DatabaseMetaData
* Compatible blob support
* Error Codes (pending backend implementation)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-27 06:52 Gunnar Rønning <gunnar@polygnosis.com>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 46+ messages in thread
From: Gunnar Rønning @ 2001-06-27 06:52 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Barry Lind <barry@xythos.com>; Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
* Bruce Momjian <pgman@candle.pha.pa.us> wrote:
|
| * Compatible blob support
* BLOB support compatible with the JDBC standard. Breaks compatibility
with earlier versions of the JDBC driver.
I suggest that we go this path, so we open up postgresql as a choice for
more third party tools and applications.
--
Gunnar Rønning - gunnar@polygnosis.com
Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
^ permalink raw reply [nested|flat] 46+ messages in thread
* Re: Re: [ADMIN] High memory usage [PATCH]
@ 2001-06-27 16:16 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Gunnar Rønning <gunnar@polygnosis.com>
0 siblings, 0 replies; 46+ messages in thread
From: Bruce Momjian @ 2001-06-27 16:16 UTC (permalink / raw)
To: Gunnar Rønning <gunnar@polygnosis.com>; +Cc: Barry Lind <barry@xythos.com>; Dave@micro-automation.net, "'PostgreSQL jdbc list'" <pgsql-jdbc@postgresql.org>
Updated:
* JDBC-standard BLOB support
> * Bruce Momjian <pgman@candle.pha.pa.us> wrote:
> |
>
> | * Compatible blob support
>
> * BLOB support compatible with the JDBC standard. Breaks compatibility
> with earlier versions of the JDBC driver.
>
> I suggest that we go this path, so we open up postgresql as a choice for
> more third party tools and applications.
>
> --
> Gunnar R?nning - gunnar@polygnosis.com
> Senior Consultant, Polygnosis AS, http://www.polygnosis.com/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 46+ messages in thread
end of thread, other threads:[~2001-06-27 16:16 UTC | newest]
Thread overview: 46+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-20 03:40 RE: High memory usage [PATCH] Rainer Mager <rmager@vgkk.com>
2001-06-21 02:08 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-21 22:23 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-22 00:33 ` Dave Cramer <Dave@micro-automation.net>
2001-06-22 04:56 ` Rainer Mager <rmager@vgkk.com>
2001-06-22 14:13 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-22 14:42 ` Michael Stephenson <mstephenson@tirin.openworld.co.uk>
2001-06-22 15:20 ` Dave Cramer <dave@fastcrypt.com>
2001-06-22 19:09 ` Dave Cramer <Dave@micro-automation.net>
2001-06-23 03:00 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-25 01:53 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-25 04:36 ` Barry Lind <blind@xythos.com>
2001-06-25 12:11 ` Dave Cramer <Dave@micro-automation.net>
2001-06-25 14:59 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-25 17:41 ` Barry Lind <barry@xythos.com>
2001-06-25 18:49 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-25 19:53 ` Dave Cramer <Dave@micro-automation.net>
2001-06-25 20:03 ` Barry Lind <barry@xythos.com>
2001-06-25 21:43 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-26 13:24 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-26 13:37 ` Michael Stephenson <mstephenson@tirin.openworld.co.uk>
2001-06-26 13:47 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-26 15:21 ` Michael Stephenson <mstephenson@tirin.openworld.co.uk>
2001-06-26 16:21 ` Dave Cramer <Dave@micro-automation.net>
2001-06-26 16:26 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-26 16:35 ` Michael Stephenson <mstephenson@tirin.openworld.co.uk>
2001-06-25 15:39 ` Barry Lind <barry@xythos.com>
2001-06-25 22:44 ` Barry Lind <barry@xythos.com>
2001-06-26 01:32 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-26 01:04 ` Dave Cramer <Dave@micro-automation.net>
2001-06-26 01:25 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-26 16:26 ` Barry Lind <barry@xythos.com>
2001-06-26 16:32 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-26 17:02 ` Dave Cramer <Dave@micro-automation.net>
2001-06-26 16:34 ` Barry Lind <barry@xythos.com>
2001-06-26 19:19 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-27 06:52 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-27 16:16 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-26 01:27 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-25 15:41 ` Barry Lind <barry@xythos.com>
2001-06-25 22:46 ` Barry Lind <barry@xythos.com>
2001-06-26 01:44 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-06-22 14:34 ` Dave Cramer <Dave@micro-automation.net>
2001-06-22 11:42 ` Gunnar Rønning <gunnar@polygnosis.com>
2001-06-22 13:19 ` Dave Cramer <davec@sentricity.com>
2001-06-22 14:02 ` Gunnar Rønning <gunnar@polygnosis.com>
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