Fixes high cpu usage spikes on win10 - #656
Conversation
|
Thanks! cc. @AdrianKoshka |
|
cc. @walker0643 Do you remember if the issue #4 that was fixed there appears on windows <=7 or >=8? In this PR I issumed that change dbfb04a was made to fix behaviour on windows7, like qt bug linked above, but I'm not sure. |
|
@galkinvv Could you rebase on newest master to fix build failure on Mac? |
…nding Current code base don't use IEventQueue::isEmpty() method. Remove it to simplify IEventQueue API and to remove confusion with IEventQueueBuffer with same name. The IEventQueueBuffer::isEmpty() and all its implementations kept unchanged
fa588a0 to
91db66a
Compare
Fixes high cpu usage spikes on win10. When queue was containing messages of only non-QS_POSTMESSAGE type the "while (m_buffer->isEmpty())" busy-looped in EventQueue::getEvent since isEmpty was true (checked only QS_POSTMESSAGE message type), but waitForEvent returned immediately (checked more message types). Investigation shows that the difference was introduced in debauchee@dbfb04a6e to fix a problem with bad behaviour of GetQueueStatus Researching showed that a similar problem was fixed in Qt, and the solution was "pass different flags to GetQueueStatus depending on version of windows" https://bugreports.qt.io/browse/QTBUG-29097 So this patch makes changes to a barrier non-GUI core similar to Qt fix.
91db66a to
95f2a84
Compare
|
I've tested fixed client on windows 10 for 2-3 hours - works fine. However I didn't test windows 7 and server on windows 10 at all. |
|
Given https://codereview.qt-project.org/c/qt/qtbase/+/63327/2/src/corelib/kernel/qeventdispatcher_win.cpp I think the risk of this change is fairly small. |
Using barrierc on windows10 I noticed that sometimes but quite often, say 1 times of 5 opens of a task manager (even when server is offline) it begins utilizing 100% of a cpu core.
Fixes high cpu usage spikes on win10.
When queue was containing messages of only non-QS_POSTMESSAGE type the
"while (m_buffer->isEmpty())" busy-looped in EventQueue::getEvent
since isEmpty was true (checked only QS_POSTMESSAGE message type),
but waitForEvent returned immediately (checked more message types).
Investigation shows that the difference was introduced in
dbfb04a6e
to fix a problem with bad behaviour of GetQueueStatus
Researching showed that a similar problem was fixed in Qt,
and the solution was
"pass different flags to GetQueueStatus depending on version of windows"
https://bugreports.qt.io/browse/QTBUG-29097
So this patch makes changes to a barrier non-GUI core similar to Qt fix.
Unfortunately I'm not using barrier often now, so only basic tests were performed and only windows as a client, not as a server.
However, this PR is created since the problem may be common, so more testers may appear)