| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
In the free-threaded build, _PyWeakref_GET_REF() no longer takes the striped weakref list lock. The referent's memory stays readable if it is freed concurrently because object heaps delay page reuse with QSBR, and wr_object only ever transitions from the referent to Py_None, so _Py_TryIncrefCompare() is sufficient. clear_weakref_lock_held() now uses release stores instead of sequentially consistent stores. The weakref list lock orders the list updates, and the lock-free read only requires that the store of Py_None happens before the referent's memory can be reused.
| return NULL; | ||
| } | ||
| #endif | ||
| if (_Py_TryIncref(obj)) { |
There was a problem hiding this comment.
This can be a simple incref now
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
In the free-threaded build, change _PyWeakref_GET_REF() so it no longer takes the striped weakref list lock. The referent's memory stays readable if it is freed concurrently because object heaps delay page reuse with QSBR, and wr_object only ever transitions from the referent to Py_None, so _Py_TryIncrefCompare() is sufficient.
Use release store for clear_weakref_lock_held(), instead of sequentially consistent stores. The weakref list lock orders the list updates, and the lock-free read only requires that the store of Py_None happens before the referent's memory can be reused.
The benchmark results below are based on a C extension implementing a weak-map using either PyUnstable_TryIncRef() (borrowed refereces) vs using weak references. Thread scaling of "get, N threads, private maps" (ns per op, lower is better):