Repository navigation
Conversation
LOAD_GLOBAL_MODULE, LOAD_GLOBAL_BUILTINS and LOAD_ATTR_MODULE loaded me_value with consume ordering, which is relaxed outside TSan. For deferred-refcount, immortal or thread-owned values the try-incref path does no further ordered load, so a reader could observe a new global without observing writes made before it was stored. Use acquire loads to pair with the release store in the dict.
Member
Author
|
CC @colesbury @mpage |
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.
LOAD_GLOBAL_MODULE, LOAD_GLOBAL_BUILTINS and LOAD_ATTR_MODULE load
me_valuewith consume ordering, which is relaxed outside TSan. For deferred-refcount, immortal or thread-owned values the try-incref path does no further ordered load, so a reader could observe a new global without observing writes made before it was stored. Use acquire loads to pair with the release store in the dict.This is the most significant divergence from the memory order documented by GH-162178. The performance impact of this change seems small. For strongly ordered architectures, like AMD64, there is no difference. For weak, like ARM, the
me_valueload goes from something likeldr x0, [x8, #0x28]toldapur x0, [x8, #0x28](an acquire load).The results below are from a Macbook M3 Pro, using performance cores. The --scale 1000, median of 15 runs, averaged over 4 rounds that alternated between the two builds. Times are in ms; diff is branch vs. main, so positive means the branch is slower.
bench_globals.py
Here is a test that shows memory order violations, when run without this patch. This run on a Macbook M3 Pro and fails about every 30 seconds of run time. Its a bit difficult to provoke the issue, the globals need to be on separate cache lines.
mo-litmus-globals.py