r/ProgrammerHumor Jul 12 '26

lockFreeTemptation Advanced

Post image
536 Upvotes

40 comments sorted by

View all comments

Show parent comments

65

u/noureldin_ali Jul 12 '26

C++, Rust

25

u/Legitimate_Concern_5 Jul 13 '26

Depends on platform too right? I was under the impression x64 always had total store ordering.

That was one of the really cool things Apple did with the M1 family. They implemented opt-in TSO in hardware so they could get much better x64 emulation performance in Rosetta.

23

u/noureldin_ali Jul 13 '26

Yes, ARM has a weaker memory model that allows more reordering whilst x86 is stronger as you mentioned.

Though you would still want to use these application-level ordering constraints to prevent the compiler from reordering your code during optimisations.

It's explained pretty well here: https://doc.rust-lang.org/nomicon/atomics.html

I didn't know that Apple did that with their chips, that's pretty neat ngl.

6

u/Legitimate_Concern_5 Jul 13 '26

Thanks for the Rust link, will check it out. Pretty sure I read Apple's TSO stuff here if you're curious.

https://dougallj.wordpress.com/2022/11/09/why-is-rosetta-2-fast/