PDA

View Full Version : QProcess extremely slow on Windows?



Pepe
25th March 2007, 23:40
I'm using a QProcess to call an external application. I also have to read and parse the output of that program.

The problem is that when the external program outputs a lot of messages (several lines per second), the external program slows down (the external program is a media player, so this is unacceptable).

Maybe my application is not fast enough to process the output and the QProcess buffer fills.

I thought on optimize the function that parses the lines, but the problem is that even not doing nothing, just reading the buffer with readStdout, just that, it already produces the slow down. So it seems that the bottleneck is in QProcess.

This only happens on Windows, tested with Qt 4.2.2 and 4.2.3. On linux it doesn't happen at all (tested with Qt 3.3 and 4.2.3).

To maintain compatibility with Qt 3 I'm using a Q3Process but I tried to convert the code to use a Qt4 QProcess and the result is the same (or even worse).

I don't know how to fix this important problem.

Is there any way to tell QProcess to use a bigger buffer, maybe?

wysota
26th March 2007, 00:10
You can try to increase the buffer in a platform dependent way (it's a system buffer) in QProcess::setupChildProcess(). But you might just try reading the data faster. How did you organise the reading process?

Pepe
26th March 2007, 00:25
I've just simply connect the readyReadStdout and readyReadStderr signals to a function which read the data with readStdout(), and then processes it.

But as I said, just simply calling readStdout() (even without storing the result) makes the external process to slow down.

In Qt 4, it's similar, I connect the readyReadStandardOutput signal and read the data with readAllStandardOutput().