Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 86243 invoked from network); 3 Aug 2007 22:00:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Aug 2007 22:00:16 -0000 Received: (qmail 11299 invoked by uid 500); 3 Aug 2007 22:00:15 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 11241 invoked by uid 500); 3 Aug 2007 22:00:15 -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 11230 invoked by uid 99); 3 Aug 2007 22:00:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 15:00:15 -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; Fri, 03 Aug 2007 21:59:57 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 162FD7141F1 for ; Fri, 3 Aug 2007 14:59:53 -0700 (PDT) Message-ID: <15835473.1186178393088.JavaMail.jira@brutus> Date: Fri, 3 Aug 2007 14:59:53 -0700 (PDT) From: "Martin Sebor (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Assigned: (STDCXX-491) string::push_back() slow In-Reply-To: <21203463.1185136026506.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-491?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Martin Sebor reassigned STDCXX-491: ----------------------------------- Assignee: Martin Sebor > string::push_back() slow > ------------------------ > > Key: STDCXX-491 > URL: https://issues.apache.org/jira/browse/STDCXX-491 > Project: C++ Standard Library > Issue Type: Bug > Components: 21. Strings > Affects Versions: 4.1.3 > Environment: gcc 4.1.2, Linux/x86_64 > Reporter: Mark Brown > Assignee: Martin Sebor > > According to my timings string::push_back() in stdcxx 4.1.3 is more than twice as slow than the same function in gcc 4.1.2 on Linux x86_64: > $ time ./push_back-stdcxx 100000000 > real 0m2.175s > user 0m2.004s > sys 0m0.172s > $ time ./push_back-gcc 100000000 > real 0m0.924s > user 0m0.760s > sys 0m0.164s > #include > #include > #include > int main (int argc, char *argv[]) > { > const int N = argc < 2 ? 1 : std::atoi (argv [1]); > std::string str; > for (int i = 0; i < N; ++i) > str.push_back ('x'); > assert (str.size () == std::size_t (N)); > } > Comparing the generated assembly, the gcc push_back() is mostly inline but the stdcxx push_back() is not: > stdcxx: > _Z8pushbackRSsc: > .LFB449: > movq (%rdi), %rax > movl %esi, %edx > movl $1, %ecx > movsbl %dl,%r8d > xorl %edx, %edx > movq -8(%rax), %rsi > jmp _ZNSs7replaceEmmmc > gcc: > _Z8pushbackRSsc: > .LFB904: > movq %rbp, -16(%rsp) > .LCFI0: > movq %r12, -8(%rsp) > .LCFI1: > movq %rdi, %rbp > movq %rbx, -24(%rsp) > .LCFI2: > subq $24, %rsp > .LCFI3: > movq (%rdi), %rax > movl %esi, %r12d > subq $24, %rax > movq (%rax), %rbx > addq $1, %rbx > cmpq 8(%rax), %rbx > ja .L2 > movl 16(%rax), %eax > testl %eax, %eax > jg .L2 > .L4: > movq (%rbp), %rdx > movq -24(%rdx), %rax > movb %r12b, (%rdx,%rax) > movq (%rbp), %rax > subq $24, %rax > movl $0, 16(%rax) > movq %rbx, (%rax) > movb $0, 24(%rax,%rbx) > movq (%rsp), %rbx > movq 8(%rsp), %rbp > movq 16(%rsp), %r12 > addq $24, %rsp > ret > .p2align 4,,7 > .L2: > movq %rbx, %rsi > movq %rbp, %rdi > call _ZNSs7reserveEm > jmp .L4 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.