Skip to content

Remove some volatile use on objects in corelib #100969

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

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

stephentoub
Copy link
Member

From a review of usage sites, all of this use for lazy initialization now appears to be superfluous, given our documented memory model.

@stephentoub stephentoub requested review from jkotas and VSadov April 12, 2024 15:36
@ghost ghost added the area-Meta label Apr 12, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a new analyzer or something like that motivating this cleanup? Or is this just something that you have run into?

Personally, I like volatile as a documentation for lock-free code. I do not have a problem with deleting it where it is not needed.

@stephentoub
Copy link
Member Author

stephentoub commented Apr 13, 2024

It's motivated by @VSadov citing earlier this week that such usage still results in extra fences being emitted on arm (I don't have a machine handy to test on). If that's not the case, or if we can teach the jit somehow they can be elided, I agree it's better to leave them. If not, seems like unnecessary overhead.

@xtqqczze
Copy link
Contributor

@MihuBot

jkotas
jkotas previously requested changes Apr 13, 2024
From a review of the use, all of this use for lazy initialization now appears to be superfluous, given our documented memory model.
Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stephentoub stephentoub merged commit bc0380f into dotnet:main Apr 20, 2024
@stephentoub stephentoub deleted the removevolatile branch April 20, 2024 14:05
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
From a review of the use, all of this use for lazy initialization now appears to be superfluous, given our documented memory model.
@github-actions github-actions bot locked and limited conversation to collaborators May 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants