Skip to content

Add relaxed atomic inc/dec intrinsics #6598

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

Closed
brson opened this issue May 18, 2013 · 4 comments
Closed

Add relaxed atomic inc/dec intrinsics #6598

brson opened this issue May 18, 2013 · 4 comments
Labels
A-codegen Area: Code generation A-concurrency Area: Concurrency A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@brson
Copy link
Contributor

brson commented May 18, 2013

The exchange heap uses atomic inc/dec to track allocations. These don't require a fence. Verify that using relaxed atomics here is a win.

@brson
Copy link
Contributor Author

brson commented May 22, 2013

Relaxed atomics generate the same assembly here.

@brson brson closed this as completed May 22, 2013
@bblum
Copy link
Contributor

bblum commented Jun 12, 2013

Reopening this issue (at least for more discussion). I'm rewriting sync::rwlock to use an atomic uint for performance, and in some cases I'd like to use the relaxed consistency ordering.

I don't expect the assembly would change at all on a strongly-consistent architecture, unless LLVM decided on its own to reorder the instructions. I do expect that we'd see a difference on ARM -- we could save a few global barrier instructions.

@bblum bblum reopened this Jun 12, 2013
@Thiez
Copy link
Contributor

Thiez commented Jul 9, 2013

@bblum is correct, on x86 it will be hard or impossible to see the difference between the stronger and weaker atomics (and in some cases, even between atomics and non-atomics) because the architecture already has very strong guarantees. This presentation might be relevant:
http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-1-of-2
http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2
About a third in the second video some architectures are compared.

@toddaaro
Copy link
Contributor

toddaaro commented Aug 6, 2013

I believe this is finished and can be closed. If I'm wrong re-open it. I'm thinking of @Aatch's set of atomic intrinsic commits.

@toddaaro toddaaro closed this as completed Aug 6, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 12, 2021
Add xor case to `manual swap` lint

Continue of rust-lang#7153
closes rust-lang#6598

changelog: Add "xor swap" case to [`manual_swap`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-concurrency Area: Concurrency A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

4 participants