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

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

2016-09-23 Thread Jonathan Wakely
On 14/09/16 18:28 +0100, Jonathan Wakely wrote: On 14/09/16 09:09 -0700, Cong Wang wrote: On Wed, Sep 14, 2016 at 4:06 AM, Jonathan Wakely wrote: On 13/09/16 11:02 -0700, Cong Wang wrote: In !_GLIBCXX_USE_CXX11_ABI implementation, string::clear() calls _M_mutate(), which

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

2016-09-15 Thread Cong Wang
On Thu, Sep 15, 2016 at 2:08 AM, Jonathan Wakely 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 >> contributors like me. We all

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

2016-09-15 Thread Jonathan Wakely
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 contributors like me. We all want to save time on this, don't we? ;) Signed-off-by wouldn't help. The copyright

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

2016-09-14 Thread Cong Wang
On Wed, Sep 14, 2016 at 10:28 AM, Jonathan Wakely wrote: > On 14/09/16 09:09 -0700, Cong Wang wrote: >> >> On Wed, Sep 14, 2016 at 4:06 AM, Jonathan Wakely >> wrote: >>> >>> If I understand the purpose of the change correctly, it's similar to >>>

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

2016-09-14 Thread Jonathan Wakely
On 14/09/16 09:09 -0700, Cong Wang wrote: On Wed, Sep 14, 2016 at 4:06 AM, Jonathan Wakely 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

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

2016-09-14 Thread Cong Wang
On Wed, Sep 14, 2016 at 4:06 AM, Jonathan Wakely 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 >> performance when string::clear()

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

2016-09-14 Thread Jonathan Wakely
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 performance when string::clear() is on the hot path. This patch improves it by using _S_empty_rep directly when

[PATCH] Improve string::clear() performance

2016-09-13 Thread Cong Wang
In !_GLIBCXX_USE_CXX11_ABI implementation, string::clear() calls _M_mutate(), which could allocate memory as we do COW. This hurts performance when string::clear() is on the hot path. This patch improves it by using _S_empty_rep directly when _GLIBCXX_FULLY_DYNAMIC_STRING is not enabled. And