This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications


>Number:         7445
>Category:       libstdc++
>Synopsis:       poor performance of std::locale::classic() in multi-threaded applications
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 30 11:46:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Alex Kompel
>Release:        gcc version 3.1.1
>Organization:
>Environment:
RedHat Linux 7.3
>Description:
poor performance of std::locale::classic() in multi-threaded applications. std::locale:classic() is using _STL_auto_lock too extensively. It should only be used when the locale object is initialized. It does locks the mutex
on every call at present. See the fix below.
>How-To-Repeat:

>Fix:
*** libstdc++-v3/src/locale.old Tue Jul 30 11:31:01 2002
--- libstdc++-v3/src/locale.cc  Tue Jul 30 11:31:13 2002
***************
*** 285,294 ****
    locale::classic()
    {
      static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;
-     _STL_auto_lock __auto(__lock);

      if (!_S_classic)
        {
        try
          {
            // 26 Standard facets, 2 references.
--- 285,294 ----
    locale::classic()
    {
      static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;

      if (!_S_classic)
        {
+         _STL_auto_lock __auto(__lock);
        try
          {
            // 26 Standard facets, 2 references.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]