Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4C2091337B66 for ; Tue, 7 Dec 2010 13:50:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 84763-02 for ; Tue, 7 Dec 2010 17:50:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B43991337B5B for ; Tue, 7 Dec 2010 13:50:49 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id oB7Hoh1I024823; Tue, 7 Dec 2010 12:50:44 -0500 (EST) To: Robert Haas cc: Jignesh Shah , Ivan Voras , pgsql-performance@postgresql.org Subject: Re: Performance under contention In-reply-to: References: Comments: In-reply-to Robert Haas message dated "Tue, 07 Dec 2010 12:37:31 -0500" Date: Tue, 07 Dec 2010 12:50:43 -0500 Message-ID: <24822.1291744243@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/77 X-Sequence-Number: 41529 Robert Haas writes: > I wonder if it would be possible to have a very short critical section > where we grab the partition lock, acquire the heavyweight lock, and > release the partition lock; and then only as a second step record (in > the form of a PROCLOCK) the fact that we got it. [ confused... ] Exactly what do you suppose "acquire the lock" would be represented as, if not "create a PROCLOCK entry attached to it"? In any case, I think this is another example of not understanding where the costs really are. As far as I can tell, on modern MP systems much of the elapsed time in these operations comes from acquiring exclusive access to shared-memory cache lines. Reducing the number of changes you have to make within a small area of shared memory won't save much, once you've paid for the first one. Changing structures that aren't heavily contended (such as a proc's list of its own locks) doesn't cost much at all. One thing that might be interesting, but that I don't know how to attack in a reasonably machine-independent way, is to try to ensure that shared and local data structures don't accidentally overlap within cache lines. When they do, you pay for fighting the cache line away from another processor even when there's no real need. regards, tom lane