-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
SpinLock: Overhaul false sharing prevention #99168
Conversation
@yretenai, following up here. Could you please test this one? |
058a1f8
to
5eb30dd
Compare
557c73e
to
67737d5
Compare
1000 force-pushes later... 😅 |
67737d5
to
a5caeeb
Compare
AVX2 and AVX512 builds are fixed with this patchset. Please check if performance is improved or degraded with the new cacheline stuff. |
@Calinou, could you please give this a go? |
Tested myself. Performance stays compared to prior to this PR, noise aside. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me.
Thanks! |
Still, for the records, we would really like to be able to rely on alignment and base this on it. @hpvb is looking into making Godot allocation aware of alignment. |
@RandomShaper I'll make a pr for memory.cpp/h asap. It should be a relatively small fix. |
This changes how false sharing in
SpinLock
is prevented. Formerly, alignment attributes were used. The problem with that is objects containingSpinLock
s could be allocated in a way that the alignment is not honored, leading to crashes.This PR also applies the new approach to the Apple implementation.
This approach could be refactored into a more general one that we may want to use in other sync primitives. However, the point is now to fix the only case we have at the moment.
Fixes crashes stated in #85167 (comment).
Bugsquad edit: