mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-115103: Implement delayed memory reclamation (QSBR) (#115180)
This adds a safe memory reclamation scheme based on FreeBSD's "GUS" and quiescent state based reclamation (QSBR). The API provides a mechanism for callers to detect when it is safe to free memory that may be concurrently accessed by readers.
This commit is contained in:
parent
711f42de2e
commit
5903190727
18 changed files with 577 additions and 2 deletions
|
@ -86,6 +86,12 @@
|
|||
#define PRE_DISPATCH_GOTO() ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
#define QSBR_QUIESCENT_STATE(tstate) _Py_qsbr_quiescent_state(((_PyThreadStateImpl *)tstate)->qsbr)
|
||||
#else
|
||||
#define QSBR_QUIESCENT_STATE(tstate)
|
||||
#endif
|
||||
|
||||
|
||||
/* Do interpreter dispatch accounting for tracing and instrumentation */
|
||||
#define DISPATCH() \
|
||||
|
@ -117,6 +123,7 @@
|
|||
|
||||
#define CHECK_EVAL_BREAKER() \
|
||||
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY(); \
|
||||
QSBR_QUIESCENT_STATE(tstate); \
|
||||
if (_Py_atomic_load_uintptr_relaxed(&tstate->interp->ceval.eval_breaker) & _PY_EVAL_EVENTS_MASK) { \
|
||||
if (_Py_HandlePending(tstate) != 0) { \
|
||||
GOTO_ERROR(error); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue