pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq_r
28+ messages / 7 participants
[nested] [flat]
* libpq_r
@ 2003-07-24 08:22 Lee Kindness <lkindness@csl.co.uk>
0 siblings, 2 replies; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 08:22 UTC (permalink / raw)
To: pgsql-hackers; +Cc: Lee Kindness <lkindness@csl.co.uk>
Guys, take a look at what was done in libpq to make it
thread-safe... No locks! No overheaded - just using "proper" reentrant
functions...
If we have libpq_r then we're making a complete hash of it all - being
reentrant is good, even if you're not using threads!
Now, ecpg is another issue...
L.
Bruce Momjian writes:
> Shridhar Daithankar wrote:
> > I repeat what I have said earlier. If there are two libraries A using libecpg_r
> > and B, using libecpg, then program linking against both of them is going to
> > have tough time living with symbol conflicts.
> >
> > I suppose problem will be reproducible even under freeBSD if you try to create
> > a postgresql function in C which uses threads. Link the library against libc_r
> > and link postgresql against libc. It would run into problems.
> >
> > I am just stating my experiences.I might have missed solution to this problem.
> >
> > But overall I like GNU libc approach of everything thread safe by default. If
> > thread performance is an issue, then it should be improved. Not worked around
> > with two libraries.
>
> I thought glibc was the one to introduce libc_r in the first place ---
> are they making libc thread-safe now?
>
> What OS's are still using libc_r for threaded-ness? I never liked that
> approach myself, and I resist adding it to our setup unless it is
> required.
>
> One problem now is that we don't have a way to create a separate libpq_r
> for operating systems that use libc_r. We just create libpq and it is
> thread-safe.
>
> As for the configure flag, we still need it because we don't know the
> flags required by all our supported OS's.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 12:52 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Lee Kindness <lkindness@csl.co.uk>
1 sibling, 2 replies; 28+ messages in thread
From: Bruce Momjian @ 2003-07-24 12:52 UTC (permalink / raw)
To: Lee Kindness <lkindness@csl.co.uk>; +Cc: pgsql-hackers
Lee Kindness wrote:
> Guys, take a look at what was done in libpq to make it
> thread-safe... No locks! No overheaded - just using "proper" reentrant
> functions...
>
> If we have libpq_r then we're making a complete hash of it all - being
> reentrant is good, even if you're not using threads!
>
> Now, ecpg is another issue...
>
I think the issue is that using a threaded library to link into libpq
could have locking stuff.
My guess is that if the OS has separate threaded libs, we have to mimic
that stuff.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 13:09 Larry Rosenman <ler@lerctr.org>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 0 replies; 28+ messages in thread
From: Larry Rosenman @ 2003-07-24 13:09 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; Lee Kindness <lkindness@csl.co.uk>; +Cc: pgsql-hackers
--On Thursday, July 24, 2003 08:52:37 -0400 Bruce Momjian
<pgman@candle.pha.pa.us> wrote:
> Lee Kindness wrote:
>> Guys, take a look at what was done in libpq to make it
>> thread-safe... No locks! No overheaded - just using "proper" reentrant
>> functions...
>>
>> If we have libpq_r then we're making a complete hash of it all - being
>> reentrant is good, even if you're not using threads!
>>
>> Now, ecpg is another issue...
>>
>
> I think the issue is that using a threaded library to link into libpq
> could have locking stuff.
>
> My guess is that if the OS has separate threaded libs, we have to mimic
> that stuff.
possibly. On UnixWare, the original executable in the process needs to
have -K[p]thread
specified to get libthread included. I'll be adding -D_REENTRANT to the
libpq build for
UnixWare to make sure that libpq is threadsafe, but doesn't include the
thread library as
a pre-requisite per input from SCO.
BTW, Bruce, SCO OpenServer does NOT have threads.
LER
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 13:12 Lee Kindness <lkindness@csl.co.uk>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 1 reply; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 13:12 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; pgsql-hackers
Bruce Momjian writes:
> Lee Kindness wrote:
> > Guys, take a look at what was done in libpq to make it
> > thread-safe... No locks! No overheaded - just using "proper" reentrant
> > functions...
> > If we have libpq_r then we're making a complete hash of it all - being
> > reentrant is good, even if you're not using threads!
> > Now, ecpg is another issue...
> I think the issue is that using a threaded library to link into libpq
> could have locking stuff.
>
> My guess is that if the OS has separate threaded libs, we have to mimic
> that stuff.
But there are NO thread primitives/calls in libpq - it's just a normal
shared library, it has has no thread voodoo! A threaded app/library
using libpq doesn't have to do anything special... libpq doesn't need
link the threads library (and it explicitly should not) - only define
_REENTRANT.
The reentrant calls libpq may be using are in the standard system
libraries (not the system thread library), the same libraries that the
app/libs will be linked against.
Now, libecpg on the otherhand does need mutex locks compiled in. Thus
if this is enabled then anyone who links against it also needs to link
in threads (unless the system is "intelligent" like Solaris and
includes empty stubs of the thread functions in libc).
However in this day and age the overhead of the locks are negligible
and it is more desirable to have one library...
L.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:04 Peter Eisentraut <peter_e@gmx.net>
parent: Lee Kindness <lkindness@csl.co.uk>
1 sibling, 0 replies; 28+ messages in thread
From: Peter Eisentraut @ 2003-07-24 14:04 UTC (permalink / raw)
To: Lee Kindness <lkindness@csl.co.uk>; +Cc: pgsql-hackers
Lee Kindness writes:
> Guys, take a look at what was done in libpq to make it
> thread-safe... No locks! No overheaded - just using "proper" reentrant
> functions...
There is a difference between being reentrant and being thread-safe.
Making libpq reentrant is relatively easy if you use the right functions.
But we have no guarantee that it will be thread-safe by default, because
some platforms require special flags to make standard library functions
thread-safe.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:09 Tom Lane <tgl@sss.pgh.pa.us>
parent: Lee Kindness <lkindness@csl.co.uk>
0 siblings, 2 replies; 28+ messages in thread
From: Tom Lane @ 2003-07-24 14:09 UTC (permalink / raw)
To: Lee Kindness <lkindness@csl.co.uk>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-hackers
Lee Kindness <lkindness@csl.co.uk> writes:
> Bruce Momjian writes:
>>> My guess is that if the OS has separate threaded libs, we have to mimic
>>> that stuff.
> But there are NO thread primitives/calls in libpq
That's not the point. The point is stuff that isn't necessarily visible
in the source code --- such as what method it uses to get at "errno",
whether it's linked to thread-safe versions of malloc and other libc
routines, etc.
If the OS supplies both libc and libc_r, it is unlikely to be a good
idea to link a threaded libpq with libc, or a non-threaded libpq with
libc_r.
regards, tom lane
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:32 Lee Kindness <lkindness@csl.co.uk>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 14:32 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-hackers
Tom Lane writes:
> Lee Kindness <lkindness@csl.co.uk> writes:
> > Bruce Momjian writes:
> >>> My guess is that if the OS has separate threaded libs, we have to mimic
> >>> that stuff.
> > But there are NO thread primitives/calls in libpq
> That's not the point. The point is stuff that isn't necessarily visible
> in the source code --- such as what method it uses to get at "errno",
> whether it's linked to thread-safe versions of malloc and other libc
> routines, etc.
> If the OS supplies both libc and libc_r, it is unlikely to be a good
> idea to link a threaded libpq with libc, or a non-threaded libpq with
> libc_r.
No, that is the point exactly... I know fine well the visibility of
errno and the different ways it may be implemented. You'll find it
hard to come across an OS which doesn't "do the right thing" WRT to
using reentrant functions and "wrappers" if _REENTRANT is defined
during the compile...
That is ALL that is needed, lets not complicate the issue...
And what do you mean by "threaded libpq" and "non-threaded libpq" - as
I say above there are NO thread primitives being used in libpq. It's
just clean reentrant code... This change/patch should be done
irregardless of the move to thread safety!
L.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:44 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Lee Kindness <lkindness@csl.co.uk>
0 siblings, 3 replies; 28+ messages in thread
From: Bruce Momjian @ 2003-07-24 14:44 UTC (permalink / raw)
To: Lee Kindness <lkindness@csl.co.uk>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Lee Kindness wrote:
> Tom Lane writes:
> > Lee Kindness <lkindness@csl.co.uk> writes:
> > > Bruce Momjian writes:
> > >>> My guess is that if the OS has separate threaded libs, we have to mimic
> > >>> that stuff.
> > > But there are NO thread primitives/calls in libpq
> > That's not the point. The point is stuff that isn't necessarily visible
> > in the source code --- such as what method it uses to get at "errno",
> > whether it's linked to thread-safe versions of malloc and other libc
> > routines, etc.
> > If the OS supplies both libc and libc_r, it is unlikely to be a good
> > idea to link a threaded libpq with libc, or a non-threaded libpq with
> > libc_r.
>
> No, that is the point exactly... I know fine well the visibility of
> errno and the different ways it may be implemented. You'll find it
> hard to come across an OS which doesn't "do the right thing" WRT to
> using reentrant functions and "wrappers" if _REENTRANT is defined
> during the compile...
>
> That is ALL that is needed, lets not complicate the issue...
>
> And what do you mean by "threaded libpq" and "non-threaded libpq" - as
> I say above there are NO thread primitives being used in libpq. It's
> just clean reentrant code... This change/patch should be done
> irregardless of the move to thread safety!
Now I see what you are saying, that _REENTRANT just makes it reentrant,
and doesn't have a downside in terms of performance.
However, notice the flags needed under Linux:
THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
or are you saying libpq needs only the first one because libpq, itself,
doesn't use threads --- interesting distinction, and perhaps a way we
can get by with one libpq even on platforms that require *_r libraries.
As you mentioned, ecpg is another manner, but I think perhaps an ecpg
flag could allow both threaded and nonthreaded.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:45 Lee Kindness <lkindness@csl.co.uk>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 14:45 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-hackers
Tom Lane writes:
> If the OS supplies both libc and libc_r, it is unlikely to be a good
> idea to link a threaded libpq with libc, or a non-threaded libpq with
> libc_r.
What modern OS has libc_r? The majors (Linux, Soalris, HPUX, AIX)
certainly do not.
L.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:48 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
2 siblings, 1 reply; 28+ messages in thread
From: Tom Lane @ 2003-07-24 14:48 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Now I see what you are saying, that _REENTRANT just makes it reentrant,
> and doesn't have a downside in terms of performance.
That's at best an unsupported assertion. Why would the platform bother
with supplying two copies of libc if they didn't think there was a
performance hit?
regards, tom lane
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:51 Lee Kindness <lkindness@csl.co.uk>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 14:51 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; Lee Kindness <lkindness@csl.co.uk>; pgsql-hackers
Tom Lane writes:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Now I see what you are saying, that _REENTRANT just makes it reentrant,
> > and doesn't have a downside in terms of performance.
> That's at best an unsupported assertion. Why would the platform bother
> with supplying two copies of libc if they didn't think there was a
> performance hit?
Better remove transactions then, yeah? Performace hit! Profile it and
see how minor (or likely non-existent) it is...
L.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 14:55 Lee Kindness <lkindness@csl.co.uk>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
2 siblings, 0 replies; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 14:55 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Bruce Momjian writes:
> However, notice the flags needed under Linux:
>
> THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
>
> or are you saying libpq needs only the first one because libpq, itself,
> doesn't use threads --- interesting distinction, and perhaps a way we
> can get by with one libpq even on platforms that require *_r
> libraries.
Urgh, I think I was a bit over zealous witht he first patch and just
bundled the later two in... After looking around the includes they
don't do anything under Linux. I think they're used on AIX.
however the best way to do this is to look at another package which
has a wide distribution and wide OS base - OpenLDAP being a good
example (or even MySQL!)- and see how they do things... No need to
reinvent the wheel!
L.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 15:18 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Peter Eisentraut <peter_e@gmx.net>
1 sibling, 1 reply; 28+ messages in thread
From: Bruce Momjian @ 2003-07-24 15:18 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > Now I see what you are saying, that _REENTRANT just makes it reentrant,
>
> _REENTRANT only makes additional functions visible in the header files, it
> doesn't change any functions to behave differently. (This is not hard to
> imagine, because the lack of reentrancy of most functions lies in the
> public interface, and you can't change that transparently.)
>
> > and doesn't have a downside in terms of performance.
>
> It follows from the above that this is irrelevant.
>
> > However, notice the flags needed under Linux:
> >
> > THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
>
> Those flags are bogus. You don't need any flags under Linux.
Is that true for all versions of Linux? Don't we need the first one so
we compile cleanly.
Also, the remaining to linux settings:
THREAD_LIBS="-lpthread"
NEED_REENTRANT_FUNC_NAMES=yes
I assume -lpthread does have an effect on the library, or does it?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 15:21 Peter Eisentraut <peter_e@gmx.net>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
2 siblings, 2 replies; 28+ messages in thread
From: Peter Eisentraut @ 2003-07-24 15:21 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Bruce Momjian writes:
> Now I see what you are saying, that _REENTRANT just makes it reentrant,
_REENTRANT only makes additional functions visible in the header files, it
doesn't change any functions to behave differently. (This is not hard to
imagine, because the lack of reentrancy of most functions lies in the
public interface, and you can't change that transparently.)
> and doesn't have a downside in terms of performance.
It follows from the above that this is irrelevant.
> However, notice the flags needed under Linux:
>
> THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
Those flags are bogus. You don't need any flags under Linux.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 15:29 Lee Kindness <lkindness@csl.co.uk>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 15:29 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Peter Eisentraut <peter_e@gmx.net>; Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Bruce Momjian writes:
> Peter Eisentraut wrote:
> > Bruce Momjian writes:
> > > THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
> > Those flags are bogus. You don't need any flags under Linux.
> Is that true for all versions of Linux? Don't we need the first one so
> we compile cleanly.
Yeah, you want to define _REENTRANT...
> Also, the remaining to linux settings:
> THREAD_LIBS="-lpthread"
> NEED_REENTRANT_FUNC_NAMES=yes
> I assume -lpthread does have an effect on the library, or does it?
You DO NOT want -lpthread for libpq, but you do want it for ecpg.
L.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 15:30 Larry Rosenman <ler@lerctr.org>
parent: Peter Eisentraut <peter_e@gmx.net>
1 sibling, 1 reply; 28+ messages in thread
From: Larry Rosenman @ 2003-07-24 15:30 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
--On Thursday, July 24, 2003 17:21:17 +0200 Peter Eisentraut
<peter_e@gmx.net> wrote:
> Bruce Momjian writes:
>
>> Now I see what you are saying, that _REENTRANT just makes it reentrant,
>
> _REENTRANT only makes additional functions visible in the header files, it
> doesn't change any functions to behave differently. (This is not hard to
> imagine, because the lack of reentrancy of most functions lies in the
> public interface, and you can't change that transparently.)
>
I beg to differ. Explicitly, on UnixWare, the <errno.h> header, reproduced
below, under
fair use, show an EXPLICIT difference in what happens with _REENTRANT:
$ cat /usr/include/errno.h
/*
* Copyright (c) 2002 Caldera International, Inc. All Rights Reserved.
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF
* Caldera International, Inc.
*
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*/
#ifndef _ERRNO_H
#define _ERRNO_H
#ident "@(#)unixsrc:usr/src/common/head/errno.h /main/uw7_nj/2"
#include <sys/errno.h>
#ifdef _REENTRANT
#ifdef __cplusplus
extern "C" {
#endif
extern int *__thr_errno(void);
#ifdef __cplusplus
}
#endif
#define errno (*__thr_errno())
#else /*!_REENTRANT*/
extern int errno;
#ifdef __cplusplus /* C++ requires that this be a macro! */
#define errno errno
#endif
#endif /*_REENTRANT*/
#endif /*_ERRNO_H*/
$
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 16:00 Peter Eisentraut <peter_e@gmx.net>
parent: Larry Rosenman <ler@lerctr.org>
0 siblings, 2 replies; 28+ messages in thread
From: Peter Eisentraut @ 2003-07-24 16:00 UTC (permalink / raw)
To: Larry Rosenman <ler@lerctr.org>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Larry Rosenman writes:
> I beg to differ. Explicitly, on UnixWare, the <errno.h> header,
> reproduced below, under fair use, show an EXPLICIT difference in what
> happens with _REENTRANT:
Hmm, I was too optimistic. I guess we'll just have to handcraft a
different solution for each platform. But clearly on some platforms we'll
need a libpq_r, so for the reasons I outlined in my initial post, it'd be
good to provide one on all platforms.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 16:08 Lee Kindness <lkindness@csl.co.uk>
parent: Peter Eisentraut <peter_e@gmx.net>
1 sibling, 0 replies; 28+ messages in thread
From: Lee Kindness @ 2003-07-24 16:08 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Larry Rosenman <ler@lerctr.org>; Bruce Momjian <pgman@candle.pha.pa.us>; Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Peter Eisentraut writes:
> Larry Rosenman writes:
> > I beg to differ. Explicitly, on UnixWare, the <errno.h> header,
> > reproduced below, under fair use, show an EXPLICIT difference in what
> > happens with _REENTRANT:
> Hmm, I was too optimistic. I guess we'll just have to handcraft a
> different solution for each platform. But clearly on some platforms we'll
> need a libpq_r, so for the reasons I outlined in my initial post, it'd be
> good to provide one on all platforms.
Sorry, but can you elaborate? I can't see any need with the above
reasoning. I managed to find your original post (amazingly hard when
you're in digest mode and the post has an empty subject!) and I think
the responses in this thread have demonstrated that there is no need
for a libpq_r.so, but there is need for a libecpg_r.so
I guess we're going to have get down to the code level to demonstrate
this! If you compile a example library with _REENTRANT and use _r
functions and the function version of errno then it can be used no
problem by a library compiled without _REENTRANT and expecting errno
to be an int...
Unfortunately i'm leaving on holiday tonight until Monday so will not
be able to get the example done...
Regards, Lee.
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 16:46 Rod Taylor <rbt@rbt.ca>
parent: Lee Kindness <lkindness@csl.co.uk>
0 siblings, 0 replies; 28+ messages in thread
From: Rod Taylor @ 2003-07-24 16:46 UTC (permalink / raw)
To: Lee Kindness <lkindness@csl.co.uk>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-hackers
> Better remove transactions then, yeah? Performace hit! Profile it and
> see how minor (or likely non-existent) it is...
You can do that. Turn fsync to off and you remove a large majority of
the transaction hit, but I understand what you're saying.
Attachments:
[application/pgp-signature] signature.asc (186B, ../../1059065201.27353.21.camel@jester/2-signature.asc)
download
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 20:30 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Peter Eisentraut <peter_e@gmx.net>
1 sibling, 2 replies; 28+ messages in thread
From: Bruce Momjian @ 2003-07-24 20:30 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Larry Rosenman <ler@lerctr.org>; Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Peter Eisentraut wrote:
> Larry Rosenman writes:
>
> > I beg to differ. Explicitly, on UnixWare, the <errno.h> header,
> > reproduced below, under fair use, show an EXPLICIT difference in what
> > happens with _REENTRANT:
>
> Hmm, I was too optimistic. I guess we'll just have to handcraft a
> different solution for each platform. But clearly on some platforms we'll
> need a libpq_r, so for the reasons I outlined in my initial post, it'd be
> good to provide one on all platforms.
I still think it is confusing to create a libpq_r on platforms that have
no _r libraries. I am on BSD/OS and I can find only _r library on my
entire system, and guess who make that one:
/usr/contrib/lib/mysql/libmysqlclient_r.a
and they actually have two different libraries:
-rwxr-xr-x 1 root wheel 127413 Jun 5 2001 /usr/contrib/lib/mysql/libmysqlclient.so.10.0.0*
-rwxr-xr-x 1 root wheel 144471 Jun 5 2001 /usr/contrib/lib/mysql/libmysqlclient_r.so.10.0.0*
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-24 20:35 Larry Rosenman <ler@lerctr.org>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 0 replies; 28+ messages in thread
From: Larry Rosenman @ 2003-07-24 20:35 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; Peter Eisentraut <peter_e@gmx.net>; +Cc: Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
--On Thursday, July 24, 2003 16:30:14 -0400 Bruce Momjian
<pgman@candle.pha.pa.us> wrote:
> Peter Eisentraut wrote:
>> Larry Rosenman writes:
>>
>> > I beg to differ. Explicitly, on UnixWare, the <errno.h> header,
>> > reproduced below, under fair use, show an EXPLICIT difference in what
>> > happens with _REENTRANT:
>>
>> Hmm, I was too optimistic. I guess we'll just have to handcraft a
>> different solution for each platform. But clearly on some platforms
>> we'll need a libpq_r, so for the reasons I outlined in my initial post,
>> it'd be good to provide one on all platforms.
>
> I still think it is confusing to create a libpq_r on platforms that have
> no _r libraries. I am on BSD/OS and I can find only _r library on my
> entire system, and guess who make that one:
>
> /usr/contrib/lib/mysql/libmysqlclient_r.a
>
> and they actually have two different libraries:
>
> -rwxr-xr-x 1 root wheel 127413 Jun 5 2001
> /usr/contrib/lib/mysql/libmysqlclient.so.10.0.0* -rwxr-xr-x 1 root
> wheel 144471 Jun 5 2001
> /usr/contrib/lib/mysql/libmysqlclient_r.so.10.0.0*
I think it needs to be a port/platform by port/platform decision.
I DO think we need to -D_REENTRANT on those platforms that we can to allow
libpq's use in threaded programs.
LER
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 09:19 Larry Rosenman <ler@lerctr.org>
parent: Peter Eisentraut <peter_e@gmx.net>
2 siblings, 1 reply; 28+ messages in thread
From: Larry Rosenman @ 2003-07-25 09:19 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; Bruce Momjian <pgman@candle.pha.pa.us>; jkj@sco.com; +Cc: Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
--On Friday, July 25, 2003 11:23:05 +0200 Peter Eisentraut
<peter_e@gmx.net> wrote:
> Bruce Momjian writes:
>
>> I still think it is confusing to create a libpq_r on platforms that have
>> no _r libraries. I am on BSD/OS and I can find only _r library on my
>> entire system,
>
> The criterion is not whether the platform has _r libraries, it's whether
> special actions are required in order to make a library fit for threaded
> programs, at the time that library is built. Such special actions may
> include:
>
> 1. need to link in special libc_r (FreeBSD)
> 2. need to use magic flags for compiler and/or linker (FreeBSD, UnixWare)
> 3. need to compile with special preprocessor symbols (UnixWare, AIX)
> 4. need to use different compiler altogether (AIX)
>
> (If you read between the lines of the manufacturers' documentation, all
> these methods end up accomplishing similar things, they are only different
> interfaces for it.)
The -D_REENTRANT causes NO pain, and makes it possible to have ONE library
for UnixWare.
the -K[p]thread issue is for EXECUTABLES to cause the libthread library to
be invoked
at PROCESS startup.
I feel that libpq should be compiled with -D_REENTRANT, and we have ONE copy
of it on UnixWare.
>
> If any of these cases apply, we need to provide a separate libpq_r, or
> else either threaded land or nonthreaded land will suffer pain, from what
> I read. (The simplest example is errno being defined in different ways
> and referring to different symbols.)
>
> If none of these cases apply, then a separate libpq_r will be redundant,
> perhaps "confusing" to some, but it can be ignored by the user.
see my above comments.
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 09:23 Peter Eisentraut <peter_e@gmx.net>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 3 replies; 28+ messages in thread
From: Peter Eisentraut @ 2003-07-25 09:23 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Larry Rosenman <ler@lerctr.org>; Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Bruce Momjian writes:
> I still think it is confusing to create a libpq_r on platforms that have
> no _r libraries. I am on BSD/OS and I can find only _r library on my
> entire system,
The criterion is not whether the platform has _r libraries, it's whether
special actions are required in order to make a library fit for threaded
programs, at the time that library is built. Such special actions may
include:
1. need to link in special libc_r (FreeBSD)
2. need to use magic flags for compiler and/or linker (FreeBSD, UnixWare)
3. need to compile with special preprocessor symbols (UnixWare, AIX)
4. need to use different compiler altogether (AIX)
(If you read between the lines of the manufacturers' documentation, all
these methods end up accomplishing similar things, they are only different
interfaces for it.)
If any of these cases apply, we need to provide a separate libpq_r, or
else either threaded land or nonthreaded land will suffer pain, from what
I read. (The simplest example is errno being defined in different ways
and referring to different symbols.)
If none of these cases apply, then a separate libpq_r will be redundant,
perhaps "confusing" to some, but it can be ignored by the user.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 09:47 Larry Rosenman <ler@lerctr.org>
parent: Peter Eisentraut <peter_e@gmx.net>
0 siblings, 0 replies; 28+ messages in thread
From: Larry Rosenman @ 2003-07-25 09:47 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; jkj@sco.com, Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
--On Friday, July 25, 2003 11:51:50 +0200 Peter Eisentraut
<peter_e@gmx.net> wrote:
> Larry Rosenman writes:
>
>> The -D_REENTRANT causes NO pain, and makes it possible to have ONE
>> library for UnixWare.
>
> Didn't you just say that -D_REENTRANT changes the definition of errno on
> your system? Surely it would not be a good idea to link a libpq that uses
> variant 1 with a program that uses variant 2. Maybe I'm wrong and you can
> do that, but it sounds problematic to me.
Yes, it DOES change errno, but it is **NOT** problematic. the static int
is there
ONLY FOR THE FIRST LWP (thread) of a process. The reentrant version
accesses the same
information for ANY LWP. the first LWP can also use it for getting access.
It is SAFER to use the reentrant version, so that if a THREADED program
uses libpq,
we are now thread-safe.
LER
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 09:51 Peter Eisentraut <peter_e@gmx.net>
parent: Larry Rosenman <ler@lerctr.org>
0 siblings, 1 reply; 28+ messages in thread
From: Peter Eisentraut @ 2003-07-25 09:51 UTC (permalink / raw)
To: Larry Rosenman <ler@lerctr.org>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; jkj@sco.com, Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Larry Rosenman writes:
> The -D_REENTRANT causes NO pain, and makes it possible to have ONE library
> for UnixWare.
Didn't you just say that -D_REENTRANT changes the definition of errno on
your system? Surely it would not be a good idea to link a libpq that uses
variant 1 with a program that uses variant 2. Maybe I'm wrong and you can
do that, but it sounds problematic to me.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 15:35 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Peter Eisentraut <peter_e@gmx.net>
2 siblings, 0 replies; 28+ messages in thread
From: Bruce Momjian @ 2003-07-25 15:35 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Larry Rosenman <ler@lerctr.org>; Lee Kindness <lkindness@csl.co.uk>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
Peter Eisentraut wrote:
> Bruce Momjian writes:
> 1. need to link in special libc_r (FreeBSD)
> 2. need to use magic flags for compiler and/or linker (FreeBSD, UnixWare)
> 3. need to compile with special preprocessor symbols (UnixWare, AIX)
> 4. need to use different compiler altogether (AIX)
>
> (If you read between the lines of the manufacturers' documentation, all
> these methods end up accomplishing similar things, they are only different
> interfaces for it.)
>
> If any of these cases apply, we need to provide a separate libpq_r, or
> else either threaded land or nonthreaded land will suffer pain, from what
> I read. (The simplest example is errno being defined in different ways
> and referring to different symbols.)
>
> If none of these cases apply, then a separate libpq_r will be redundant,
> perhaps "confusing" to some, but it can be ignored by the user.
I see no reason to symlink to libpq_r if it is identical to libpq.
Operating systems are moving away from _r libraries, and I see no reason
to create one just for consistency with platforms that still use _r.
Basically, I don't like the confusion.
I agree with the goal of having a libpq_r if it is different from libpq.
This is going to require us to compile libpq twice and install libpq and
libpq_r. Can that be done cleanly? I don't see how we can get this
done before beta. Will we fiddle with this during beta?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 22:20 Greg Stark <gsstark@mit.edu>
parent: Peter Eisentraut <peter_e@gmx.net>
2 siblings, 1 reply; 28+ messages in thread
From: Greg Stark @ 2003-07-25 22:20 UTC (permalink / raw)
To: pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> Bruce Momjian writes:
>
> > I still think it is confusing to create a libpq_r on platforms that have
> > no _r libraries. I am on BSD/OS and I can find only _r library on my
> > entire system,
>
> The criterion is not whether the platform has _r libraries, it's whether
> special actions are required in order to make a library fit for threaded
> programs, at the time that library is built. Such special actions may
> include:
No, there's one more criterion: And those special actions make the library
unsuitable for use in programs not compiled to use threads.
For example, on Debian *all* libraries are compiled with -D_REENTANT -fPIC.
Anything else would be a major headache for the distribution.
It causes a 3-5% performance drop on i386 and much less on other
architectures. However then all libraries are suitable for use in both
threaded and non-threaded applications.
There may still be some architectures out there where two versions are needed.
But I'm not aware of any.
--
greg
^ permalink raw reply [nested|flat] 28+ messages in thread
* Re: libpq_r
@ 2003-07-25 22:26 Larry Rosenman <ler@lerctr.org>
parent: Greg Stark <gsstark@mit.edu>
0 siblings, 0 replies; 28+ messages in thread
From: Larry Rosenman @ 2003-07-25 22:26 UTC (permalink / raw)
To: Greg Stark <gsstark@mit.edu>; pgsql-hackers
--On Friday, July 25, 2003 18:20:10 -0400 Greg Stark <gsstark@mit.edu>
wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
>
>> Bruce Momjian writes:
>>
>> > I still think it is confusing to create a libpq_r on platforms that
>> > have no _r libraries. I am on BSD/OS and I can find only _r library
>> > on my entire system,
>>
>> The criterion is not whether the platform has _r libraries, it's whether
>> special actions are required in order to make a library fit for threaded
>> programs, at the time that library is built. Such special actions may
>> include:
>
> No, there's one more criterion: And those special actions make the library
> unsuitable for use in programs not compiled to use threads.
>
> For example, on Debian *all* libraries are compiled with -D_REENTANT
> -fPIC. Anything else would be a major headache for the distribution.
This, I believe, is the same situation for UnixWare.
>
> It causes a 3-5% performance drop on i386 and much less on other
> architectures. However then all libraries are suitable for use in both
> threaded and non-threaded applications.
>
> There may still be some architectures out there where two versions are
> needed. But I'm not aware of any.
I believe that FreeBSD still needs 2, but there are 3 different threading
libs at
the moment on 5.x, and 4.x still has _r libs.
LER
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 28+ messages in thread
end of thread, other threads:[~2003-07-25 22:26 UTC | newest]
Thread overview: 28+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-24 08:22 libpq_r Lee Kindness <lkindness@csl.co.uk>
2003-07-24 12:52 ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-24 13:09 ` Larry Rosenman <ler@lerctr.org>
2003-07-24 13:12 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 14:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-07-24 14:32 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 14:44 ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-24 14:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-07-24 14:51 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 16:46 ` Rod Taylor <rbt@rbt.ca>
2003-07-24 14:55 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 15:21 ` Peter Eisentraut <peter_e@gmx.net>
2003-07-24 15:18 ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-24 15:29 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 15:30 ` Larry Rosenman <ler@lerctr.org>
2003-07-24 16:00 ` Peter Eisentraut <peter_e@gmx.net>
2003-07-24 16:08 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 20:30 ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-24 20:35 ` Larry Rosenman <ler@lerctr.org>
2003-07-25 09:23 ` Peter Eisentraut <peter_e@gmx.net>
2003-07-25 09:19 ` Larry Rosenman <ler@lerctr.org>
2003-07-25 09:51 ` Peter Eisentraut <peter_e@gmx.net>
2003-07-25 09:47 ` Larry Rosenman <ler@lerctr.org>
2003-07-25 15:35 ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-25 22:20 ` Greg Stark <gsstark@mit.edu>
2003-07-25 22:26 ` Larry Rosenman <ler@lerctr.org>
2003-07-24 14:45 ` Lee Kindness <lkindness@csl.co.uk>
2003-07-24 14:04 ` Peter Eisentraut <peter_e@gmx.net>
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