Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes high cpu usage spikes on win10 #656

Merged
merged 2 commits into from
Jun 4, 2020

Conversation

galkinvv
Copy link

@galkinvv galkinvv commented May 6, 2020

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)

@p12tic
Copy link
Member

p12tic commented May 6, 2020

Thanks!

cc. @AdrianKoshka

@galkinvv
Copy link
Author

galkinvv commented May 6, 2020

cc. @walker0643
If you interested in barrier and still remember any details about 2-year-old commit dbfb04a6e

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.

@p12tic
Copy link
Member

p12tic commented May 12, 2020

@galkinvv Could you rebase on newest master to fix build failure on Mac?

@shymega shymega added bug Something isn't working critical For critical bugs windows Related to Microsoft Windows labels May 12, 2020
…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
@galkinvv galkinvv force-pushed the fix-win10-cpu-usage-spikes branch from fa588a0 to 91db66a Compare May 12, 2020 22:37
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.
@galkinvv galkinvv force-pushed the fix-win10-cpu-usage-spikes branch from 91db66a to 95f2a84 Compare May 29, 2020 11:10
@galkinvv
Copy link
Author

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.

@p12tic
Copy link
Member

p12tic commented Jun 4, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical For critical bugs windows Related to Microsoft Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants