 
> NOTICE:  LockRelease: no such lock
> 
> I'm afraid now the locking is broken. Will look into more.

Next try would be _check_lock (found in sys/atomic_op.h):

Description (from man page)

The _check_lock subroutine performs an atomic (uninterruptible) sequence of
operations. The compare_and_swap subroutine is similar, but does not issue
synchronization instructions and therefore is inappropriate for updating lock
words.

replace the TAS define with:
#define TAS(lock)       _check_lock(lock, 0, 1)

> with LinuxPPC asm: 	2m9.340s
> with cs:			10m11.15s
> with fetch_and_or:	3m55.19s

with _check_lock:		3m29.990s

I think that the culprit may also be the S_UNLOCK (use _clear_lock) ?

Andreas

Tue, 15 Jan 2002 18:14:12 +0100
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>
Re: 7.1 vs. 7.2 on AIX 5L 
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes:
> I think that the culprit may also be the S_UNLOCK (use _clear_lock) ?

If isync is anything like the MB instruction on Alpha (ie, force memory
updates to occur before proceeding), then it must be used in S_UNLOCK
as well as S_LOCK.  All updates done within the spinlocked section must
reach memory before another processor is allowed to acquire the lock.

			regards, tom lane

Tue, 15 Jan 2002 12:34:24 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: 7.1 vs. 7.2 on AIX 5L 
> > NOTICE:  LockRelease: no such lock
> > 
> > I'm afraid now the locking is broken. Will look into more.
> 
> Next try would be _check_lock (found in sys/atomic_op.h):
> 
> Description (from man page)
> 
> The _check_lock subroutine performs an atomic (uninterruptible) sequence of
> operations. The compare_and_swap subroutine is similar, but does not issue
> synchronization instructions and therefore is inappropriate for updating lock
> words.
> 
> replace the TAS define with:
> #define TAS(lock)       _check_lock(lock, 0, 1)
> 
> > with LinuxPPC asm: 	2m9.340s
> > with cs:			10m11.15s
> > with fetch_and_or:	3m55.19s
> 
> with _check_lock:		3m29.990s
> 
> I think that the culprit may also be the S_UNLOCK (use _clear_lock) ?

Thanks. I will try with it.

BTW, I'm still wondering why 7.2 is slower than 7.1 on AIX. Tom said
cs() is responsible for that. But not only 7.2 but 7.1 uses cs(). It
seems cs() does not explain the difference of the performance.
--
Tatsuo Ishii

Wed, 16 Jan 2002 09:58:21 +0900
Tatsuo Ishii <t-ishii@sra.co.jp>
Re: 7.1 vs. 7.2 on AIX 5L 
> Thanks. I will try with it.
> 
> BTW, I'm still wondering why 7.2 is slower than 7.1 on AIX. Tom said
> cs() is responsible for that. But not only 7.2 but 7.1 uses cs(). It
> seems cs() does not explain the difference of the performance.

cs() may be used more heavily on 7.2 --- not sure.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 15 Jan 2002 21:15:33 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: 7.1 vs. 7.2 on AIX 5L
Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> BTW, I'm still wondering why 7.2 is slower than 7.1 on AIX. Tom said
>> cs() is responsible for that. But not only 7.2 but 7.1 uses cs(). It
>> seems cs() does not explain the difference of the performance.

> cs() may be used more heavily on 7.2 --- not sure.

Most of the places that were SpinLockAcquire ... SpinRelease on 7.1 are
now LWLockAcquire ... LWLockRelease on 7.2.  And each of LWLockAcquire
and LWLockRelease does a SpinLockAcquire + SpinRelease + some other
computation.  So there's no doubt that we expend more cycles; cycles
that are wasted in a pure-single-backend scenario.  However, if the
spinlock operations are as cheap as they should be, it's hard to believe
that the extra cost would be enough to notice.  And indeed we haven't
been able to measure any penalty on Linux, HPUX, nor BSD (right Bruce?).
So I'm still suspicious that our cs()-based spinlock for AIX is carrying
some unexpected cost.

			regards, tom lane

Wed, 16 Jan 2002 00:22:13 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: 7.1 vs. 7.2 on AIX 5L 
> that the extra cost would be enough to notice.  And indeed we haven't
> been able to measure any penalty on Linux, HPUX, nor BSD (right Bruce?).

Right.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 16 Jan 2002 00:23:37 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: 7.1 vs. 7.2 on AIX 5L

Added to TODO:

* Evaluate AIX cs() spinlock macro for performance optimizations (Tatsuo)

---------------------------------------------------------------------------

Tatsuo Ishii wrote:
> > > NOTICE:  LockRelease: no such lock
> > > 
> > > I'm afraid now the locking is broken. Will look into more.
> > 
> > Next try would be _check_lock (found in sys/atomic_op.h):
> > 
> > Description (from man page)
> > 
> > The _check_lock subroutine performs an atomic (uninterruptible) sequence of
> > operations. The compare_and_swap subroutine is similar, but does not issue
> > synchronization instructions and therefore is inappropriate for updating lock
> > words.
> > 
> > replace the TAS define with:
> > #define TAS(lock)       _check_lock(lock, 0, 1)
> > 
> > > with LinuxPPC asm: 	2m9.340s
> > > with cs:			10m11.15s
> > > with fetch_and_or:	3m55.19s
> > 
> > with _check_lock:		3m29.990s
> > 
> > I think that the culprit may also be the S_UNLOCK (use _clear_lock) ?
> 
> Thanks. I will try with it.
> 
> BTW, I'm still wondering why 7.2 is slower than 7.1 on AIX. Tom said
> cs() is responsible for that. But not only 7.2 but 7.1 uses cs(). It
> seems cs() does not explain the difference of the performance.
> --
> Tatsuo Ishii
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Thu, 24 Jan 2002 18:35:12 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: 7.1 vs. 7.2 on AIX 5L