From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pg@fastcrypt.com, Josh Berkus <josh@agliodbs.com>
Cc: Paul Tuckfield <paul@tuckfield.com>
Cc: Anjan Dave <adave@vantage.com>
Cc: Neil Conway <neilc@samurai.com>
Cc: Dirk Lutzebäck <lutzeb@aeccom.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1
Date: Thu, 22 Apr 2004 00:56:15 -0400 (EDT)
Message-ID: <200404220456.i3M4uFv04710@candle.pha.pa.us> (raw)
In-Reply-To: <19596.1082607804@sss.pgh.pa.us>
Tom Lane wrote:
> Dave Cramer <pg@fastcrypt.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: pgman@candle.pha.pa.us, tgl@sss.pgh.pa.us, josh@agliodbs.com, paul@tuckfield.com, adave@vantage.com, neilc@samurai.com, lutzeb@aeccom.com
Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1
In-Reply-To: <200404220456.i3M4uFv04710@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox