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

            Bug ID: 59439
           Summary: std::locale uses atomic instructions on construction
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ben.maurer at gmail dot com

In a large multithreaded program that uses stringstream to stringify integers,
I have seen that construction and deconstruction of std::locale can take over
10% of the runtime according to the perf tool.

In bug 40088, std::locale was optimized to avoid the usage of a mutex when
creating the default locale. In our program, this path is being exercised.
However, the act of doing ref counting still has a very large performance
penalty on SMP systems due to cache line bouncing.

If this locale is truly readonly, it would be much better if refcounting could
be avoided. Maybe a refcount of -1 could signify "this object need not be
refcounted".

Reply via email to