This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: bkoz at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, ljrittle at gcc dot gnu dot org, shurik at sequoiap dot com
- Date: Thu, 8 Aug 2002 18:58:42 -0500 (CDT)
- Subject: Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications
OK, I'd be happy to find a performance fix that doesn't make the
library code subtly less portable when we have a test case. A
reference to code already in our test suite would be acceptable.
I just looked at some locale code in our test suite under gdb and then
constructed the smallest cases that used std::locale::classic() [1]
and another that did not [2]. Then, I compiled both [1] and [2] with
and without -static and looked under gdb. In all four cases,
std::locale::classic() was called once before main().
[1]
#include <locale>
int main (void)
{
std::locale::classic();
}
[2]
#include <locale>
int main (void)
{
}
Benjamin (as the "local locale" expert), is it *always* true that
std::locale::classic() is called at least once during startup before
control is transferred to main()? If so (and will always be so), then
all thread-related locking could be removed IMHO. In practice, our
implementation of the Standard C++ library (with optional threading
support) already supposes that no thread which uses the library
implementation may have ever been started before main() is invoked.
If not true, then this change would make a very hard to detect
threading bug when the assumption changes.
Regards,
Loren