logoalt Hacker News

tialaramex • today at 2:17 AM • 1 reply • view on HN

I don't think fearless concurrency is strongly related to the atomic memory ordering model.

C++ 11 wants to model two non-trivial orderings, Acquire-Release and Consume-Release, but only Acquire-Release is actually usable. So yes, C and Rust both also choose to offer Acquire-Release ordering like C++ but it's also clear that the universe of possibilities is actually smaller than WG21 realised when C++ 11 was developed.

If on your first random stab you guess 65537 is prime, you're correct and you might foolishly assume all those Fermat Numbers are prime and then try say, 4294967297. Nope, that's divisible by 641 for some reason. There are only Five of these Fermat Primes so far as we know, they weren't common after all.


Replies

haberman • today at 3:14 AM

My understanding is that Consume is actually a desirable semantic that models what algorithms often want, and would allow for more optimization than Acquire if implemented properly, but that its failure was due almost entirely to it being difficult to implement correctly in compilers. In particular, the semantic is difficult to preserve across all compiler passes, especially given that existing compilers are essentially 20-40 years of accumulated optimizations that were never designed to preserve this semantic.

I sometimes wonder how difficult it would be for a compiler that was designed from the outset to implement Consume correctly.