Bug #87365 Preference of newer gcc atomic built ins over sync

Submitted: 10 Aug 2017 4:49 Modified: 30 Aug 2017 14:37
Reporter: Debayan Ghosh (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S4 (Feature request)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: aarch64, atomic

[10 Aug 2017 4:49] Debayan Ghosh
Description:
In os0atomic.h , preference given to older sync atomic apis over newer atomic apics.

#if defined(HAVE_GCC_SYNC_BUILTINS)
  <sync>
#else
  <atomics>

This results in the older sync apis to be used in place of newer atomics if available.

How to repeat:

File: storage/innobase/include/os0atomic.h
[30 Aug 2017 12:51] MySQL Verification Team
Hi!

Would you be so kind to let us know which GCC version, exactly, has faster atomics then sync ???

Thanks in advance.
[30 Aug 2017 13:09] Debayan Ghosh
The atomic apis were introduced quite some time back in GCC 4.7.1

Release Notes:
https://gcc.gnu.org/gcc-4.7/changes.html

And also as the gcc docs mentions below:
[https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html]

"New code should always use the ‘__atomic’ builtins rather than the ‘__sync’ builtins."
[30 Aug 2017 14:09] MySQL Verification Team
Hi!

We have not updated all platforms on 4.7.*, so we can not use that universally. However, since upgrades will occur, I consider that this is a fully justified feature request.

Verified as a feature request.
[30 Aug 2017 14:37] Debayan Ghosh
Thanks Sinisa .

My suggestion was to change the order from currently as below

#if defined(HAVE_GCC_SYNC_BUILTINS)
  <sync>
#else
  <atomics>

To something like:

#if defined (HAVE_GCC_ATOMIC_BUILTINS)
 <atomics>
#else if defined (HAVE_GCC_SYNC_BUILTINS)
 <sync>
..

This should work for earlier versions as well where sync will be used and also gives preference to atomics for the newer versions.
[30 Aug 2017 14:40] MySQL Verification Team
It will be researched. Very carefully.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.