From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18962 invoked by alias); 9 Jan 2012 14:31:42 -0000 Received: (qmail 18948 invoked by uid 22791); 9 Jan 2012 14:31:41 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Jan 2012 14:31:28 +0000 From: "dje at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/51798] New: [4.7 regression] libstdc++ atomicity performance regression due to __sync_fetch_and_add Date: Mon, 09 Jan 2012 14:31:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dje at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg00869.txt.bz2 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.