__gnu_cxx::__exchange_and_add shows up in profiles of the PowerDNS recursor, which is single threaded. I'm somewhat amazed this is an out-of-line function (there are 40 cycles to be gained by inlining it, and this function gets called a lot), but I'm worried more about the 1000 cycle overhead even in a single-threaded program!
I think it would be good to teach std::string to use a non-atomic exchange_and_add (or even just 'add') for non-REENTRANT applications, plus it would be good to be able to inline the function, but I understand this is of far smaller importance. The code exhibiting prominent profiled use of __gnu_cxx::__exchange_and_add can be found via the repository described on http://wiki.powerdn.somc. Thanks! -- Summary: __gnu_cxx::__exchange_and_add is out of line and called even for single threaded applications using std::string Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ahu at ds9a dot nl GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24704