I wrote:
> The bottom line is that this is a cygwin bug and we can't fix it,
> sorry.  Hopefully someone with more love for this platform than I
> (I've done my time, heh) can forward this to them and get it fixed.

No, that's dumb.  I may not like windows, but cygwin is one of the few
things that makes it bearable. :)

Attached is a SimGear-less version of the test file with the same
performance characteristics.  Happily, the problem can be exhibited
against a mingw32 build with the same compiler, so you don't even have
to reboot to see the awful breakage. :)

I'll try to dig up a cygwin mailing list to which to submit this.

#include <ctype.h>
#include <vector>
#include <string>

// Reads and splits the input file on whitespace.  Sample input file:
// perl -e 'for($i=0; $i<160000; $i++) { print "AAAAA " x 12, "\n" }' \
//    > cygspd.dat
// $ g++ -O2 -o cygspd cygspd.cc
// $ time ./cygspd cygspd.dat
// real    0m26.545s
// user    0m26.468s
// sys     0m0.031s
// g++ -mno-cygwin -O2 -o cygspd cygspd.cc
// time ./cygspd cygspd.dat
// real    0m1.689s
// user    0m0.015s
// sys     0m0.015s
// VERY bad performance characteristics when linked against
// cygwin.dll.  Watch under strace, and note that every N reads, there
// is an inexplicable delay of several milliseconds.  Spinning in the
// malloc implementation?

using namespace std;

vector<string> split(const string& str)
    vector<string> result;
    string::size_type i=0, j, len=str.length();
    while(i < len) {
        while(i < len && isspace(str[i])) ++i;
        j = i;
        while (i < len && !isspace(str[i])) ++i;
        if(j < i) {
            result.push_back(str.substr(j, i-j));
            while(i < len && isspace(str[i])) ++i;
    return result;

#define BUFSZ 2048
char buf[BUFSZ];

int main(int argc, char** argv)
    FILE* input = argc > 1 ? fopen(argv[1], "r") : stdin;
    vector<string> toks;
    while(fgets(buf, BUFSZ, input))
        toks = split(buf);
Flightgear-devel mailing list

Reply via email to