[PATCH] Configure: Prefer gcc __atomic builtins instead of older __sync builtins

debayang.qdt debayang.qdt at qualcommdatacenter.com
Mon Dec 4 16:37:50 UTC 2017


Hello,

For some architectures like armv8a  - newer GCC generates a full barrier for the __sync operations compared to the __atomics .

This is seen to give some performance lag on these architectures when using __sync compared to the atomics apis under high contention.

The C++ atomic ops looks good as well (http://mailman.nginx.org/pipermail/nginx-devel/2016-September/008805.html), 
However I would like to test it out and confirm.

e.g   sync_fetch_add with newer GCC:

  58:   f94007e0        ldr     x0, [sp,#8]
  5c:   c85f7c01         ldxr    x1, [x0]
  60:   91000821        add     x1, x1, #0x2
  64:   c802fc01         stlxr   w2, x1, [x0]
  68:   35ffffa2           cbnz    w2, 5c <testing+0xc>
  6c:   d5033bbf        dmb     ish   

With atomics_fetch_add  with SEQ_CST:

  58:   f94007e0        ldr     x0, [sp,#8]
  5c:   c85ffc01          ldaxr   x1, [x0]
  60:   91000821       add     x1, x1, #0x2
  64:   c802fc01        stlxr   w2, x1, [x0]
  68:   35ffffa2          cbnz    w2, 5c <testing+0xc>

Thanks
Debayan


-----Original Message-----
From: Maxim Dounin [mailto:mdounin at mdounin.ru] 
Sent: Monday, December 4, 2017 8:35 PM
To: nginx-devel at nginx.org
Cc: debayang.qdt <debayang.qdt at qualcommdatacenter.com>
Subject: Re: [PATCH] Configure: Prefer gcc __atomic builtins instead of older __sync builtins

Hello!

On Sun, Dec 03, 2017 at 09:11:52PM +0530, Debayan Ghosh wrote:

> # HG changeset patch
> # User Debayan Ghosh <debayang.qdt at qualcommdatacenter.com>
> # Date 1511884462 -19800
> #      Tue Nov 28 21:24:22 2017 +0530
> # Node ID 4576e7c90ed42da3af67d90f624b34dd9285a658
> # Parent  fc0d06224edac2c7cfbfd9a4def478f285d9957b
> Configure: Prefer gcc __atomic builtins instead of older __sync 
> builtins
> 
> It is desirable to use the newer GCC __atomic builtins when using 
> later versions of GCC , compared to the legacy __sync atomic builtins.
> Ref: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

Any practical reasons for the change?

Either way, I would rather suggest looking at C11 atomic ops instead, see here:

http://mailman.nginx.org/pipermail/nginx-devel/2016-September/008805.html

Though I don't think it's practical either.

[...]

--
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list