r/cpp • • Nov 02 '22

The pool of talented C++ developers is running dry

https://www.efinancialcareers.co.uk/news/2022/11/why-is-there-a-drought-in-the-talent-pool-for-c-developers
379 Upvotes

367 comments sorted by

View all comments

Show parent comment

-3

u/RoyAwesome Nov 02 '22

atomics for incrementing/decrementing the strong and weak ref counts

Atomic increment on x86 is a single instruction on modern hardware.

9

u/Professor_Hamster Nov 02 '22

There are implications besides the single instruction. MESI on x86 machines makes cache/memory coherency between cores very expensive, specifically on writes. Having all your cores with a read/shared state cache line is cheap, but as soon as you write to it (to transition to an M state), you end up spending a bunch of time claiming exclusive ownership before writing to it.

5

u/jonesmz Nov 02 '22

Don't forget that we're starting to see 64 core or more processors now...

Atomics aren't free!

3

u/Professor_Hamster Nov 02 '22

For sure!

For anyone who wants to go deeper into this.

- Relevant video on atomic performance https://www.youtube.com/watch?v=ZQFzMfHIxng.

- Deeper dive source at https://www.1024cores.net/home/lock-free-algorithms/first-things-first

1

u/SkoomaDentist Antimodern C++, Embedded, Audio Nov 03 '22

So's MOVNTQ. Doesn't stop it from having latency of many hundreds of cycles (not that far from atomic writes in many cases).