http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51798

             Bug #: 51798
           Summary: [4.7 regression] libstdc++ atomicity performance
                    regression due to __sync_fetch_and_add
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: d...@gcc.gnu.org


libstdc++ uses __sync_fetch_and_add() to provide atomicity for reference
counting.  The semantics of __sync_fetch_and_add() were not explicitly stated. 
libstdc++ apparently requires ACQUIRE semantics for incrementing the reference
count and RELEASE semantics for decrementing the reference and possibly
destroying the object.  The libstdc++ code did not make this distinction, but
__sync_fetch_and_add() generally was implemented as RELEASE semantics, which
was overkill for increment and appropriate for decrement/destroy.

As part of the C++11 memory model changes, __sync_fetch_and_add() atomicity was
changed to use the new, more general atomicity infrastructure with SEQUENTIAL
CONSISTENCY.  This imposes the most strict and heavy-weight barrier.

On architectures with granularity and gradations in the implementation of
atomic instructions, this introduces a severe performance regression.

Reply via email to