Feature or enhancement
Proposal:
In the free-threaded build, all operations on ob_ref_shared use sequentially consistent atomics. Full ordering is stronger than the biased reference counting protocol requires, and on ARM64 the ordered instructions are measurably slower under contention. Instead, we could (and I think should) match what C++ shared_ptr implementations do which is relaxed increfs and acquire/release decrefs 1 2 3 4.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
Feature or enhancement
Proposal:
In the free-threaded build, all operations on ob_ref_shared use sequentially consistent atomics. Full ordering is stronger than the biased reference counting protocol requires, and on ARM64 the ordered instructions are measurably slower under contention. Instead, we could (and I think should) match what C++ shared_ptr implementations do which is relaxed increfs and acquire/release decrefs 1 2 3 4.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
Footnotes
https://github.com/llvm/llvm-project/blob/a005951a12a9f5cd1e11e9c59cbb52d74fcffe4f/libcxx/include/__memory/shared_count.h#L27-L42 ↩
https://github.com/boostorg/smart_ptr/blob/6e945160d788b8efdfc49ba4af1f8797cacd7c97/include/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp#L41-L66 ↩
https://github.com/rust-lang/rust/blob/8925ea358a0f265ca61026aadc7ecc506c545cbe/library/alloc/src/sync.rs#L2409-L2420 ↩
https://github.com/rust-lang/rust/blob/8925ea358a0f265ca61026aadc7ecc506c545cbe/library/alloc/src/sync.rs#L2875-L2903 ↩