This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/5001: g++ 3.0.2 getline is too slow
- From: mayer at tux dot org
- To: gcc-gnats at gcc dot gnu dot org
- Cc: mayer at tux dot org
- Date: Mon, 3 Dec 2001 17:03:32 -0800 (PST)
- Subject: c++/5001: g++ 3.0.2 getline is too slow
- Reply-to: mayer at tux dot org
>Number: 5001
>Category: c++
>Synopsis: g++ 3.0.2 getline is too slow
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Dec 03 17:06:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Uwe F. Mayer
>Release: 3.0.2
>Organization:
tux.org
>Environment:
System: SunOS hydra 5.6 Generic_105181-16 sun4u sparc SUNW,Ultra-2
Architecture: sun4
host: sparc-sun-solaris2.6
build: sparc-sun-solaris2.6
target: sparc-sun-solaris2.6
configured with: ../gcc/configure --prefix=/work/hyd01/td/sw/gcc_3_0_2_release --disable-nls --disable-threads --disable-shared --enable-languages=c,c++,f77,objc
>Description:
The getline() call of g++ version 3.0.x is slow if compared to previous
versions of g++ (for example, version 2.95.3). I tried this on various
SunOS boxes, running SunOS 5.6 or 5.8, and g++ versions 3.0.1 and 3.0.2,
having g++ compiled with single-threads only, or compiled with
multi-thread support.
A sample program exhibiting this problem is:
#include <iostream>
#include <fstream>
#include <cstdio> // for BUFSIZ=1024
using namespace std;
int main (int argc, char * argv[])
{
if (2!=argc) { cerr << "Please provide a filename\n"; }
ifstream in(argv[1]);
char buffer[BUFSIZ];
while( ! in.eof()) {
in.getline(buffer, BUFSIZ);
}
}
If compiled with g++ version 3.0.2 this program reads 100,000 lines with
79 characters (plus newline) each in about 4.5 seconds. On the same machine,
if compiled with g++ version 2.95.3, the program needs for the same input
file only about 0.25 seconds.
A similar program in C using fgets() does NOT have this slow-down problem
with gcc version 3.0.2.
>How-To-Repeat:
See the Description field above.
>Fix:
I am guessing some kind of synchronization problem connected with the
buffering strategy, but I might be way off target...
>Release-Note:
>Audit-Trail:
>Unformatted: