Qt6 Windows slower than Qt6 Ubuntu
- 
@Joe-von-Habsburg You did not post any code, so nobody knows what exactly you're doing and how This is my code for take data with get request. void DataReceiver::start() { _connection++; if(_connection > 1) return; qDebug() << "Starting take data"; _takeData = true; while(_takeData){ QDateTime time1 = QDateTime::currentDateTime(); _sample = getData(54664); QDateTime time3 = QDateTime::currentDateTime(); if(_takeIQData) _iq = getData(54665); QDateTime time2 = QDateTime::currentDateTime(); qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1; emit sendData(_sample, _iq); } qDebug() << "Finished taking data"; } QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); QUrl apiUrl(url); QNetworkAccessManager manager; QNetworkRequest request(apiUrl); QNetworkReply *reply = manager.get(request); QEventLoop loop; connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); loop.exec(); if (reply->error() == QNetworkReply::NoError) { QByteArray responseData = reply->readAll(); return responseData; reply->deleteLater(); } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } reply->deleteLater(); return NULL; }
- 
This is my code for take data with get request. void DataReceiver::start() { _connection++; if(_connection > 1) return; qDebug() << "Starting take data"; _takeData = true; while(_takeData){ QDateTime time1 = QDateTime::currentDateTime(); _sample = getData(54664); QDateTime time3 = QDateTime::currentDateTime(); if(_takeIQData) _iq = getData(54665); QDateTime time2 = QDateTime::currentDateTime(); qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1; emit sendData(_sample, _iq); } qDebug() << "Finished taking data"; } QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); QUrl apiUrl(url); QNetworkAccessManager manager; QNetworkRequest request(apiUrl); QNetworkReply *reply = manager.get(request); QEventLoop loop; connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); loop.exec(); if (reply->error() == QNetworkReply::NoError) { QByteArray responseData = reply->readAll(); return responseData; reply->deleteLater(); } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } reply->deleteLater(); return NULL; }@Joe-von-Habsburg 
 If you are calling this multiple times at least correct so as not to leak theQNetworkReply. Probably irrelevant, but just in case.How do timings compare on each platform quite outside of a Qt program? 
- 
@Joe-von-Habsburg 
 If you are calling this multiple times at least correct so as not to leak theQNetworkReply. Probably irrelevant, but just in case.How do timings compare on each platform quite outside of a Qt program? @JonB 
 I watch debug line and graphic. The data which is came, it's graphic data and I draw i it (drawing is 30ms).Debug line : qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;In ubuntu : 150ms 0ms 150ms 
 In windows : 400ms 0ms 400msHow can I take data with different way ? Can you give any example? Note: The data is come with only get request. 
- 
@JonB 
 I watch debug line and graphic. The data which is came, it's graphic data and I draw i it (drawing is 30ms).Debug line : qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;In ubuntu : 150ms 0ms 150ms 
 In windows : 400ms 0ms 400msHow can I take data with different way ? Can you give any example? Note: The data is come with only get request. @Joe-von-Habsburg 
 I have suggested what you should test first, but you have said nothing each time.. I also suggested you do not test anything with the "debug" in "debug line and graphic".
- 
@Joe-von-Habsburg 
 I have suggested what you should test first, but you have said nothing each time.. I also suggested you do not test anything with the "debug" in "debug line and graphic".@JonB I run release versions, and I saw same thing. Any advice for get request ? And is it possible, gcc more performance than msvc ? 
- 
@JonB I run release versions, and I saw same thing. Any advice for get request ? And is it possible, gcc more performance than msvc ? @Joe-von-Habsburg 
 No, compiler is not going to make any difference when fetching data over a network and it's taking hundreds of milliseconds.
- 
@Joe-von-Habsburg 
 No, compiler is not going to make any difference when fetching data over a network and it's taking hundreds of milliseconds.I wrote basic program just taking data. (Because I suspect other code lines slow me). I saw same output. Can you give me code example for get request ? 
- 
@Joe-von-Habsburg 
 If you are calling this multiple times at least correct so as not to leak theQNetworkReply. Probably irrelevant, but just in case.How do timings compare on each platform quite outside of a Qt program? 
- 
@JonB said in Qt6 Windows slower than Qt6 Ubuntu: How do timings compare on each platform quite outside of a Qt program? @JonB I watched graphic speed 
- 
@JonB I watched graphic speed @Joe-von-Habsburg You should read more carefully what others write. What @JonB suggested is that you try to get the data with a non Qt application on both platforms to see whether the behaviour is the same or not... 
- 
@Joe-von-Habsburg You should read more carefully what others write. What @JonB suggested is that you try to get the data with a non Qt application on both platforms to see whether the behaviour is the same or not... @jsulm I used javascript for get request. const deneme = async() => { while(true){ var date1 = new Date(); var res = await fetch('http://localhost:54664/sample') var data = await res.json(); console.log("sample len : ",data.samples[0].length) var date2 = new Date(); var res2 = await fetch('http://localhost:54665/sample') var data2 = await res2.json(); console.log("sample len : ",data2.samples[0].length) var date3 = new Date(); console.log("sample : ", date2-date1, " - iq : ", date3 - date2, " - time : ", date3 - date1); } } deneme();I saw same times between ubuntu and windows (90ms). 
 I think the problem is in windows Qt. Any idea ?
