public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5001: g++ 3.0.2 getline is too slow
@ 2001-12-03 17:06 mayer
0 siblings, 0 replies; 2+ messages in thread
From: mayer @ 2001-12-03 17:06 UTC (permalink / raw)
To: gcc-gnats; +Cc: mayer
>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:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/5001: g++ 3.0.2 getline is too slow
@ 2001-12-03 17:46 Zack Weinberg
0 siblings, 0 replies; 2+ messages in thread
From: Zack Weinberg @ 2001-12-03 17:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR libstdc++/5001; it has been noted by GNATS.
From: Zack Weinberg <zack@codesourcery.com>
To: mayer@tux.org
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/5001: g++ 3.0.2 getline is too slow
Date: Mon, 3 Dec 2001 17:36:59 -0800
On Mon, Dec 03, 2001 at 05:03:32PM -0800, mayer@tux.org wrote:
> 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.
Try putting ios::sync_with_stdio(false); at the beginning of your
test program. (I may have the syntax slightly wrong.)
zw
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-12-04 1:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-03 17:06 c++/5001: g++ 3.0.2 getline is too slow mayer
2001-12-03 17:46 Zack Weinberg
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).