Re: ECPG - Specifying connections, TSD, sqlca.

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
Cc: Shridhar Daithankar <shridhar(at)frodo(dot)hserus(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ECPG - Specifying connections, TSD, sqlca.
Date: 2004-03-09 21:41:23
Message-ID: 200403092141.i29LfNK13529@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Lee Kindness wrote:
> From: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
> > Lee Kindness wrote:
> > > I still think it's worthwhile investigating the use of GCC's __thread
> > > storage class specifier to remove the use of pthread_*specific in this
> > > case. This would also be a help to the WIN32 port since this specifier
> > > maps well to similar constructs in Microsoft's and Borland's compilers
> > > (see "thread" item in the TODO at developer.postgresql.org)
> > I would like to avoid compiler-specific thread stuff unless tests can
> > show a performance benefit.
>
> I think concerns re performance are largely moot - with the thread specific
> data performance is much the same as without. However native compiler
> support for thread specific data is much more straightforward and
> understandable - you simply end up with a variable that can be used like any
> other except there is a copy of it for each thread.
>
> To make ECPG thread-safe for WIN32 an additional set of thread calls will
> need to be added, and/or similar features to GCC's __thread storage
> specifier. If we end up adding these for WIN32 then it may as well be done
> for GCC too. I probably will experiment with it a bit (and get some real
> performance figure, rather than my hunch!)...
>
> Perhaps a cleaner way is to use an existing thread package with encompasses
> the various platform APIs - i.e. APR or ACE, or... But that's a big
> discussion, and not one I'm keen to get into at the moment. A more
> appropriate time is perhaps once the WIN32 port is completed? It would also
> be straightforward to encompass this in an PostgreSQL specific API to wrap
> around the various calls we use and, if available, make these no-ops when a
> suitable storage class is supplied by the compiler? I'd be happy to write
> this API if others saw it as a way forward.
>
> Perhaps someone would like to fwd this on to the hackers-win32 list (I'm not
> subscribed) to see what their view is on thread safety in the client
> libraries? And what approach they're planning?

I guess my point was that if there isn't a big performance win, why do
compiler specific and POSIX standard both in the same code. The
compiler-specific might be clearer, but if we have to support non-gcc
too, which we do, adding a cleaner solution to one that is already
standard actually makes it look worse.

I don't think MinGW support thread-specific right now (no TLS support),
so we will need native Win32 in there anyway. Adding a third seems like
more confusion.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2004-03-09 21:53:07 Re: pgFoundry WAS: On pgweb project
Previous Message Robert Treat 2004-03-09 21:22:02 Re: pgFoundry WAS: On pgweb project

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2004-03-09 21:55:08 Re: minor doc work
Previous Message Lee Kindness 2004-03-09 21:15:39 Re: ECPG - Specifying connections, TSD, sqlca.