From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22908 invoked by alias); 9 Aug 2002 00:06:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 22894 invoked by uid 71); 9 Aug 2002 00:06:00 -0000 Date: Thu, 08 Aug 2002 23:26:00 -0000 Message-ID: <20020809000600.22893.qmail@sources.redhat.com> To: ljrittle@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Loren James Rittle Subject: Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications Reply-To: Loren James Rittle X-SW-Source: 2002-08/txt/msg00179.txt.bz2 List-Id: The following reply was made to PR libstdc++/7445; it has been noted by GNATS. From: Loren James Rittle To: bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, ljrittle@gcc.gnu.org, shurik@sequoiap.com Cc: Subject: Re: libstdc++/7445: poor performance of std::locale::classic() in multi-threaded applications Date: Thu, 8 Aug 2002 18:58:42 -0500 (CDT) 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 int main (void) { std::locale::classic(); } [2] #include 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