- 
@jsulm I used javascript for get request. const deneme = async() => { while(true){ var date1 = new Date(); var res = await fetch('http://localhost:54664/sample') var data = await res.json(); console.log("sample len : ",data.samples[0].length) var date2 = new Date(); var res2 = await fetch('http://localhost:54665/sample') var data2 = await res2.json(); console.log("sample len : ",data2.samples[0].length) var date3 = new Date(); console.log("sample : ", date2-date1, " - iq : ", date3 - date2, " - time : ", date3 - date1); } } deneme();I saw same times between ubuntu and windows (90ms). 
 I think the problem is in windows Qt. Any idea ?@Joe-von-Habsburg You should try to do your networking properly: without local event loops. Qt is asynchronous. 
- 
@Joe-von-Habsburg You should try to do your networking properly: without local event loops. Qt is asynchronous. ... And you should/must not recreate the QNetworkAcceesManager every time. 
- 
... And you should/must not recreate the QNetworkAcceesManager every time. @Christian-Ehrlicher said in Qt6 Windows slower than Qt6 Ubuntu: And you should/must not recreate the QNetworkAcceesManager every time. This work for me. Thank you so much :) 
- 
... And you should/must not recreate the QNetworkAcceesManager every time. I have another question. I received some times between ubuntu and windows (65ms). Everything is ok. But, sometimes windows rising 350ms for one packet. In ubuntu just max 80ms. QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); _apiUrl.setUrl(url); _request.setUrl(_apiUrl); _reply = _manager.get(_request); connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit); _loop.exec(); if (_reply->error() == QNetworkReply::NoError) { QByteArray responseData = _reply->readAll(); _reply->deleteLater(); return responseData; } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } _reply->deleteLater(); return NULL; }Do you know, why it's rising ? What can I do another, after take data ? 
- 
I have another question. I received some times between ubuntu and windows (65ms). Everything is ok. But, sometimes windows rising 350ms for one packet. In ubuntu just max 80ms. QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); _apiUrl.setUrl(url); _request.setUrl(_apiUrl); _reply = _manager.get(_request); connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit); _loop.exec(); if (_reply->error() == QNetworkReply::NoError) { QByteArray responseData = _reply->readAll(); _reply->deleteLater(); return responseData; } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } _reply->deleteLater(); return NULL; }Do you know, why it's rising ? What can I do another, after take data ? @Joe-von-Habsburg I found the reason. Thanks a lot :) <3 
- 
@Joe-von-Habsburg I found the reason. Thanks a lot :) <3 @Joe-von-Habsburg And what was the reason? Windows defender? 
- 
@Joe-von-Habsburg And what was the reason? Windows defender? @Volker75 said in Qt6 Windows slower than Qt6 Ubuntu: And what was the reason? Windows defender? another networkmanager..... @Christian-Ehrlicher , @JonB , @jsulm Hi guys, I need your help. When I run the my program (only data receive) after 30min, my ram will be 20gb. It's increase always. I tested it in Ubuntu and Windows and I saw same thing. What should I do after take data? QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); _apiUrl.setUrl(url); _request.setUrl(_apiUrl); reply = _manager.get(_request); connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit); _loop.exec(); if (reply->error() == QNetworkReply::NoError) { QByteArray responseData = reply->readAll(); reply->deleteLater(); return responseData; } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } reply->deleteLater(); return {}; }if I use my code like that : QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); QUrl _apiUrl(url); QNetworkRequest _request(_apiUrl); QEventLoop _loop; QNetworkAccessManager _manager; QNetworkReply *reply = _manager.get(_request); connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit); _loop.exec(); if (reply->error() == QNetworkReply::NoError) { QByteArray responseData = reply->readAll(); reply->deleteLater(); return responseData; } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } reply->deleteLater(); return {}; }Memory will not rise but response time slow.... 
- 
@Volker75 said in Qt6 Windows slower than Qt6 Ubuntu: And what was the reason? Windows defender? another networkmanager..... @Christian-Ehrlicher , @JonB , @jsulm Hi guys, I need your help. When I run the my program (only data receive) after 30min, my ram will be 20gb. It's increase always. I tested it in Ubuntu and Windows and I saw same thing. What should I do after take data? QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); _apiUrl.setUrl(url); _request.setUrl(_apiUrl); reply = _manager.get(_request); connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit); _loop.exec(); if (reply->error() == QNetworkReply::NoError) { QByteArray responseData = reply->readAll(); reply->deleteLater(); return responseData; } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } reply->deleteLater(); return {}; }if I use my code like that : QByteArray DataReceiver::getData(int port) { QString url = QString("http://localhost:%1/sample").arg(port); QUrl _apiUrl(url); QNetworkRequest _request(_apiUrl); QEventLoop _loop; QNetworkAccessManager _manager; QNetworkReply *reply = _manager.get(_request); connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit); _loop.exec(); if (reply->error() == QNetworkReply::NoError) { QByteArray responseData = reply->readAll(); reply->deleteLater(); return responseData; } else { QString _error = tr("Error"); QString _spectrum_error = tr("Spectrum error."); QMessageBox::critical(nullptr, _error, _spectrum_error); stop(); } reply->deleteLater(); return {}; }Memory will not rise but response time slow.... @Joe-von-Habsburg 
 Is the difference due to theQNetworkAccessManager _manager;or to theQNetworkReply *reply = _manager.get(_request);?
 In the bad case you might connect toreply->destroyed()to make sure it is indeed getting freed.
- 
@Joe-von-Habsburg 
 Is the difference due to theQNetworkAccessManager _manager;or to theQNetworkReply *reply = _manager.get(_request);?
 In the bad case you might connect toreply->destroyed()to make sure it is indeed getting freed.According to my tests, if I rebuild the NetworkManager, my memory usage does not increase. But this time my receiving time is slowing down. If I do not recreate the NetworkManager, my reception time decreases but memory usage increases. connect(reply, &QNetworkReply::destroyed, this, &DataReceiver::replyDeleted);it's work, reply deleted 
 


