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]

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


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