[PATCHES] [PATCH] fix libpq mutex initialization for multithreaded win32 libs

2004-06-30 Thread Manfred Spraul
Hi, win32 doesn't support a static initializer for mutexes, thus the first user must initialize the lock. The problem are concurrent first users - the pthread_mutex_t initialization must be synchronized. The current implementation is broken, the attached patches fixes that: mutex_initlock is a

[PATCHES] [PATCH] s_lock support for win32

2004-06-30 Thread Manfred Spraul
Hi, The win32 port doesn't have a native user space spinlock implementation yet. Attached is an untested patch - could someone test it? I don't have Visual C++. -- Manfred Index: src/include/storage/s_lock.h === RCS file:

Re: [PATCHES] Compiling libpq with VisualC

2004-06-11 Thread Manfred Spraul
Andreas Pflug wrote: I don't really think so. That mutex_initialized is a globally static variable, not a thread local one. Thread interruption between testing mutex_initialized and setting it is very unlikely and still wouldn't do much harm if it actually does happen. Very unlikely is not a

Re: [PATCHES] Compiling libpq with VisualC

2004-06-11 Thread Manfred Spraul
Andreas Pflug wrote: Bruce Momjian wrote: Agreed. My pthread book says pthread_mutex_init() should be called only once, and we have to guarantee that. If the Windows implentation allows it to be called multiple times, just create a function to be called only by Win32 that does that and leave

Re: [PATCHES] Libpq ssl fix

2004-05-28 Thread Manfred Spraul
on failure, which will be interpreted just the other way round in initialize_SSL. Patch appended. Hmm, that looks backwards to me too, but this would seem to imply that Manfred Spraul failed to test his last patch at all. Manfred, care to explain why we shouldn't revert that patch in toto

Re: [PATCHES] Libpq ssl fix

2004-05-28 Thread Manfred Spraul
Bruce Momjian wrote: - patch for thread_test.c needed posted some hours ago. Applied. The current CVS tree work again, Andreas' patch fixed the configure failure. Additionally Andreas' libpq patch fixes ssl. I've tested the locking, too: ssl calls pq_lockingcallback. I've tested it by

Re: [PATCHES] [HACKERS] libpq thread safety

2004-03-21 Thread Manfred Spraul
Bruce Momjian wrote: I could not get this patch to compile. I am getting a failure because BSD/OS doesn't have pthread_rwlock_wrlock(). I am concerned other platforms might not have it either. I feared that. I'll switch to pthread_mutex_lock()+_unlock(). pthread_rwlock_wrlock()+_unlock was

Re: [PATCHES] SIGPIPE handling

2004-01-07 Thread Manfred Spraul
Bruce Momjian wrote: + /* +* We could lose a signal during this test. +* In a multi-threaded application, this might +* be a problem. Do any non-threaded platforms Threaded or non-threaded? +* lack sigaction()? +*/ Additionally, the

Re: [PATCHES] update i386 spinlock for hyperthreading

2003-12-29 Thread Manfred Spraul
Tom Lane wrote: Is there an easy way find out which LWLock is contended? Not from oprofile output, as far as I can think. I've suspected for some time that the BufMgrLock is a major bottleneck, but have no proof. Mark ran a DBT-2 testrun with the attached statistics patch applied: It

Re: [PATCHES] update i386 spinlock for hyperthreading

2003-12-27 Thread Manfred Spraul
Tom Lane wrote: Manfred Spraul [EMAIL PROTECTED] writes: Tom Lane wrote: Don't you have to put it in a specific place in the loop to make that work? If not, why not? Rep;nop is just a short delay - that's all. That view seems to me to be directly contradicted

Re: [PATCHES] update i386 spinlock for hyperthreading

2003-12-27 Thread Manfred Spraul
Tom Lane wrote: Anyway, I've committed your patch with some changes. Thanks. BTW, I noticed a lot of concern in the Intel app notes about reserving 64 or even 128 bytes for each spinlock to avoid cache line conflicts. That seems excessive to me (we use a lot of spinlocks for buffers), but

Re: [PATCHES] update i386 spinlock for hyperthreading

2003-12-26 Thread Manfred Spraul
Tom Lane wrote: Manfred Spraul [EMAIL PROTECTED] writes: Intel recommends to add a special pause instruction into spinlock busy loops. It's necessary for hyperthreading - without it, the cpu can't figure out that a logical thread does no useful work and incorrectly awards lots of execution

