public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21314] New: C++ performance regression with -Os
@ 2005-05-01 8:30 deemkay at gmail dot com
2005-05-01 8:32 ` [Bug c++/21314] " deemkay at gmail dot com
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: deemkay at gmail dot com @ 2005-05-01 8:30 UTC (permalink / raw)
To: gcc-bugs
the following code takes more than twice as long to run when compiled with -Os
using gcc-4.0.0 than it does with 3.3.5 or 3.4.3.
#include <stdio.h>
#include <vector>
class mytype_A {
public:
int id;
mytype_A():id(0) {}
};
class mytype_B {
public:
mytype_A* A;
mytype_B(mytype_A* p):A(p) {}
};
class mytype_C {
public:
mytype_B* B;
mytype_C(mytype_B* p):B(p) {}
};
class mytype_D {
public:
// mytype_C* C[2]; // less performance difference if we use simple arrays
std::vector<mytype_C*> C;
int junk[3]; // affects performance
public:
mytype_D(mytype_A* a0, mytype_A* a1) {
// C[0] = new mytype_C(new mytype_B(a0));
// C[1] = new mytype_C(new mytype_B(a0));
C.push_back(new mytype_C(new mytype_B(a0)));
C.push_back(new mytype_C(new mytype_B(a0)));
}
};
int main() {
int k = 5000; // run-time not linear in k
mytype_A* A[k];
mytype_D* D[k];
for (int i=0;i<=k;i++)
A[i] = new mytype_A();
for (int i=0;i<k;i++)
D[i] = new mytype_D(A[i],A[k-i]); // intentionally make some pointers
farther apart
clock_t before = clock();
int k0 = 0;
for (int i=0;i<k;i++) {
k0 = 0;
for (int j=0;j<k;j++) { // run through list of D's, and reference
pointers
mytype_D* d = D[j];
if (d->C[0]->B->A->id) k0++;
if (d->C[1]->B->A->id) k0++;
}
}
printf("%d\n",k0); // don't allow compiler to optimize away k0
printf("time: %f\n",(double)(clock()-before)/CLOCKS_PER_SEC);
return 0;
}
dirtyepic ~/work $ g++ -Os -Wall -march=pentium3 cpptest.cpp
i686-pc-linux-gnu-3.3.5-20050130 - time: 6.530000
i686-pc-linux-gnu-3.4.3-20050110 - time: 6.920000
i686-pc-linux-gnu-4.0.0(release) - time: 16.790000
i686-pc-linux-gnu-4.0.0-20050430 - time: 16.700000
dirtyepic ~/work $ g++ -v -save-temps -Os -Wall -march=pentium3 cpptest.cpp -o
gcc401
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with:
/var/tmp/portage/gcc-4.0.1_alpha20050430/work/gcc-4.0-20050430/configure
--enable-version-specific-runtime-libs --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.0.1-alpha20050430
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0.1-alpha20050430
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0.1-alpha20050430/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0.1-alpha20050430/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--disable-nls --with-system-zlib --disable-checking --disable-werror
--disable-libunwind-exceptions --disable-multilib --disable-libgcj
--enable-languages=c,c++ --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.0.1-alpha20050430 (Gentoo Linux 4.0.1_alpha20050430)
/usr/libexec/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/cc1plus -E -quiet -v
-D_GNU_SOURCE cpptest.cpp -march=pentium3 -Wall -Os -fpch-preprocess -o cpptest.ii
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/include/g++-v4
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/include/g++-v4/i686-pc-linux-gnu
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/include/g++-v4/backward
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/include
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../../../i686-pc-linux-gnu/include
/usr/include
End of search list.
/usr/libexec/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/cc1plus -fpreprocessed
cpptest.ii -quiet -dumpbase cpptest.cpp -march=pentium3 -auxbase cpptest -Os
-Wall -version -o cpptest.s
GNU C++ version 4.0.1-alpha20050430 (Gentoo Linux 4.0.1_alpha20050430)
(i686-pc-linux-gnu)
compiled by GNU C version 4.0.1-alpha20050430 (Gentoo Linux 4.0.1_alpha20050430).
GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=48339
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../../../i686-pc-linux-gnu/bin/as
-V -Qy -o cpptest.o cpptest.s
GNU assembler version 2.16.90.0.2 (i686-pc-linux-gnu) using BFD version
2.16.90.0.2 20050429
/usr/libexec/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/collect2 --eh-frame-hdr
-m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o gcc401
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../../crt1.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../../crti.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/crtbegin.o
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../../../i686-pc-linux-gnu/lib
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../.. cpptest.o -lstdc++
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/crtend.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.1-alpha20050430/../../../crtn.o
--
Summary: C++ performance regression with -Os
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: deemkay at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
@ 2005-05-01 8:32 ` deemkay at gmail dot com
2005-05-01 13:34 ` pinskia at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: deemkay at gmail dot com @ 2005-05-01 8:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From deemkay at gmail dot com 2005-05-01 08:31 -------
Created an attachment (id=8780)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8780&action=view)
cpptest.ii
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
2005-05-01 8:32 ` [Bug c++/21314] " deemkay at gmail dot com
@ 2005-05-01 13:34 ` pinskia at gcc dot gnu dot org
2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 13:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-01 13:34 -------
-Os is compile for size if the size is smaller than there is no bug. We don't care about runtime speed
really at -Os.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (2 preceding siblings ...)
2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
@ 2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
2005-05-01 13:36 ` [Bug target/21314] " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 13:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-01 13:35 -------
Also this is a modified compiler from Gentoo, can you try an unmodified one.
--
What |Removed |Added
----------------------------------------------------------------------------
Version|4.0.0 |4.0.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
2005-05-01 8:32 ` [Bug c++/21314] " deemkay at gmail dot com
2005-05-01 13:34 ` pinskia at gcc dot gnu dot org
@ 2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 13:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-01 13:35 -------
Oh, also I cannot reproduce the slow down that you are getting.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (3 preceding siblings ...)
2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
@ 2005-05-01 13:36 ` pinskia at gcc dot gnu dot org
2005-05-01 14:26 ` giovannibajo at libero dot it
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-01 13:36 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |target
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (4 preceding siblings ...)
2005-05-01 13:36 ` [Bug target/21314] " pinskia at gcc dot gnu dot org
@ 2005-05-01 14:26 ` giovannibajo at libero dot it
2005-05-01 18:09 ` deemkay at gmail dot com
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2005-05-01 14:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2005-05-01 14:26 -------
Yes, mostly we don't care, but it's a two-fold regression so it should be
justified by a significant decrease in size, otherwise it's just a bad
regression. I almost think it's because of Honza's inline patches.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (5 preceding siblings ...)
2005-05-01 14:26 ` giovannibajo at libero dot it
@ 2005-05-01 18:09 ` deemkay at gmail dot com
2005-05-02 1:17 ` deemkay at gmail dot com
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: deemkay at gmail dot com @ 2005-05-01 18:09 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From deemkay at gmail dot com 2005-05-01 18:08 -------
hmm. code size is actually bigger with -Os.
-rwxr-xr-x 1 dirtyepic users 15689 May 1 12:02 pr21314-O0
-rwxr-xr-x 1 dirtyepic users 8333 May 1 12:02 pr21314-O1
-rwxr-xr-x 1 dirtyepic users 8405 May 1 11:35 pr21314-O2
-rwxr-xr-x 1 dirtyepic users 8157 May 1 12:03 pr21314-O3
-rwxr-xr-x 1 dirtyepic users 12989 May 1 11:35 pr21314-Os
( $ g++ -Ox -Wall -march=pentium3 cpptest.cpp -o pr21314-Ox )
the only modification should be the branding.. but if you can't reproduce i
must have overlooked something. i'll do a manual build and see if it goes away.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ size and performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (7 preceding siblings ...)
2005-05-02 1:17 ` deemkay at gmail dot com
@ 2005-05-02 1:17 ` deemkay at gmail dot com
2005-05-03 13:42 ` ivan at yosifov dot net
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: deemkay at gmail dot com @ 2005-05-02 1:17 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|C++ performance regression |C++ size and performance
|with -Os |regression with -Os
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (6 preceding siblings ...)
2005-05-01 18:09 ` deemkay at gmail dot com
@ 2005-05-02 1:17 ` deemkay at gmail dot com
2005-05-02 1:17 ` [Bug target/21314] C++ size and " deemkay at gmail dot com
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: deemkay at gmail dot com @ 2005-05-02 1:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From deemkay at gmail dot com 2005-05-02 01:17 -------
dirtyepic ~/work $ ~/gcc-4.0-20050430/bin/g++ -O0 -Wall -march=pentium3
cpptest.cpp -o new-pr21314-O0
dirtyepic ~/work $ ~/gcc-4.0-20050430/bin/g++ -O1 -Wall -march=pentium3
cpptest.cpp -o new-pr21314-O1
dirtyepic ~/work $ ~/gcc-4.0-20050430/bin/g++ -O2 -Wall -march=pentium3
cpptest.cpp -o new-pr21314-O2
dirtyepic ~/work $ ~/gcc-4.0-20050430/bin/g++ -O3 -Wall -march=pentium3
cpptest.cpp -o new-pr21314-O3
dirtyepic ~/work $ ~/gcc-4.0-20050430/bin/g++ -Os -Wall -march=pentium3
cpptest.cpp -o new-pr21314-Os
-rwxr-xr-x 1 dirtyepic users 15609 May 1 18:59 new-pr21314-O0
-rwxr-xr-x 1 dirtyepic users 8245 May 1 18:59 new-pr21314-O1
-rwxr-xr-x 1 dirtyepic users 8317 May 1 18:59 new-pr21314-O2
-rwxr-xr-x 1 dirtyepic users 8069 May 1 18:59 new-pr21314-O3
-rwxr-xr-x 1 dirtyepic users 12901 May 1 18:59 new-pr21314-Os
dirtyepic ~/work $ ./new-pr21314-O0
0
time: 20.420000
dirtyepic ~/work $ ./new-pr21314-O1
0
time: 7.490000
dirtyepic ~/work $ ./new-pr21314-O2
0
time: 6.950000
dirtyepic ~/work $ ./new-pr21314-O3
0
time: 7.030000
dirtyepic ~/work $ ./new-pr21314-Os
0
time: 16.680000
the performance regression i can understand is not a priority. but the size
regression is surprising.
dirtyepic ~/work $ ~/gcc-4.0-20050430/bin/g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0-20050430/configure
--enable-version-specific-runtime-libs
--prefix=/home/dirtyepic/gcc-4.0-20050430/ --host=i686-pc-linux-gnu
--build=i686-pc-linux-gnu --disable-altivec --disable-nls --with-system-zlib
--disable-checking --disable-werror --disable-libunwind-exceptions
--disable-multilib --disable-libgcj --enable-languages=c,c++ --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.0.1 20050430 (prerelease)
let me know if there's any other data that would help.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ size and performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (8 preceding siblings ...)
2005-05-02 1:17 ` [Bug target/21314] C++ size and " deemkay at gmail dot com
@ 2005-05-03 13:42 ` ivan at yosifov dot net
2005-05-12 8:10 ` dann at godzilla dot ics dot uci dot edu
2005-05-21 7:33 ` deemkay at gmail dot com
11 siblings, 0 replies; 13+ messages in thread
From: ivan at yosifov dot net @ 2005-05-03 13:42 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |ivan at yosifov dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ size and performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (9 preceding siblings ...)
2005-05-03 13:42 ` ivan at yosifov dot net
@ 2005-05-12 8:10 ` dann at godzilla dot ics dot uci dot edu
2005-05-21 7:33 ` deemkay at gmail dot com
11 siblings, 0 replies; 13+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2005-05-12 8:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dann at godzilla dot ics dot uci dot edu 2005-05-12 08:09 -------
(In reply to comment #6)
> hmm. code size is actually bigger with -Os.
>
> -rwxr-xr-x 1 dirtyepic users 15689 May 1 12:02 pr21314-O0
> -rwxr-xr-x 1 dirtyepic users 8333 May 1 12:02 pr21314-O1
> -rwxr-xr-x 1 dirtyepic users 8405 May 1 11:35 pr21314-O2
> -rwxr-xr-x 1 dirtyepic users 8157 May 1 12:03 pr21314-O3
> -rwxr-xr-x 1 dirtyepic users 12989 May 1 11:35 pr21314-Os
Don't look at the sizes shown by 'ls -l' look at the text size (as shown by
size -f)
You can also use 'nm' to see the size of the main function (all the interesting
code is in there, right?)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/21314] C++ size and performance regression with -Os
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
` (10 preceding siblings ...)
2005-05-12 8:10 ` dann at godzilla dot ics dot uci dot edu
@ 2005-05-21 7:33 ` deemkay at gmail dot com
11 siblings, 0 replies; 13+ messages in thread
From: deemkay at gmail dot com @ 2005-05-21 7:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From deemkay at gmail dot com 2005-05-21 07:33 -------
i think this might be a dupe of #21529, and the original person who provided the
code has also opened a PR (although for a different reason), so i'd like to
close this. thanks anyways.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21314
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2005-05-21 7:33 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-01 8:30 [Bug c++/21314] New: C++ performance regression with -Os deemkay at gmail dot com
2005-05-01 8:32 ` [Bug c++/21314] " deemkay at gmail dot com
2005-05-01 13:34 ` pinskia at gcc dot gnu dot org
2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
2005-05-01 13:35 ` pinskia at gcc dot gnu dot org
2005-05-01 13:36 ` [Bug target/21314] " pinskia at gcc dot gnu dot org
2005-05-01 14:26 ` giovannibajo at libero dot it
2005-05-01 18:09 ` deemkay at gmail dot com
2005-05-02 1:17 ` deemkay at gmail dot com
2005-05-02 1:17 ` [Bug target/21314] C++ size and " deemkay at gmail dot com
2005-05-03 13:42 ` ivan at yosifov dot net
2005-05-12 8:10 ` dann at godzilla dot ics dot uci dot edu
2005-05-21 7:33 ` deemkay at gmail 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).