Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9AFC0632DF6 for ; Sat, 21 Mar 2009 20:02:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 98696-06 for ; Sat, 21 Mar 2009 20:02:46 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) by mail.postgresql.org (Postfix) with ESMTP id DD436632678 for ; Sat, 21 Mar 2009 20:02:49 -0300 (ADT) Received: from fe-amer-09.sun.com ([192.18.109.79]) by brmea-mail-4.sun.com (8.13.6+Sun/8.12.9) with ESMTP id n2LN2mdB023847 for ; Sat, 21 Mar 2009 23:02:48 GMT MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; format=flowed; charset=ISO-8859-1 Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java(tm) System Messaging Server 7.0-5.01 64bit (built Feb 19 2009)) id <0KGV00B00P797W00@mail-amer.sun.com> for pgsql-performance@postgresql.org; Sat, 21 Mar 2009 17:02:48 -0600 (MDT) Received: from Macintosh-8.local ([unknown] [129.150.33.62]) by mail-amer.sun.com (Sun Java(tm) System Messaging Server 7.0-5.01 64bit (built Feb 19 2009)) with ESMTPSA id <0KGV007N9PCMPV10@mail-amer.sun.com>; Sat, 21 Mar 2009 17:02:47 -0600 (MDT) Date: Sat, 21 Mar 2009 19:02:46 -0400 From: "Jignesh K. Shah" Subject: Re: Proposal of tunable fix for scalability of 8.4 In-reply-to: <603c8f070903201745m575642f5s539e1a374ce4ce9f@mail.gmail.com> To: Robert Haas Cc: Alvaro Herrera , Scott Carey , Greg Smith , Kevin Grittner , "pgsql-performance@postgresql.org" Message-id: <49C57216.1050205@sun.com> References: <603c8f070903191349p5e8fb00as2816581d584fcefd@mail.gmail.com> <20090320154601.GC8313@alvh.no-ip.org> <20090320215813.GR8313@alvh.no-ip.org> <20090320220513.GS8313@alvh.no-ip.org> <49C42921.8050508@sun.com> <603c8f070903201745m575642f5s539e1a374ce4ce9f@mail.gmail.com> User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200903/316 X-Sequence-Number: 33238 Robert Haas wrote: > On Fri, Mar 20, 2009 at 7:39 PM, Jignesh K. Shah wrote: > >> Alvaro Herrera wrote: >> >>>> So Simon's correct. >>>> >>> And perhaps this explains why Jignesh is measuring an improvement on his >>> benchmark. Perhaps an useful experiment would be to turn this behavior >>> off and compare performance. This lack of measurement is probably the >>> cause that the suggested patch to fix it was never applied. >>> >>> The patch is here >>> http://archives.postgresql.org//pgsql-hackers/2004-11/msg00935.php >>> >> One of the reasons why my patch helps is it keeps this check intact but >> allows other exclusive Wake up.. Now what PostgreSQL calls "Wakes" is in >> reality just makes a variable indicating wake up and not really signalling a >> process to wake up. This is a key point to note. So when the process wanting >> the exclusive fights the OS Scheduling policy to finally get time on the CPU >> then it check the value to see if it is allowed to wake up and potentially >> > > I'm confused. Is a process waiting for an LWLock is in a runnable > state? I thought we went to sleep on a semaphore. > > ...Robert > > If you check the code http://doxygen.postgresql.org/lwlock_8c-source.html#l00451 Semaphore lock can wake up but then it needs to confirm !proc->lwWaiting which can be TRUE if you have not been "Waked up" then it increase the extraWaits count and go back to PGSemaphoreLock .. What my patch gives the flexibility with sequential X wakeups that it can still exit and check for getting the exclusive lock and if not add back to the queue. My theory is when it is already on CPU running makes sense to check for the lock if another exclusive is running since the chances are that it has completed within few cycles is very high.. and the improvement that I see leads to that inference. Otherwise if lwWaiting is TRUE then it does not even check if the lock is available or not and just goes back and waits for the next chance.. This is the part that gets the benefit of my patch. -Jignesh -- Jignesh Shah http://blogs.sun.com/jkshah The New Sun Microsystems,Inc http://sun.com/postgresql