http://bugs.winehq.org/show_bug.cgi?id=31438
--- Comment #122 from Heiko lil_tux@web.de --- (In reply to Alessandro Pignotti from comment #121)
I agree the docs says that TcpSockets should always be buffered, but this does not seem to be true. They definitely are buffered by default, but for HTTP connection the mode is changed in QHttpNetworkConnectionChannel::ensureConnection. You can see that when the connection is not SSL based it will pass the QIODevice::Unbuffered flag to the connectToHost call.
Damn, I should've seen that. Thanks for your insights and hinting. That 'new' feature of Qt. There's even a statement... " // Before Qt 4.6, we always set the send and receive buffer size to 49152 as // this was found to be an optimal value. However, modern OS // all have some kind of auto tuning for this and we therefore don't set // this explictly anymore. // If it introduces any performance regressions for Qt 4.6.x (x > 0) then // it will be put back in. // // You can use tests/manual/qhttpnetworkconnection to test HTTP download speed // with this. // // pre-4.6: // setReceiveBufferSize(49152); // setSendBufferSize(49152); "
Ok, your words are awesomely correct. Sorry for not believing at first. For now I've got another workaround: patch Qt5Network.dll Basically you just need to change byte 518626 from 0 to 1. That makes the QTcpSocket buffered again. Download speed went to 1,6MB/s.
cmp -bl Qt5Network.dll.orig Qt5Network.dll.patched
518626 0 ^@ 1 ^A
Still does feel wrong to me to repeatedly pull 1 byte from the socket (and to write QTcpSocket is always buffered into the doc).
So, kudos to Alessandro for really figuring the cause. Thanks!