libstdc++/4470: Thousands of seeks per read from cin

kw+gnats@cs.cmu.edu kw+gnats@cs.cmu.edu
Thu Oct 4 12:56:00 GMT 2001


>Number:         4470
>Category:       libstdc++
>Synopsis:       Thousands of seeks per read from cin
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 04 12:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Kevin Watkins
>Release:        gcc version 3.0.1
>Organization:
>Environment:
RedHat 7.1 (Linux 2.4.10 i686)
gcc was built from source with ./configure && make && make install
>Description:
The following code:

  #include <iostream>
  int main() {
    char buf[1024];
    while (std::cin.read(buf, 1024));
  }

when compiled thus:

  g++ -static qwe.cc

and run thus:

  ./a.out < /usr/dict/words

generates thousands of seek system calls per read system
call, as revealed by strace.  This is an insurmountable
performance problem.
The problem is specific to cin; it has not been observed
for files opened via the ifstream constructor.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list