This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Improve string::clear() performance
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Cong Wang <xiyou dot wangcong at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 14 Sep 2016 12:06:22 +0100
- Subject: Re: [PATCH] Improve string::clear() performance
- Authentication-results: sourceware.org; auth=none
- References: <CAM_iQpV4L=KLj3aKya=eXbHjWLFG4ZcNtryxuE+z7hYKw_hKPQ@mail.gmail.com>
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
_GLIBCXX_FULLY_DYNAMIC_STRING is not enabled. 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.
Thank you for the patch (and changelog and test results!).
Do you have a GCC copyright assignment in place? See
https://gcc.gnu.org/contribute.html#legal for details.
If I understand the purpose of the change correctly, it's similar to
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg00278.html - is that
right?