[Bug libstdc++/51798] New: [4.7 regression] libstdc++ atomicity performance regression due to __sync_fetch_and_add
dje at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jan 9 14:31:00 GMT 2012
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: unassigned@gcc.gnu.org
ReportedBy: dje@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.
More information about the Gcc-bugs
mailing list