Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 96605 invoked from network); 12 Aug 2007 03:38:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Aug 2007 03:38:06 -0000 Received: (qmail 81453 invoked by uid 500); 12 Aug 2007 03:38:05 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 81442 invoked by uid 500); 12 Aug 2007 03:38:05 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 81431 invoked by uid 99); 12 Aug 2007 03:38:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Aug 2007 20:38:05 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Aug 2007 03:38:12 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6B1A371417D for ; Sat, 11 Aug 2007 20:37:43 -0700 (PDT) Message-ID: <23325202.1186889863436.JavaMail.jira@brutus> Date: Sat, 11 Aug 2007 20:37:43 -0700 (PDT) From: "Mark Brown (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Commented: (STDCXX-518) std::string copy constructor slow In-Reply-To: <6494896.1186876183839.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-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519279 ] Mark Brown commented on STDCXX-518: ----------------------------------- I thought timings for multipled threads might be of interest. Unfortunately, I have only 2 CPUs to test on. $ time ./string-copy.gcc 100000000 real 0m9.739s user 0m19.257s sys 0m0.060s $ time ./string-copy.stlport 100000000 real 0m20.906s user 0m40.211s sys 0m0.056s $ time LD_LIBRARY_PATH=../lib ./string-copy 100000000 real 0m17.585s user 0m34.698s sys 0m0.076s #include #include #include #include std::string strings [256]; const std::size_t num_strings = sizeof strings / sizeof *strings; unsigned long n; extern "C" void* test_copy_ctor (void*) { for (unsigned long i = 0; i != n; ++i) { const std::size_t index = i % num_strings; const std::string copy (strings [index]); assert (copy.length () == index); } return 0; } int main (int argc, char *argv[]) { n = argc < 2 ? 0 : std::strtoul (argv [1], 0, 10); for (unsigned long i = 0; i != num_strings; ++i) strings [i].assign (i, 'x'); pthread_t thread [2]; const std::size_t num_threads = sizeof thread / sizeof *thread; for (std::size_t i = 0; i < num_threads; ++i) pthread_create (thread + i, 0, test_copy_ctor, 0); for (std::size_t i = 0; i < num_threads; ++i) pthread_join (thread [i], 0); } > std::string copy constructor slow > --------------------------------- > > Key: STDCXX-518 > URL: https://issues.apache.org/jira/browse/STDCXX-518 > Project: C++ Standard Library > Issue Type: Improvement > Components: 21. Strings > Affects Versions: 4.1.3 > Environment: gcc 4.1.2, x86_64 > Reporter: Mark Brown > > When thread safety is enabled in stdcxx the string copy constructor is more than ten times slower than when it's not, and twice as slow as the same copy constructor in gcc 4.1.2 on Linux (x86_64), but slightly faster than with STLport 5.1.3. The timings were done on Intel x86_64 at 2.4GHz: > BUILDMODE=shared,optimized: > $ time LD_LIBRARY_PATH=../lib ./string-copy 100000000 > real 0m0.482s > user 0m0.480s > sys 0m0.000s > BUILDMODE=shared,optimized,pthread: > $ time LD_LIBRARY_PATH=../lib ./string-copy 100000000 > real 0m10.157s > user 0m10.041s > sys 0m0.032s > gcc 4.1.2 with -O2 -m64: > $ time ./string-copy.gcc 100000000 > real 0m4.280s > user 0m4.260s > sys 0m0.020s > gcc 4.1.2 with STLport 5.1.3 (-D_REENTRANT -O2 -m64 -lpthread): > $ time ./string-copy.stlport 100000000 > real 0m12.479s > user 0m12.473s > sys 0m0.004s > #include > #include > #include > int main (int argc, char *argv[]) > { > const unsigned long n = argc < 2 ? 0 : std::strtoul (argv [1], 0, 10); > std::string strings [256]; > const std::size_t num_strings = sizeof strings / sizeof *strings; > for (unsigned long i = 0; i != num_strings; ++i) > strings [i].assign (i, 'x'); > for (unsigned long i = 0; i < n; ++i) { > const std::size_t length = i % num_strings; > const std::string str (strings [length]); > assert (str.size () == length); > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.