Re: [pgsql-hackers-win32] [PATCHES] SRA Win32 sync() code

2003-11-19 Thread Manfred Spraul
Shridhar Daithankar wrote: Does 30% difference above count as significant? No. It's Linux, we can look at the sources: there is no per-fd cache, the page cache is global. Thus fsync() syncs the whole cache to disk. A problem could only occur if the file cache is not global - perhaps a

Re: [PATCHES] initdb copyright notice

2003-11-17 Thread Manfred Spraul
Neil Conway wrote: A quick grep of the source tree indicates that the following files claim to be covered by the 4 clause BSD license: $ grep -rlI 'This product includes software developed' * contrib/mysql/my2pg.pl contrib/pgcrypto/README.pgcrypto contrib/pgcrypto/blf.c You must be careful

[PATCHES] SIGPIPE handling

2003-11-16 Thread Manfred Spraul
Hi, attached is an update of my automatic sigaction patch: I've moved the actual sigaction calls into pqsignal.c and added a helper function (pgsignalinquire(signo)). I couldn't remove the include signal.h from fe-connect.c: it's required for the SIGPIPE definition. Additionally I've added a

Re: [PATCHES] SRA Win32 sync() code

2003-11-16 Thread Manfred Spraul
Tom Lane wrote: Seriously though, if we can move the bulk of the writing work into background processes then I don't believe that there will be any significant penalty for regular backends. And I believe that it would be a huge advantage from a correctness point of view if we could stop

Re: [PATCHES] SIGPIPE handling

2003-11-16 Thread Manfred Spraul
Bruce Momjian wrote: I thought it should be global too, basically testing on the first connection request. What if two PQconnect calls happen at the same time? I would really prefer the manual approach with a new PQsetsighandler function - the autodetection is fragile, it's trivial to find a

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Manfred Spraul
Tom Lane wrote: I don't think we need to complicate pqsignal's API for this. Instead we'd better document that SIGPIPE handling has to be set up and kept stable before doing any libpq operations in a multithread app. Not reliable. An app could install it's own signal handler and block SIGPIPE

[PATCHES] sigpipe handling

2003-11-08 Thread Manfred Spraul
Attatched is the latest version of my patch that makes the signal(SIG_PIPE, SIG_IGN) calls around the send() syscall conditional: they are not sufficient to ensure that multithreaded libpq users are not killed by SIGPIPE signals, and they cause a noticable slowdown. I've switched to a global

[PATCHES] SIGPIPE handling, take two.

2003-11-02 Thread Manfred Spraul
pqsecure_write tries to catch SIGPIPE signals generated by network disconnects by setting the signal handler to SIG_IGN. The current approach causes several problems: - it always sets SA_RESTART when it restores the old handler. - it's not reliable for multi threaded apps, because another thread

Re: [PATCHES] fix for strict-alias warnings

2003-10-14 Thread Manfred Spraul
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: Of course, the linux kernel is aimed at a limited set of compilers - as I understand it basically gcc although it has been made to build with Intel compilers icc once compiled the kernel. But they had to teach it quite a lots of

Re: [PATCHES] fix for strict-alias warnings

2003-10-14 Thread Manfred Spraul
Tom Lane wrote: Manfred Spraul [EMAIL PROTECTED] writes: After some massaging, I've succeeded in generating bad code using a slightly modified MemSetAligned macro (parameters -O2 -fstrict-aliasing): gcc pipelined the x*x around the memset. As I already explained, we do not care about

Re: [PATCHES] WIN32_CONSOLE usage

2003-09-11 Thread Manfred Spraul
Christoph Dalitz wrote: On Thu, 11 Sep 2003 20:51:24 +0200 Manfred Spraul [EMAIL PROTECTED] wrote: - OemToChar() and CharToOem() convert all console input/output. In the long run this might be the better solution, if it works entirely without user intervention. I'm not sure if it's possible

Re: [PATCHES] WIN32_CONSOLE usage

2003-09-11 Thread Manfred Spraul
Peter Eisentraut wrote: If you can detect that they are different, why can't you adjust the code page in that case only? What should we do if we detect that they differ: - set the console code page to the ansi code page. This has two drawbacks: It doesn't work with Indic, because Indic