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 B907AD1D096 for ; Thu, 22 Apr 2004 01:56:31 -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 74325-04 for ; Thu, 22 Apr 2004 01:56:31 -0300 (ADT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 5FCE3D1D0B8 for ; Thu, 22 Apr 2004 01:56:29 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i3M4uFv04710; Thu, 22 Apr 2004 00:56:15 -0400 (EDT) From: Bruce Momjian Message-Id: <200404220456.i3M4uFv04710@candle.pha.pa.us> Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 In-Reply-To: <19596.1082607804@sss.pgh.pa.us> To: Tom Lane Date: Thu, 22 Apr 2004 00:56:15 -0400 (EDT) Cc: pg@fastcrypt.com, Josh Berkus , Paul Tuckfield , Anjan Dave , Neil Conway , =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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/371 X-Sequence-Number: 6671 Tom Lane wrote: > Dave Cramer writes: > > I tried increasing the NUM_SPINS to 1000 and it works better. > > Doesn't surprise me. The value of 100 is about right on the assumption > that the spinlock instruction per se is not too much more expensive than > any other instruction. What I was seeing from oprofile suggested that > the spinlock instruction cost about 100x more than an ordinary > instruction :-( ... so maybe 200 or so would be good on a Xeon. > > > This is certainly heading in the right direction ? Although it looks > > like it is highly dependent on the system you are running on. > > Yeah. I don't know a reasonable way to tune this number automatically > for particular systems ... but at the very least we'd need to find a way > to distinguish uniprocessor from multiprocessor, because on a > uniprocessor the optimal value is surely 1. Have you looked at the code pointed to by our TODO item: * Add code to detect an SMP machine and handle spinlocks accordingly from distributted.net, http://www1.distributed.net/source, in client/common/cpucheck.cpp For BSDOS it has: #if (CLIENT_OS == OS_FREEBSD) || (CLIENT_OS == OS_BSDOS) || \ (CLIENT_OS == OS_OPENBSD) || (CLIENT_OS == OS_NETBSD) { /* comment out if inappropriate for your *bsd - cyp (25/may/1999) */ int ncpus; size_t len = sizeof(ncpus); int mib[2]; mib[0] = CTL_HW; mib[1] = HW_NCPU; if (sysctl( &mib[0], 2, &ncpus, &len, NULL, 0 ) == 0) //if (sysctlbyname("hw.ncpu", &ncpus, &len, NULL, 0 ) == 0) cpucount = ncpus; } and I can confirm that on my computer it works: hw.ncpu = 2 -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073