Skip to content

Conversation

Al2Klimov
Copy link
Member

More relaxed memory_order = less safety guarantees = faster execution.

This is safe because std::shared_ptr does the same. See also: https://en.cppreference.com/w/cpp/atomic/memory_order "Typical use for relaxed memory ordering is incrementing counters, such as the reference counters of std::shared_ptr, since this only requires atomicity, but not ordering or synchronization (note that decrementing the std::shared_ptr counters requires acquire-release synchronization with the destructor)."

@Al2Klimov Al2Klimov added the core/quality Improve code, libraries, algorithms, inline docs label Jan 13, 2025
@cla-bot cla-bot bot added the cla/signed label Jan 13, 2025
@Al2Klimov Al2Klimov requested a review from oxzi January 21, 2025 09:50
@oxzi oxzi removed their request for review January 21, 2025 10:19
@oxzi
Copy link
Member

oxzi commented Jan 21, 2025

I have unassigned myself from this PR because I don't think I can give good feedback here.

However, could you please provide some deeper insights why this is a good idea? Perhaps some performance metrics? Generally speaking, "less safety guarantees" is something I would try to avoid at any cost.

@Al2Klimov
Copy link
Member Author

This is hard to measure, but we do those refcounts literally everywhere. IMAO a little more performance is better than no more performance.

Sure, I explicitly said "less safety guarantees". But I meant less than right now, not less than std::shared_ptr. I mean, if THEY are fine with it... 🤷‍♂️

@Al2Klimov Al2Klimov added the good first issue Good for newcomers label Apr 17, 2025
More relaxed memory_order = less safety guarantees = faster execution.

This is safe because std::shared_ptr does the same. See also:
https://en.cppreference.com/w/cpp/atomic/memory_order
"Typical use for relaxed memory ordering is incrementing counters, such as the reference counters of std::shared_ptr, since this only requires atomicity, but not ordering or synchronization (note that decrementing the std::shared_ptr counters requires acquire-release synchronization with the destructor)."
@Al2Klimov Al2Klimov force-pushed the intrusive_ptr_refcnt branch from 925a266 to c8dccd9 Compare April 30, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed core/quality Improve code, libraries, algorithms, inline docs good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants