Tom Lane wrote:
> Dave Cramer <[EMAIL PROTECTED]> 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
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to