Hacker News new | ask | show | jobs
by charleslmunger 4 days ago
This is overstated in value; on arm systems with LSE it's faster to use that even for weak operations than to use ll/sc. Even if you are limited to ll/sc the compiler may not put your cas-loop body into the ll/sc region as there's limitations on how many and what type of instructions are permitted there.
2 comments

On ARM systems with LSE both weak and strong compile to the same CAS instruction anyway. On LL/SC, using strong means CPU will attempt to retry the same exchange on spurious failure, which increases likelihood that another thread will update the value in the meantime, requiring an outer loop retry.

On any plaform which implements strong exchange with zero overhead over weak exchange, we can safely assume they compile to the same thing, and use weak. The only reason to use `strong` is if you have a one-shot CAS operation and you don't want to write a retry loop.

Sure, with LSE. But you have to target LSE and get a system that actually contains it, i.e. not the default compiler flags and not the original AWS Graviton.