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 623EED1B560 for ; Thu, 22 Apr 2004 09:36:34 -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 31012-05 for ; Thu, 22 Apr 2004 09:36:34 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id EA8A2D1B43A for ; Thu, 22 Apr 2004 09:36:30 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3MCaTOc025059; Thu, 22 Apr 2004 08:36:29 -0400 (EDT) To: pg@fastcrypt.com Cc: Paul Tuckfield , Anjan Dave , Josh Berkus , Neil Conway , Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , pgsql-performance@postgresql.org Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 In-reply-to: <1082603201.1556.272.camel@localhost.localdomain> 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> <1082574808.1558.243.camel@localhost.localdomain> <1082580588.13371.260.camel@localhost.localdomain> <18322.1082601330@sss.pgh.pa.us> <1082603201.1556.272.camel@localhost.localdomain> Comments: In-reply-to Dave Cramer message dated "Wed, 21 Apr 2004 23:06:41 -0400" Date: Thu, 22 Apr 2004 08:36:28 -0400 Message-ID: <25058.1082637388@sss.pgh.pa.us> From: Tom Lane 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/377 X-Sequence-Number: 6677 Dave Cramer writes: > My hypothesis is that if you spin approximately the same or more time > than the average time it takes to get finished with the shared resource > then this should reduce cs. The only thing we use spinlocks for nowadays is to protect LWLocks, so the "average time" involved is fairly small and stable --- or at least that was the design intention. What we seem to be seeing is that on SMP machines, cache coherency issues cause the TAS step itself to be expensive and variable. However, in the experiments I did, strace'ing showed that actual spin timeouts (manifested by the execution of a delaying select()) weren't actually that common; the big source of context switches is semop(), which indicates contention at the LWLock level rather than the spinlock level. So while tuning the spinlock limit count might be a useful thing to do in general, I think it will have only negligible impact on the particular problems we're discussing in this thread. regards, tom lane