X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 2F51CD1C935 for ; Tue, 22 Jul 2003 15:26:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 28920-10 for ; Tue, 22 Jul 2003 15:26:05 +0000 (GMT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 8BF49D1C93A for ; Tue, 22 Jul 2003 12:26:03 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h6MFVT2J016202 for ; Tue, 22 Jul 2003 21:01:29 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) (authenticated bits=0) by persistent.co.in (8.12.9/8.12.9) with ESMTP id h6MFVSsW016189 for ; Tue, 22 Jul 2003 21:01:28 +0530 From: "Shridhar Daithankar" To: PostgreSQL Development Date: Tue, 22 Jul 2003 20:57:45 +0530 MIME-Version: 1.0 Subject: Re: Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3F1DA549.20040.49B0FD@localhost> In-reply-to: X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/564 X-Sequence-Number: 41169 On 22 Jul 2003 at 16:55, Peter Eisentraut wrote: > I've been thinking some about how exactly to provide the new option of > thread-safe clients (libpq, ecpg). Let me state the following goals: > > a. Thread-safeness, where it makes a difference, is generally thought to > be a performance hit, so the user needs to have a choice to use > thread-safe libraries or not. On linux and freeBSD, that is not an issue. I can attest that from my experiments with a webserver. Thread function calls often time less than or of the order of 1us even with CPU capped. I would really like to know for what platforms, locking mutex while selecting from connection list or some such object, is going to be such a great performance hit. Performance degradation in threaded programs comes from contentions. It goes for frequency of contention and number of threads fighting over it. I doubt any threaded ecpg program would reach that level of contention anytime. If a lock canbe obtained/released in less than 10us and subsequent database query is going to take at least a ms, IMO that performance degradation is not worth that much trouble. But that is for linux and freeBSD. What other platforms have serious thread issues? > Clearly, a thread-safe ecpg library is always going to be significantly > different from the "normal" one, with all the mutex things that get pulled > in, so it seems reasonable to always offer a libecpg_r alongside the > libecpg. I would say, it should be thread-safe by default. No point polluting possible linkages. 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. Just a thought.. Bye Shridhar -- 2180, U.S. History question: What 20th Century U.S. President was almost impeached and what office did he later hold?