Re: Improving spin-lock implementation on ARM. - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Improving spin-lock implementation on ARM.
Date
Msg-id 16697830-4e15-5b4e-9698-f5be30eec363@iki.fi
Whole thread Raw
In response to Improving spin-lock implementation on ARM.  (Krunal Bauskar <krunalbauskar@gmail.com>)
Responses Re: Improving spin-lock implementation on ARM.  (Alexander Korotkov <aekorotkov@gmail.com>)
Re: Improving spin-lock implementation on ARM.  (Krunal Bauskar <krunalbauskar@gmail.com>)
List pgsql-hackers
On 26/11/2020 06:30, Krunal Bauskar wrote:
> Improving spin-lock implementation on ARM.
> ------------------------------------------------------------
> 
> * Spin-Lock is known to have a significant effect on performance
>    with increasing scalability.
> 
> * Existing Spin-Lock implementation for ARM is sub-optimal due to
>    use of TAS (test and swap)
> 
> * TAS is implemented on ARM as load-store so even if the lock is not free,
>    store operation will execute to replace the same value.
>    This redundant operation (mainly store) is costly.
> 
> * CAS is implemented on ARM as load-check-store-check that means if the
>    lock is not free, check operation, post-load will cause the loop to
>    return there-by saving on costlier store operation. [1]

Can you add some code comments to explain that why CAS is cheaper than 
TAS on ARM?

Is there some official ARM documentation, like a programmer's reference 
manual or something like that, that would show a reference 
implementation of a spinlock on ARM? It would be good to refer to an 
authoritative source on this.

- Heikki



pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: [Proposal] Global temporary tables
Next
From: Magnus Hagander
Date:
Subject: Re: [Proposal] Global temporary tables