Return-Path: Delivered-To: apmail-stdcxx-issues-archive@locus.apache.org Received: (qmail 78172 invoked from network); 9 Nov 2008 00:19:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Nov 2008 00:19:14 -0000 Received: (qmail 16589 invoked by uid 500); 9 Nov 2008 00:19:22 -0000 Delivered-To: apmail-stdcxx-issues-archive@stdcxx.apache.org Received: (qmail 16568 invoked by uid 500); 9 Nov 2008 00:19:22 -0000 Mailing-List: contact issues-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list issues@stdcxx.apache.org Received: (qmail 16556 invoked by uid 99); 9 Nov 2008 00:19:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Nov 2008 16:19:21 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Nov 2008 00:18:01 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 306C6234C288 for ; Sat, 8 Nov 2008 16:18:44 -0800 (PST) Message-ID: <618453688.1226189924183.JavaMail.jira@brutus> Date: Sat, 8 Nov 2008 16:18:44 -0800 (PST) From: "Martin Sebor (JIRA)" To: issues@stdcxx.apache.org Subject: [jira] Issue Comment Edited: (STDCXX-914) sstream ctors inefficient in reentrant modes In-Reply-To: <1774712964.1210133395826.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594770#action_12594770 ] sebor edited comment on STDCXX-914 at 11/8/08 4:16 PM: -------------------------------------------------------------- gprof flat profile for a 15D build with gcc 4.3.0 on x86_64 (with most template arguments removed for brevity): \\ {noformat} Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ns/call ns/call name 33.40 0.08 0.08 1000000 80.15 200.37 std::string lex_cast(long const&) 16.70 0.12 0.04 1000000 40.07 90.17 std::stringstream::~stringstream() 16.70 0.16 0.04 main 12.52 0.19 0.03 1000000 30.06 40.07 std::iostream::~iostream() 8.35 0.21 0.02 1000000 20.04 20.04 std::iostream::iostream(std::streambuf*) 4.17 0.22 0.01 1000000 10.02 10.02 std::ostream::~ostream() 4.17 0.23 0.01 1000000 10.02 30.06 std::stringstream::stringstream(__rw::__rw_openmode) 4.17 0.24 0.01 1000000 10.02 10.02 std::ios::~ios() 0.00 0.24 0.00 14000002 0.00 0.00 data_start 0.00 0.24 0.00 1000001 0.00 0.00 std::allocator::allocator() 0.00 0.24 0.00 1000000 0.00 0.00 __rw::__string_ref::~__string_ref() 0.00 0.24 0.00 1000000 0.00 0.00 std::stringstream::rdbuf() const 0.00 0.24 0.00 1000000 0.00 0.00 std::istream::~istream() {noformat} gprof call graph: {noformat} granularity: each sample hit covers 2 byte(s) for 4.16% of 0.24 seconds index % time self children called name [1] 100.0 0.04 0.20 main [1] 0.08 0.12 1000000/1000000 std::string lex_cast(long const&) [2] 0.00 0.00 3000002/14000002 data_start [9] 0.00 0.00 1/1000001 std::allocator::allocator() [15] ----------------------------------------------- 0.08 0.12 1000000/1000000 main [1] [2] 83.3 0.08 0.12 1000000 std::string lex_cast(long const&) [2] 0.04 0.05 1000000/1000000 std::stringstream::~stringstream() [3] 0.01 0.02 1000000/1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] 0.00 0.00 5000000/14000002 data_start [9] 0.00 0.00 1000000/1000001 std::allocator::allocator() [15] ----------------------------------------------- 0.04 0.05 1000000/1000000 std::string lex_cast(long const&) [2] [3] 37.5 0.04 0.05 1000000 std::stringstream::~stringstream() [3] 0.03 0.01 1000000/1000000 std::iostream::~iostream() [4] 0.01 0.00 1000000/1000000 std::ios::~ios() [8] 0.00 0.00 1000000/14000002 data_start [9] ----------------------------------------------- 0.03 0.01 1000000/1000000 std::stringstream::~stringstream() [3] [4] 16.7 0.03 0.01 1000000 std::iostream::~iostream() [4] 0.01 0.00 1000000/1000000 std::ostream::~ostream() [7] 0.00 0.00 1000000/1000000 std::istream::~istream() [18] ----------------------------------------------- 0.01 0.02 1000000/1000000 std::string lex_cast(long const&) [2] [5] 12.5 0.01 0.02 1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] 0.02 0.00 1000000/1000000 std::iostream::iostream(std::streambuf*) [6] 0.00 0.00 2000000/14000002 data_start [9] 0.00 0.00 1000000/1000000 std::stringstream::rdbuf() const [17] ----------------------------------------------- 0.02 0.00 1000000/1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] [6] 8.3 0.02 0.00 1000000 std::iostream::iostream(std::streambuf*) [6] 0.00 0.00 2000000/14000002 data_start [9] ----------------------------------------------- 0.01 0.00 1000000/1000000 std::iostream::~iostream() [4] [7] 4.2 0.01 0.00 1000000 std::ostream::~ostream() [7] ----------------------------------------------- 0.01 0.00 1000000/1000000 std::stringstream::~stringstream() [3] [8] 4.2 0.01 0.00 1000000 std::ios::~ios() [8] 0.00 0.00 1000000/14000002 data_start [9] ----------------------------------------------- 0.00 0.00 1000000/14000002 std::ios::~ios() [8] 0.00 0.00 1000000/14000002 std::stringstream::~stringstream() [3] 0.00 0.00 2000000/14000002 std::iostream::iostream(std::streambuf*) [6] 0.00 0.00 2000000/14000002 std::stringstream::stringstream(__rw::__rw_openmode) [5] 0.00 0.00 3000002/14000002 main [1] 0.00 0.00 5000000/14000002 std::string lex_cast(long const&) [2] [9] 0.0 0.00 0.00 14000002 data_start [9] ----------------------------------------------- 0.00 0.00 1/1000001 main [1] 0.00 0.00 1000000/1000001 std::string lex_cast(long const&) [2] [15] 0.0 0.00 0.00 1000001 std::allocator::allocator() [15] ----------------------------------------------- 0.00 0.00 1000000/1000000 std::allocator<__rw::__string_ref>::destroy(__rw::__string_ref*) [19] [16] 0.0 0.00 0.00 1000000 __rw::__string_ref::~__string_ref() [16] ----------------------------------------------- 0.00 0.00 1000000/1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] [17] 0.0 0.00 0.00 1000000 std::stringstream::rdbuf() const [17] ----------------------------------------------- 0.00 0.00 1000000/1000000 std::iostream::~iostream() [4] [18] 0.0 0.00 0.00 1000000 std::istream::~istream() [18] ----------------------------------------------- {noformat} and index by function name: {noformat} [2] std::string lex_cast(long const&) [4] std::iostream::~iostream() [8] std::ios::~ios() [16] __rw::__string_ref::~__string_ref() [18] std::istream::~istream() [9] data_start [17] std::stringstream::rdbuf() const [7] std::ostream::~ostream() [1] main [15] std::allocator::allocator() [5] std::stringstream::stringstream(__rw::__rw_openmode) [6] std::iostream::iostream(std::streambuf*) [3] std::stringstream::~stringstream() {noformat} was (Author: sebor): gprof flat profile for a 15D build with gcc 4.3.0 on x86_64: \\ {noformat} Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ns/call ns/call name 33.40 0.08 0.08 1000000 80.15 200.37 std::string lex_cast(long const&) 16.70 0.12 0.04 1000000 40.07 90.17 std::stringstream::~stringstream() 16.70 0.16 0.04 main 12.52 0.19 0.03 1000000 30.06 40.07 std::iostream::~iostream() 8.35 0.21 0.02 1000000 20.04 20.04 std::iostream::iostream(std::streambuf*) 4.17 0.22 0.01 1000000 10.02 10.02 std::ostream::~ostream() 4.17 0.23 0.01 1000000 10.02 30.06 std::stringstream::stringstream(__rw::__rw_openmode) 4.17 0.24 0.01 1000000 10.02 10.02 std::ios::~ios() 0.00 0.24 0.00 14000002 0.00 0.00 data_start 0.00 0.24 0.00 1000001 0.00 0.00 std::allocator::allocator() 0.00 0.24 0.00 1000000 0.00 0.00 __rw::__string_ref, std::allocator >::~__string_ref() 0.00 0.24 0.00 1000000 0.00 0.00 std::stringstream::rdbuf() const 0.00 0.24 0.00 1000000 0.00 0.00 std::istream::~istream() {noformat} gprof call graph: {noformat} granularity: each sample hit covers 2 byte(s) for 4.16% of 0.24 seconds index % time self children called name [1] 100.0 0.04 0.20 main [1] 0.08 0.12 1000000/1000000 std::string lex_cast(long const&) [2] 0.00 0.00 3000002/14000002 data_start [9] 0.00 0.00 1/1000001 std::allocator::allocator() [15] ----------------------------------------------- 0.08 0.12 1000000/1000000 main [1] [2] 83.3 0.08 0.12 1000000 std::string lex_cast(long const&) [2] 0.04 0.05 1000000/1000000 std::stringstream::~stringstream() [3] 0.01 0.02 1000000/1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] 0.00 0.00 5000000/14000002 data_start [9] 0.00 0.00 1000000/1000001 std::allocator::allocator() [15] ----------------------------------------------- 0.04 0.05 1000000/1000000 std::string lex_cast(long const&) [2] [3] 37.5 0.04 0.05 1000000 std::stringstream::~stringstream() [3] 0.03 0.01 1000000/1000000 std::iostream::~iostream() [4] 0.01 0.00 1000000/1000000 std::ios::~ios() [8] 0.00 0.00 1000000/14000002 data_start [9] ----------------------------------------------- 0.03 0.01 1000000/1000000 std::stringstream::~stringstream() [3] [4] 16.7 0.03 0.01 1000000 std::iostream::~iostream() [4] 0.01 0.00 1000000/1000000 std::ostream::~ostream() [7] 0.00 0.00 1000000/1000000 std::istream::~istream() [18] ----------------------------------------------- 0.01 0.02 1000000/1000000 std::string lex_cast(long const&) [2] [5] 12.5 0.01 0.02 1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] 0.02 0.00 1000000/1000000 std::iostream::iostream(std::streambuf*) [6] 0.00 0.00 2000000/14000002 data_start [9] 0.00 0.00 1000000/1000000 std::stringstream::rdbuf() const [17] ----------------------------------------------- 0.02 0.00 1000000/1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] [6] 8.3 0.02 0.00 1000000 std::iostream::iostream(std::streambuf*) [6] 0.00 0.00 2000000/14000002 data_start [9] ----------------------------------------------- 0.01 0.00 1000000/1000000 std::iostream::~iostream() [4] [7] 4.2 0.01 0.00 1000000 std::ostream::~ostream() [7] ----------------------------------------------- 0.01 0.00 1000000/1000000 std::stringstream::~stringstream() [3] [8] 4.2 0.01 0.00 1000000 std::ios::~ios() [8] 0.00 0.00 1000000/14000002 data_start [9] ----------------------------------------------- 0.00 0.00 1000000/14000002 std::ios::~ios() [8] 0.00 0.00 1000000/14000002 std::stringstream::~stringstream() [3] 0.00 0.00 2000000/14000002 std::iostream::iostream(std::streambuf*) [6] 0.00 0.00 2000000/14000002 std::stringstream::stringstream(__rw::__rw_openmode) [5] 0.00 0.00 3000002/14000002 main [1] 0.00 0.00 5000000/14000002 std::string lex_cast(long const&) [2] [9] 0.0 0.00 0.00 14000002 data_start [9] ----------------------------------------------- 0.00 0.00 1/1000001 main [1] 0.00 0.00 1000000/1000001 std::string lex_cast(long const&) [2] [15] 0.0 0.00 0.00 1000001 std::allocator::allocator() [15] ----------------------------------------------- 0.00 0.00 1000000/1000000 std::allocator<__rw::__string_ref, std::allocator > >::destroy(__rw::__string_ref, std::allocator >*) [19] [16] 0.0 0.00 0.00 1000000 __rw::__string_ref, std::allocator >::~__string_ref() [16] ----------------------------------------------- 0.00 0.00 1000000/1000000 std::stringstream::stringstream(__rw::__rw_openmode) [5] [17] 0.0 0.00 0.00 1000000 std::stringstream::rdbuf() const [17] ----------------------------------------------- 0.00 0.00 1000000/1000000 std::iostream::~iostream() [4] [18] 0.0 0.00 0.00 1000000 std::istream::~istream() [18] ----------------------------------------------- {noformat} and index by function name: {noformat} [2] std::string lex_cast(long const&) [4] std::iostream::~iostream() [8] std::ios::~ios() [16] __rw::__string_ref, std::allocator >::~__string_ref() [18] std::istream::~istream() [9] data_start [17] std::stringstream::rdbuf() const [7] std::ostream::~ostream() [1] main [15] std::allocator::allocator() [5] std::stringstream::stringstream(__rw::__rw_openmode) [6] std::iostream::iostream(std::streambuf*) [3] std::stringstream::~stringstream() {noformat} > sstream ctors inefficient in reentrant modes > -------------------------------------------- > > Key: STDCXX-914 > URL: https://issues.apache.org/jira/browse/STDCXX-914 > Project: C++ Standard Library > Issue Type: Improvement > Components: 27. Input/Output > Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1 > Reporter: Martin Sebor > Priority: Critical > Fix For: 4.2.2 > > Attachments: stdcxx-914-gprof-gcc-4.1.2-12D.txt, stdcxx-914-gprof-gcc-4.3.0-12S.txt > > Original Estimate: 12h > Time Spent: 2.5h > Remaining Estimate: 9.5h > > As discussed in this [thread|http://markmail.org/message/hqlsw5dq23gx7d4o] stream ctors in thread-safe builds are inefficient due to the initialization of the mutex data member in every stream, even in those that never use it. As soon as binary compatibility rules permit it we should remove the mutex and/or defer its initialization until it's needed. It might be possible to implement the deferred initialization as early as 4.2.2, or maybe 4.3. Complete removal will need to wait until 5.0. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.