Repository navigation
fix: Dispatcher - back off with SpinWait while waiting for a batch to finish - #3685
Closed
Kryptos-FR wants to merge 1 commit into
Closed
Kryptos-FR wants to merge 1 commit into
Kryptos-FR wants to merge 1 commit into
Conversation
When there is no work to steal, the wait loops in Dispatcher.ForBatched and WaitCompletion spun on TryCooperate without any pause. A thread waiting this way (e.g. the editor game thread waiting for a shader compile) burns a full core, and under Wine the runtime can't suspend it for a garbage collection: the GC retries NtSuspendThread forever and the process freezes (seen with the WPF GameStudio scene editor). Call SpinWait.SpinOnce when TryCooperate finds nothing to do; it spins briefly, then yields and sleeps, so the waiting thread still picks up work promptly.
Collaborator
|
Thanks for adding me into this loop, I believe #3600 is what you're looking for. Have a look at the discussion we had there, your input for the editor side of the issue would be very welcome. Although yours does take care of Sorts completion as well, so maybe add on top of that PR. |
Member
Author
|
@Eideren Unfortunately I'm not enough of an expert to understand why the original commit of that PR (which is similar to mine) wasn't a good idea. My limited testing worked with this change but it wasn't heavy load as you mentioned. Or to be more precise, without that change it, the editor wasn't working on Wine. (along with this other fix: #3684). |
Member
Author
|
Closed in favor of #3600. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Details
When there is no work to steal, the wait loops in
Dispatcher.ForBatchedandWaitCompletionspun onTryCooperatewithout any pause. A thread waiting this way (e.g. the editor game thread waiting for a shader compile) burns a full core, and under Wine the runtime can't suspend it for a garbage collection: the GC retriesNtSuspendThreadforever and the process freezes (seen with the WPF GameStudio scene editor).Call
SpinWait.SpinOncewhenTryCooperatefinds nothing to do; it spins briefly, then yields and sleeps, so the waiting thread still picks up work promptly.Types of changes
Checklist