mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-101659: Isolate "obmalloc" State to Each Interpreter (gh-101660)
This is strictly about moving the "obmalloc" runtime state from `_PyRuntimeState` to `PyInterpreterState`. Doing so improves isolation between interpreters, specifically most of the memory (incl. objects) allocated for each interpreter's use. This is important for a per-interpreter GIL, but such isolation is valuable even without it. FWIW, a per-interpreter obmalloc is the proverbial canary-in-the-coalmine when it comes to the isolation of objects between interpreters. Any object that leaks (unintentionally) to another interpreter is highly likely to cause a crash (on debug builds at least). That's a useful thing to know, relative to interpreter isolation.
This commit is contained in:
parent
01be52e42e
commit
df3173d28e
20 changed files with 322 additions and 73 deletions
|
@ -29,7 +29,7 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
_pymem_allocators_debug_INIT, \
|
||||
_pymem_allocators_obj_arena_INIT, \
|
||||
}, \
|
||||
.obmalloc = _obmalloc_state_INIT(runtime.obmalloc), \
|
||||
.obmalloc = _obmalloc_global_state_INIT, \
|
||||
.pyhash_state = pyhash_state_INIT, \
|
||||
.signals = _signals_RUNTIME_INIT, \
|
||||
.interpreters = { \
|
||||
|
@ -93,6 +93,7 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
{ \
|
||||
.id_refcount = -1, \
|
||||
.imports = IMPORTS_INIT, \
|
||||
.obmalloc = _obmalloc_state_INIT(INTERP.obmalloc), \
|
||||
.ceval = { \
|
||||
.recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
|
||||
}, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue