-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
BVH - thread safety option #48892
BVH - thread safety option #48892
Conversation
Added optional thread safe version through template argument and runtime switch, that wraps access with a mutex.
UpdateAfter extensive testing neither myself or @pouleyKetchoupp has seen contention for threads in linux or windows. So it could well be that the existing thread protection from using rendering and physics through servers is working correctly. We still can't discount it as the cause of the linked issues, as we have been unable to replicate them. But the lack of evidence does move it down from number one suspect spot. As a result of this I've split the other bug fix into a separate PR, #49057. Until we pinpoint the problem, it still may be worth having this available in one of the betas for testing. Or at least having those affected able to download the artifacts from here in order to try. |
Thanks! |
Added optional thread safe version through template argument and runtime switch, that wraps access with a mutex.
Related to #48749
Related to #48790
This temporarily also adds a project setting to turn on and off use of the mutex to hopefully allow us to test whether the bug is to do with threading. The project setting is
rendering/threads/thread_safe_bvh
and defaults to off.On suggestion from @pouleyKetchoupp I've also added a
try_lock
so it should print a warning if it detects a contended situation (which would indicate that thread safety was needed).Notes
thread_safe_bvh
on my linux system. It could be that uncontended mutexes are very cheap on my system, although I can't vouch for this on other platforms.try_lock
I can't seem to get a contended lock on my system with the project from the issue (or any other). So hopefully the bug is something simpler, and we won't need to use a mutex in production. It still needs testing on windows, or by someone who can reproduce the bug.Update
The default value for the
thread_safe_bvh
is now off (if we introduce it set to on, we may never find out whether thread safety was the cause of the problems).It now operates on both the rendering BVH, and the physics BVHs for 3d and 2d. The project setting name is still the same. I'm unsure a little about having it still as
rendering/threads/thread_safe_bvh
for this reason, but there doesn't seem to be a sensible section to put it into. It may well be a temporary setting - if we discover that thread safety is required, we should probably leave it on in all cases and remove the option, and vice versa if it is not the cause of the bug.Instructions for Testers
rendering/threads/thread_safe_bvh
set to on. Please post here whether it fixes the visual bugs with eitherthread_safe_bvh
switched on or off, and especially whether you see an error / warning messageInfo : multithread BVH access detected (benign)
.