News for hackers. Stuff that matters.
Re:A safe, non-owning C++ pointer class by SkiFire13 on Monday September 29, 2025 @01:10AM (#45410501)
> not marginally higher cost of atomic inc/dec vs plain inc/dec.

Note that the difference is not so marginal, and the difference is not just in hardware instructions as the non-atomic operations generally allow for more optimizations by the compiler.

Re:A safe, non-owning C++ pointer class by loeg on Monday September 29, 2025 @02:18AM (#45410822)
The actual intrinsic is like 8-9 cycles on Zen4 or Ice Lake (vs 1 for plain add). It's something if you're banging on it in a hot loop, but otherwise not a ton. (If refcounting is hot in your design, your design is bad.)

It's comparable to like, two integer multiplies, or a single integer division. Yes, there is some effect on program order.