Skip to content

Fixes high cpu usage spikes on win10 - #656

Merged
p12tic merged 2 commits into
debauchee:masterfrom
galkinvv:fix-win10-cpu-usage-spikes
Jun 4, 2020
Merged

Fixes high cpu usage spikes on win10#656
p12tic merged 2 commits into
debauchee:masterfrom
galkinvv:fix-win10-cpu-usage-spikes

Conversation

@galkinvv

@galkinvv galkinvv commented May 6, 2020

Copy link
Copy Markdown

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

p12tic commented May 6, 2020

Copy link
Copy Markdown
Member

Thanks!

cc. @AdrianKoshka

@galkinvv

galkinvv commented May 6, 2020

Copy link
Copy Markdown
Author

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

p12tic commented May 12, 2020

Copy link
Copy Markdown
Member

@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
Comment thread src/lib/platform/MSWindowsEventQueueBuffer.cpp Outdated
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
Copy Markdown
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

p12tic commented Jun 4, 2020

Copy link
Copy Markdown
Member

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