public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow
@ 2006-08-18 1:34 ian at airs dot com
2006-08-18 2:14 ` [Bug libstdc++/28765] " pcarlini at suse dot de
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: ian at airs dot com @ 2006-08-18 1:34 UTC (permalink / raw)
To: gcc-bugs
Compile this code with -O2:
#include <ext/vstring.h>
void foo(__gnu_cxx::__vstring s)
{
s.clear();
}
Look at the resulting assembler code. Do not show it to small children. It is
too scary.
With this simple patch:
--- include/ext/sso_string_base.h (revision 116231)
+++ include/ext/sso_string_base.h (working copy)
@@ -540,7 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
}
template<typename _CharT, typename _Traits, typename _Alloc>
- void
+ inline void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_erase(size_type __pos, size_type __n)
{
I get this code:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
movl 8(%ebp), %eax
movl $0, 4(%eax)
movl (%eax), %eax
movb $0, (%eax)
popl %ebp
ret
Much nicer.
I think this would be an appropriate fix, as _M_erase is not large. Another
possible fix would be to change clear to call _M_set_length(0).
--
Summary: __gnu_cxx::__vstring::clear() is slow
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
@ 2006-08-18 2:14 ` pcarlini at suse dot de
2006-08-18 6:32 ` ian at airs dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2006-08-18 2:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pcarlini at suse dot de 2006-08-18 02:13 -------
Hi Ian. Please go ahead with the inlining: only, from a stylistical point of
view, please move the entire body inline, do not mark inline the out of line
code. Patch preapproved, thanks a lot!
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ian at airs dot com
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-08-18 02:13:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
2006-08-18 2:14 ` [Bug libstdc++/28765] " pcarlini at suse dot de
@ 2006-08-18 6:32 ` ian at airs dot com
2006-08-18 8:31 ` pcarlini at suse dot de
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2006-08-18 6:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ian at airs dot com 2006-08-18 06:32 -------
Unfortunately I do not currently have a valid copyright assignment with the
FSF. I think my one word change is fine, but I don't feel comfortable moving a
function around (although I agree that is the right approach).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
2006-08-18 2:14 ` [Bug libstdc++/28765] " pcarlini at suse dot de
2006-08-18 6:32 ` ian at airs dot com
@ 2006-08-18 8:31 ` pcarlini at suse dot de
2006-08-18 15:42 ` paolo at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2006-08-18 8:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pcarlini at suse dot de 2006-08-18 08:31 -------
Ok, I see... Then I will do the change, a little embarassing ;) By the way, if
it's not obvious, the reason we don't simply call _M_set_length is the other
base class, where clear cannot be trivial (due to refcounting) and the
meaningful thing to do is considering clear a special case of erase and share
code. At some point we should add a new _M_clear to both base classes and
either forward to _M_erase or just call _M_set_length.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|ian at airs dot com |pcarlini at suse dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
` (3 preceding siblings ...)
2006-08-18 15:42 ` paolo at gcc dot gnu dot org
@ 2006-08-18 15:42 ` paolo at gcc dot gnu dot org
2006-08-18 15:44 ` pcarlini at suse dot de
2006-08-18 15:58 ` ian at airs dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-08-18 15:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from paolo at gcc dot gnu dot org 2006-08-18 15:42 -------
Subject: Bug 28765
Author: paolo
Date: Fri Aug 18 15:42:27 2006
New Revision: 116241
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116241
Log:
2006-08-18 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28765
* include/ext/rc_string_base.h (_M_clear): New.
* include/ext/sso_string_base.h (_M_clear): Likewise.
* include/ext/vstring.h (clear): Use it.
Modified:
branches/gcc-4_1-branch/libstdc++-v3/ChangeLog
branches/gcc-4_1-branch/libstdc++-v3/include/ext/rc_string_base.h
branches/gcc-4_1-branch/libstdc++-v3/include/ext/sso_string_base.h
branches/gcc-4_1-branch/libstdc++-v3/include/ext/vstring.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
` (2 preceding siblings ...)
2006-08-18 8:31 ` pcarlini at suse dot de
@ 2006-08-18 15:42 ` paolo at gcc dot gnu dot org
2006-08-18 15:42 ` paolo at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-08-18 15:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from paolo at gcc dot gnu dot org 2006-08-18 15:42 -------
Subject: Bug 28765
Author: paolo
Date: Fri Aug 18 15:42:05 2006
New Revision: 116240
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116240
Log:
2006-08-18 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28765
* include/ext/rc_string_base.h (_M_clear): New.
* include/ext/sso_string_base.h (_M_clear): Likewise.
* include/ext/vstring.h (clear): Use it.
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/ext/rc_string_base.h
trunk/libstdc++-v3/include/ext/sso_string_base.h
trunk/libstdc++-v3/include/ext/vstring.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
` (4 preceding siblings ...)
2006-08-18 15:42 ` paolo at gcc dot gnu dot org
@ 2006-08-18 15:44 ` pcarlini at suse dot de
2006-08-18 15:58 ` ian at airs dot com
6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2006-08-18 15:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2006-08-18 15:44 -------
Fixed for 4.1.2.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/28765] __gnu_cxx::__vstring::clear() is slow
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
` (5 preceding siblings ...)
2006-08-18 15:44 ` pcarlini at suse dot de
@ 2006-08-18 15:58 ` ian at airs dot com
6 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2006-08-18 15:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from ian at airs dot com 2006-08-18 15:58 -------
Thanks!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28765
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-08-18 15:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-18 1:34 [Bug libstdc++/28765] New: __gnu_cxx::__vstring::clear() is slow ian at airs dot com
2006-08-18 2:14 ` [Bug libstdc++/28765] " pcarlini at suse dot de
2006-08-18 6:32 ` ian at airs dot com
2006-08-18 8:31 ` pcarlini at suse dot de
2006-08-18 15:42 ` paolo at gcc dot gnu dot org
2006-08-18 15:42 ` paolo at gcc dot gnu dot org
2006-08-18 15:44 ` pcarlini at suse dot de
2006-08-18 15:58 ` ian at airs dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).