public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15522] New: slow IO in g++ 3.X.Y
@ 2004-05-19 12:15 eric at cs dot umn dot edu
2004-05-19 12:16 ` [Bug libstdc++/15522] " pcarlini at suse dot de
0 siblings, 1 reply; 2+ messages in thread
From: eric at cs dot umn dot edu @ 2004-05-19 12:15 UTC (permalink / raw)
To: gcc-bugs
I believe I have discovered a performance problem in how g++ 3.X.X handles
output. I originally encountered the problem when doing file IO, but was able
to duplicate the major slow down writing to stdout and directing it into a file.
I have duplicated the problem on a variety of linux and solaris installations,
using a variety of different compilers and have included some details of the
experiments below.
In general, IO in the 3.X.X branch is anywhere from 3 to 50 times slower than
doing the same IO in C. The 2.9X.Y branch however does not have this problem.
eric@thingie slow_io $ cat /proc/cpuinfo
[snip snip]
processor : 3
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.40GHz
stepping : 9
cpu MHz : 2393.052
cache size : 512 KB
physical id : 3
siblings : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips : 4767.74
eric@thingie slow_io $ uname -a
Linux thingie 2.6.1-mm4 #1 SMP Sat Jan 17 07:18:18 Local time zone must be
set--see zic i686 Intel(R) Xeon(TM) CPU 2.40GHz GenuineIntel GNU/Linux
eric@thingie slow_io $ g++ --version
g++ (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@thingie slow_io $ gcc --version
gcc (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@thingie slow_io $ cat test.cpp
#include <iostream>
using namespace std;
int main()
{
for(int i=0; i<1000000;++i) {
cout <<"I am writing out a lot of text to see how long it takes\n";
}
return 0;
}
eric@thingie slow_io $ g++ -O3 test.cpp -o slow_cpp
eric@thingie slow_io $ time ./slow_cpp > slow.txt
real 0m16.272s
user 0m12.652s
sys 0m0.141s
eric@thingie slow_io $ cat test.c
#include <stdio.h>
int main()
{
int i;
for(i=0; i<1000000;++i) {
printf("I am writing out a lot of text to see how long it takes\n");
}
return(0);
}
eric@thingie slow_io $ time ./fast_c > fast.txt
real 0m0.305s
user 0m0.130s
sys 0m0.122s
eric@thingie slow_io $ diff slow.txt fast.txt
eric@thingie slow_io $
****************************************************
[eric@kaitain slow_io]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.80GHz
stepping : 7
cpu MHz : 2791.085
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips : 5570.56
[eric@kaitain slow_io]$ uname -a
Linux kaitain 2.4.23 #2 Mon Dec 22 09:40:11 GMT 2003 i686 i686
i386 GNU/Linux
[eric@kaitain slow_io]$ g++ --version
g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[eric@kaitain slow_io]$ gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[eric@kaitain slow_io]$ g++ -O3 test.cpp -o slow_cpp
[eric@kaitain slow_io]$ time ./slow_cpp > slow.txt
real 0m14.068s
user 0m13.820s
sys 0m0.200s
[eric@kaitain slow_io]$ time ./fast_c > fast.txt
real 0m0.376s
user 0m0.190s
sys 0m0.110s
[eric@kaitain slow_io]$ diff slow.txt fast.txt
[eric@kaitain slow_io]$
**************************************
eric@lucy:~/slow_io$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 6
model name : Celeron (Mendocino)
stepping : 5
cpu MHz : 501.148
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
sep_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 mmx fxsr
bogomips : 999.42
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 6
model name : Celeron (Mendocino)
stepping : 5
cpu MHz : 501.148
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
sep_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 mmx fxsr
bogomips : 999.42
eric@lucy:~/slow_io$ uname -a
Linux lucy 2.2.16 #2 SMP Thu Aug 3 15:29:25 CDT 2000 i686 unknown
eric@lucy:~/slow_io$ g++ --version
egcs-2.91.66
eric@lucy:~/slow_io$ gcc --version
egcs-2.91.66
eric@lucy:~/slow_io$ g++ -O3 test.cpp -o slow_cpp
eric@lucy:~/slow_io$ time ./slow_cpp > slow.txt
real 0m1.563s
user 0m1.040s
sys 0m0.520s
eric@lucy:~/slow_io$ cat test.c
eric@lucy:~/slow_io$ time ./fast_c > fast.txt
real 0m1.575s
user 0m0.980s
sys 0m0.590s
eric@lucy:~/slow_io$ diff slow.txt fast.txt
eric@lucy:~/slow_io$
********************************************************
eric@s1 (~/slow_io) % uname -a
SunOS s1 5.8 Generic_108528-09 sun4u sparc
eric@s1 (~/slow_io) % g++ --version
g++ (GCC) 3.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@s1 (~/slow_io) % gcc --version
gcc (GCC) 3.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@s1 (~/slow_io) % g++ -O3 test.cpp -o slow_cpp
eric@s1 (~/slow_io) % time ./slow_cpp > slow.txt
60.35u 0.54s 1:01.60 98.8%
eric@s1 (~/slow_io) % gcc -O3 test.c -o fast_c
eric@s1 (~/slow_io) % time ./fast_c > fast.txt
0.85u 0.49s 0:21.60 6.2%
eric@s1 (~/slow_io) % diff slow.txt fast.txt
eric@s1 (~/slow_io) %
*************************************
The below was done on a single computer where I was able to load different
compilers.
eric@takin (~/slow_io) % cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 1
model name : Intel(R) Pentium(R) 4 CPU 1.80GHz
stepping : 2
cpu MHz : 1794.597
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 3578.26
eric@takin (~/slow_io) % uname -a
Linux takin 2.4.25-1-686 #1 Fri Mar 12 20:12:02 CST 2004 i686 unknown
eric@takin (~/slow_io) % g++ --version
2.95.4
eric@takin (~/slow_io) % gcc --version
2.95.4
eric@takin (~/slow_io) % cat test.cpp
#include <iostream>
using namespace std;
int main()
{
for(int i=0; i<1000000;++i) {
cout <<"I am writing out a lot of text to see how long it takes\n";
}
return 0;
}
eric@takin (~/slow_io) % g++ -O3 test.cpp -o slow_cpp
eric@takin (~/slow_io) % time ./slow_cpp > slow.txt
0.540u 0.150s 0:09.18 7.5% 0+0k 0+0io 135pf+0w
eric@takin (~/slow_io) % cat test.c
#include <stdio.h>
int main()
{
int i;
for(i=0; i<1000000;++i) {
printf("I am writing out a lot of text to see how long it takes\n");
}
fflush(stdout);
return(0);
}
eric@takin (~/slow_io) % gcc -O3 test.c -o fast_c
eric@takin (~/slow_io) % time ./fast_c > fast.txt
0.580u 0.160s 0:09.72 7.6% 0+0k 0+0io 82pf+0w
eric@takin (~/slow_io) % diff slow.txt fast.txt
eric@takin (~/slow_io) %
**************************************
eric@takin (~/slow_io) % uname -a
Linux takin 2.4.25-1-686 #1 Fri Mar 12 20:12:02 CST 2004 i686 unknown
eric@takin (~/slow_io) % g++ --version
g++ (GCC) 3.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@takin (~/slow_io) % gcc --version
gcc (GCC) 3.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@takin (~/slow_io) % g++ -O3 test.cpp -o slow_cpp
eric@takin (~/slow_io) % time ./slow_cpp > slow.txt
22.680u 0.700s 0:26.33 88.7% 0+0k 0+0io 183pf+0w
eric@takin (~/slow_io) % gcc -O3 test.c -o fast_c
eric@takin (~/slow_io) % time ./fast_c > fast.txt
0.450u 0.200s 0:09.45 6.8% 0+0k 0+0io 80pf+0w
eric@takin (~/slow_io) % diff slow.txt fast.txt
eric@takin (~/slow_io) % rm fast.txt slow.txt slow_cpp fast_c
eric@takin (~/slow_io) %
****************************************************
eric@takin (~/slow_io) % g++ --version
g++ (GCC) 3.2.3
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@takin (~/slow_io) % gcc --version
gcc (GCC) 3.2.3
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@takin (~/slow_io) % g++ -O3 test.cpp -o slow_cpp
eric@takin (~/slow_io) % time ./slow_cpp > slow.txt
22.420u 0.720s 0:25.93 89.2% 0+0k 0+0io 198pf+0w
eric@takin (~/slow_io) % gcc -O3 test.c -o fast_c
eric@takin (~/slow_io) % time ./fast_c > fast.txt
0.500u 0.120s 0:09.37 6.6% 0+0k 0+0io 80pf+0w
***************************************************************
eric@takin (~/slow_io) % g++ --version
g++ (GCC) 3.3.2
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@takin (~/slow_io) % gcc --version
gcc (GCC) 3.3.2
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eric@takin (~/slow_io) % g++ -O3 test.cpp -o slow_cpp
eric@takin (~/slow_io) % time ./slow_cpp > slow.txt
21.750u 0.680s 0:29.66 75.6% 0+0k 0+0io 207pf+0w
eric@takin (~/slow_io) % gcc -O3 test.c -o fast_c
eric@takin (~/slow_io) % time ./fast_c > fast.txt
0.570u 0.100s 0:11.48 5.8% 0+0k 0+0io 80pf+0w
eric@takin (~/slow_io) %
--
Summary: slow IO in g++ 3.X.Y
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eric at cs dot umn dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15522
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libstdc++/15522] slow IO in g++ 3.X.Y
2004-05-19 12:15 [Bug c++/15522] New: slow IO in g++ 3.X.Y eric at cs dot umn dot edu
@ 2004-05-19 12:16 ` pcarlini at suse dot de
0 siblings, 0 replies; 2+ messages in thread
From: pcarlini at suse dot de @ 2004-05-19 12:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pcarlini at suse dot de 2004-05-18 19:22 -------
This is already fixed in gcc3.4.0. On my machine (P4-2400), I get,
approximatively (averaging would be needed):
"C++"
0.180u 0.230s 0:00.46 89.1% 0+0k 0+0io 201pf+0w
"C"
0.170u 0.200s 0:00.44 84.0% 0+0k 0+0io 74pf+0w
Thanks for your report, anyway!
P.S. If sync with stdio is not really needed, for best performance consider
calling 'std::ios::sync_with_stdio(false);' before doing any I/O: with 3.3.x
it makes *a lot* of difference.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|c++ |libstdc++
Known to work| |3.4.0
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15522
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-18 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 12:15 [Bug c++/15522] New: slow IO in g++ 3.X.Y eric at cs dot umn dot edu
2004-05-19 12:16 ` [Bug libstdc++/15522] " 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).