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 CEE5AD1B44F for ; Thu, 22 Apr 2004 02:13:57 -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 75956-09 for ; Thu, 22 Apr 2004 02:13:57 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0F88AD1B441 for ; Thu, 22 Apr 2004 02:13:56 -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 i3M5Dl3J020172; Thu, 22 Apr 2004 01:13:47 -0400 (EDT) To: Bruce Momjian Cc: pg@fastcrypt.com, Josh Berkus , Paul Tuckfield , Anjan Dave , Neil Conway , =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , pgsql-performance@postgresql.org Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 In-reply-to: <200404220456.i3M4uFv04710@candle.pha.pa.us> References: <200404220456.i3M4uFv04710@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 22 Apr 2004 00:56:15 -0400" Date: Thu, 22 Apr 2004 01:13:47 -0400 Message-ID: <20171.1082610827@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/372 X-Sequence-Number: 6672 Bruce Momjian writes: > 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; > } Multiplied by how many platforms? Ewww... I was wondering about some sort of dynamic adaptation, roughly along the lines of "whenever a spin loop successfully gets the lock after spinning, decrease the allowed loop count by one; whenever we fail to get the lock after spinning, increase by 100; if the loop count reaches, say, 10000, decide we are on a uniprocessor and irreversibly set it to 1." As written this would tend to incur a select() delay once per hundred spinlock acquisitions, which is way too much, but I think we could make it work with a sufficiently slow adaptation rate. The tricky part is that a slow adaptation rate means we can't have every backend figuring this out for itself --- the right value would have to be maintained globally, and I'm not sure how to do that without adding a lot of overhead. regards, tom lane