Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id EA7CE633155 for ; Sat, 14 Mar 2009 05:24:07 -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 33682-06 for ; Sat, 14 Mar 2009 05:24:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og112.obsmtp.com (exprod7og112.obsmtp.com [64.18.2.177]) by mail.postgresql.org (Postfix) with SMTP id 059EE632E83 for ; Sat, 14 Mar 2009 05:24:02 -0300 (ADT) Received: from source ([209.85.219.162]) by exprod7ob112.postini.com ([64.18.6.12]) with SMTP ID DSNKSbtpoFpSSJ0KY7jGwvMSkc3cUgPfYWnU@postini.com; Sat, 14 Mar 2009 01:24:03 PDT Received: by ewy6 with SMTP id 6so3169017ewy.6 for ; Sat, 14 Mar 2009 01:23:59 -0700 (PDT) Received: by 10.216.8.65 with SMTP id 43mr1051637weq.168.1237019039447; Sat, 14 Mar 2009 01:23:59 -0700 (PDT) Received: from ?80.223.212.7? (dsl-hkibrasgw2-fed4df00-7.dhcp.inet.fi [80.223.212.7]) by mx.google.com with ESMTPS id i4sm4926986nfh.19.2009.03.14.01.23.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 14 Mar 2009 01:23:58 -0700 (PDT) Message-ID: <49BB699D.1070809@enterprisedb.com> Date: Sat, 14 Mar 2009 10:23:57 +0200 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Tom Lane CC: Robert Haas , Scott Carey , Greg Smith , "Jignesh K. Shah" , Kevin Grittner , "pgsql-performance@postgresql.org" Subject: Re: Proposal of tunable fix for scalability of 8.4 References: <603c8f070903121829r31cf1472ha9876e5c480a542e@mail.gmail.com> <12292.1236964604@sss.pgh.pa.us> In-Reply-To: <12292.1236964604@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200903/186 X-Sequence-Number: 33108 Tom Lane wrote: > Robert Haas writes: >> I think that changing the locking behavior is attacking the problem at >> the wrong level anyway. > > Right. By the time a patch here could have any effect, you've already > lost the game --- having to deschedule and reschedule a process is a > large cost compared to the typical lock hold time for most LWLocks. So > it would be better to look at how to avoid blocking in the first place. I think the elephant in the room is that we have a single lock that needs to be acquired every time a transaction commits, and every time a backend takes a snapshot. It has worked well, and it still does for smaller numbers of CPUs, but I'm not surprised it starts to become a bottleneck on a test like the one Jignesh is running. To make matters worse, the more backends there are, the longer the lock needs to be held to take a snapshot. It's going require some hard thinking to bust that bottleneck. I've sometimes thought about maintaining a pre-calculated array of in-progress XIDs in shared memory. GetSnapshotData would simply memcpy() that to private memory, instead of collecting the xids from ProcArray. Or we could try to move some of the if-tests inside the for-loop to after the ProcArrayLock is released. For example, we could easily remove the check for "proc == MyProc", and remove our own xid from the array afterwards. That's just linear speed up, though. I can't immediately think of a way to completely avoid / partition away the contention. WALInsertLock is also quite high on Jignesh's list. That I've seen become the bottleneck on other tests too. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com