public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/20706] New: string::reserve severe performance regression
@ 2005-03-31 20:27 ftr at highstreetnetworks dot com
  2005-03-31 20:57 ` [Bug libstdc++/20706] " pcarlini at suse dot de
  2005-03-31 21:14 ` pcarlini at suse dot de
  0 siblings, 2 replies; 3+ messages in thread
From: ftr at highstreetnetworks dot com @ 2005-03-31 20:27 UTC (permalink / raw)
  To: gcc-bugs

I am experiencing severe performance degradation using string::reserve() under
libstdc++.so.6 (g++ 3.4.3) that was not present under libstdc++.so.5 (g++ 3.2.2).

Here is a test program that exhibits the problem:

#include <string>
#include <assert.h>

int
main(int argc, char **argv)
{
	unsigned long size = 1024 * 1024;
	char *data = (char *) malloc(size);
	for (unsigned long i = 0; i < size; i++) {
		data[i] = 32 + (i % 94);
	}

	std::string dest;
	for (unsigned long i = 0; i < size; i++) {
		dest.reserve(dest.length() + 1);
		dest.append(&data[i],1);
	}

	assert(dest.length() == size);
	assert(dest == std::string(data,size));
}

Running linked against libstdc++.so.5 returns:
$ time ./test_reserve

real    0m0.128s
user    0m0.109s
sys     0m0.010s

Running linked against libstdc++.so.6 returns:
$ time ./test_reserve

real    13m34.776s
user    5m44.582s
sys     7m50.130s

On a 3.20GHz Xeon!!

g++ -v on RH8.0 returns:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)


g++ -v on RHEL4 returns:
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

-- 
           Summary: string::reserve severe performance regression
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ftr at highstreetnetworks dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20706


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-31 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-31 20:27 [Bug libstdc++/20706] New: string::reserve severe performance regression ftr at highstreetnetworks dot com
2005-03-31 20:57 ` [Bug libstdc++/20706] " pcarlini at suse dot de
2005-03-31 21:14 ` pcarlini at suse dot de

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).