Re: Wierd context-switching issue on Xeon patch for 7.4.1

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pg(at)fastcrypt(dot)com, Josh Berkus <josh(at)agliodbs(dot)com>, Paul Tuckfield <paul(at)tuckfield(dot)com>, Anjan Dave <adave(at)vantage(dot)com>, Neil Conway <neilc(at)samurai(dot)com>, Dirk Lutzebäck <lutzeb(at)aeccom(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1
Date: 2004-04-22 04:56:15
Message-ID: 200404220456.i3M4uFv04710@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Tom Lane wrote:
> Dave Cramer <pg(at)fastcrypt(dot)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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2004-04-22 05:13:47 Re: Wierd context-switching issue on Xeon patch for 7.4.1
Previous Message Christopher Kings-Lynne 2004-04-22 04:44:07 Re: Wierd context-switching issue on Xeon patch for 7.4.1