
> > With the new pgbench, I ran a test with current and 7.1 and saw
> > not-so-small differences. Any idea to get better performance on 7.2
> > and AIX 5L combo?
> 
> I'm thinking more and more that there must be something weird about the
> cs() routine that we use for spinlocks on AIX.  Could someone dig into
> that and find exactly what it does and whether it's got any performance
> issues?

The manual page sais:

    Note: The cs subroutine is only provided to support binary compatibility with
    AIX Version 3 applications. When writing new applications, it is not
    recommended to use this subroutine; it may cause reduced performance in the
    future. Applications should use the compare_and_swap subroutine, unless they
    need to use unaligned memory locations.

I once tried to replace cs() with compare_and_swap() but saw worse performance
for the limited testing I did (probably on a single CPU). Maybe the "threat"
that performance will be reduced is actually true on AIX 5 now.

The thing would imho now be for Tatsuo to try to replace cs with compare_and_swap,
and see what happens on AIX 5.

Andreas

PS: Would the __powerpc__ assembly work on AIX machines ?

Fri, 11 Jan 2002 09:16:29 +0100
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>
Re: 7.1 vs. 7.2 on AIX 5L 
> > I'm thinking more and more that there must be something weird about the
> > cs() routine that we use for spinlocks on AIX.  Could someone dig into
> > that and find exactly what it does and whether it's got any performance
> > issues?
> 
> The manual page sais:
> 
>     Note: The cs subroutine is only provided to support binary compatibility with
>     AIX Version 3 applications. When writing new applications, it is not
>     recommended to use this subroutine; it may cause reduced performance in the
>     future. Applications should use the compare_and_swap subroutine, unless they
>     need to use unaligned memory locations.
> 
> I once tried to replace cs() with compare_and_swap() but saw worse performance
> for the limited testing I did (probably on a single CPU). Maybe the "threat"
> that performance will be reduced is actually true on AIX 5 now.
> 
> The thing would imho now be for Tatsuo to try to replace cs with compare_and_swap,
> and see what happens on AIX 5.
> 
> Andreas
> 
> PS: Would the __powerpc__ assembly work on AIX machines ?
> 

I wish I could do that but...

 From the manual page of compare_and_swap (see below):

What I'm not sure is this part:

> Note If compare_and_swap is used as a locking primitive, insert an
> isync at the start of any critical sections;

What is "isync"? Also, how I can implement calling compare_and_swap in
the assembly language?
--
Tatsuo Ishii

-----------------------------------------------------------------------
boolean_t compare_and_swap ( word_addr, old_val_addr, new_val)

atomic_p word_addr;

int *old_val_addr;

int new_val;

Description

The compare_and_swap subroutine performs an atomic operation which compares
the contents of a single word variable with a stored old value; If the
values are equal, a new value is stored in the single word variable and TRUE
is returned; otherwise, the old value is set to the current value of the
single word variable and FALSE is returned;

The compare_and_swap subroutine is useful when a word value must be updated
only if it has not been changed since it was last read;

    Note The word containing the single word variable must be aligned on
    a full word boundary

    Note If compare_and_swap is used as a locking primitive, insert an
 isync at the start of any critical sections;

Parameters

word_addr Specifies the address of the single word variable&#46;

old_val_addr Specifies the address of the old value to be checked against
(and conditionally updated with) the value of the single word variable&#46;

new_val Specifies the new value to be conditionally assigned to the single
word variable&#46;

Return Values

TRUE Indicates that the single word variable was equal to the old value, and
has been set to the new value&#46;

FALSE Indicates that the single word variable was not equal to the old value,
and that its current value has been returned in the location where the old
value was previously stored&#46;

Implementation Specifics

Implementation Specifics

The compare_and_swap subroutine is part of the Base Operating System (BOS)
Runtime

Related Information

The fetch_and_add (fetch_and_add Subroutine) subroutine, fetch_and_and
(fetch_and_and or fetch_and_or Subroutine) subroutine, fetch_and_or
(fetch_and_and or fetch_and_or Subroutine) subroutine&#46;


Fri, 11 Jan 2002 17:28:01 +0900
Tatsuo Ishii <t-ishii@sra.co.jp>
Re: 7.1 vs. 7.2 on AIX 5L 
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> [ compare_and_swap man page ]

Looks kinda baroque.  What about the referenced fetch_and_or routine?
If that's atomic it might be closer to TAS semantics.

			regards, tom lane

Fri, 11 Jan 2002 12:14:01 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: 7.1 vs. 7.2 on AIX 5L 