X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 90717D1CCD5 for ; Wed, 21 Apr 2004 19:02:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54475-08 for ; Wed, 21 Apr 2004 19:02:36 -0300 (ADT) Received: from is.rice.edu (is.rice.edu [128.42.42.24]) by svr1.postgresql.org (Postfix) with ESMTP id ADB76D1CCCA for ; Wed, 21 Apr 2004 19:02:33 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by localhost.is.rice.edu (Postfix) with ESMTP id 24C7B4190C; Wed, 21 Apr 2004 17:02:36 -0500 (CDT) Received: from is.rice.edu ([127.0.0.1]) by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 25811-10; Wed, 21 Apr 2004 17:02:32 -0500 (CDT) Received: by is.rice.edu (Postfix, from userid 18612) id 4F31F4196A; Wed, 21 Apr 2004 17:02:32 -0500 (CDT) Date: Wed, 21 Apr 2004 17:02:31 -0500 From: Kenneth Marshall To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Wierd context-switching issue on Xeon Message-ID: <20040421220231.GA18010@it.is.rice.edu> References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> <200404200959.52813.josh@agliodbs.com> <1082515263.1558.214.camel@localhost.localdomain> <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> <14264.1082573491@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14264.1082573491@sss.pgh.pa.us> User-Agent: Mutt/1.4.2i X-Virus-Scanned: by amavis-20030314-p2 at is.rice.edu X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/441 X-Sequence-Number: 6741 On Wed, Apr 21, 2004 at 02:51:31PM -0400, Tom Lane wrote: > The context swap storm is happening because of contention at the next > level up (LWLocks rather than spinlocks). It could be an independent > issue that just happens to be triggered by the same sort of access > pattern. I put forward a hypothesis that the cache miss storm caused by > the test-and-set ops induces the context swap storm by making the code > more likely to be executing in certain places at certain times ... but > it's only a hypothesis. > If the context swap storm derives from LWLock contention, maybe using a random order to assign buffer locks in buf_init.c would prevent simple adjacency of buffer allocation to cause the storm. Just offsetting the assignment by the cacheline size should work. I notice that when initializing the buffers in shared memory, both the buf->meta_data_lock and the buf->cntx_lock are immediately adjacent in memory. I am not familiar enough with the flow through postgres to see if there could be "fighting" for those two locks. If so, offsetting those by the cache line size would also stop the context swap storm. --Ken