[PATCH] Improve string::clear() performance

2016-09-13 Thread Cong Wang
. And Linux distro like Fedora doesn't enable this, this is why we caught it. The copy-and-clear test shows it improves by 50%. Ran all testsuites on Linux-x64. 2016-09-13 Cong Wang <xiyou.wangc...@gmail.com> PR libstdc++/77582 * libstdc++-v3/include/bits/basic_string.h: Change

Re: [PATCH] Improve string::clear() performance

2016-09-14 Thread Cong Wang
On Wed, Sep 14, 2016 at 4:06 AM, Jonathan Wakely <jwak...@redhat.com> wrote: > On 13/09/16 11:02 -0700, Cong Wang wrote: >> >> In !_GLIBCXX_USE_CXX11_ABI implementation, string::clear() calls >> _M_mutate(), which could allocate memory as we do COW. This hurts >&g

Re: [PATCH] Improve string::clear() performance

2016-09-14 Thread Cong Wang
On Wed, Sep 14, 2016 at 10:28 AM, Jonathan Wakely <jwak...@redhat.com> wrote: > On 14/09/16 09:09 -0700, Cong Wang wrote: >> >> On Wed, Sep 14, 2016 at 4:06 AM, Jonathan Wakely <jwak...@redhat.com> >> wrote: >>> >>> If I understand the purpose

Re: [PATCH] Improve string::clear() performance

2016-09-15 Thread Cong Wang
On Thu, Sep 15, 2016 at 2:08 AM, Jonathan Wakely <jwak...@redhat.com> wrote: > On 14/09/16 10:41 -0700, Cong Wang wrote: >> >> For long term, I think gcc should have something as simple as >> 'Signed-off-by' for Linux kernel, otherwise too much work for first-time >

Re: [PATCH] Improve string::clear() performance

2016-09-23 Thread Cong Wang
On Fri, Sep 23, 2016 at 10:25 AM, Jonathan Wakely wrote: > > I'm applying this patch, which is my one from 2014 with a check for > whether the string is shared, so we just set the length to zero (and > don't throw away reusable capacity) when it's not shared. > > Tested