Skip to content

Isolate the Default Object Allocator between Interpreters #101659

Description

@ericsnowcurrently

(see gh-100227)

By default, the allocator for the "object" and "mem" domains is historically known as "obmalloc". The implementation of the allocator is _PyObject_Malloc(), etc., for which the runtime state is found in _PyRuntimeState.obmalloc. Thus all interpreters currently share the runtime state for the default allocator.

Isolating that state to each interpreter is important for a per-interpreter GIL (my short-term motivation here), but there are other benefits. For example, it helps us manage resources (e.g. objects) relative to the lifecycle of each interpreter, and to do so more efficiently. Furthermore, any situation where we share memory between interpreters is an invitation for memory leaks and other bugs.

The solution here should be as simple as moving the "obmalloc" state to PyInterpreterState.

Linked PRs

Activity

  1. ericsnowcurrently commented on Feb 9, 2023

    @ericsnowcurrently
    MemberAuthor

    FYI, one consequence of debugging CI failures in gh-101660 is that I was reminded that we may be able to take advantage of an object's corresponding obmalloc pool/arena to determine to which interpreter that object belongs. I'll open an issue about that once this one is settled.

  2. moved this from In Review to Todo in Fancy CPython Boardon Feb 27, 2023
  3. moved this from Todo to In Progress in Fancy CPython Boardon Mar 9, 2023
  4. moved this from In Progress to In Review in Fancy CPython Boardon Mar 9, 2023
  5. added a commit that references this issue on Mar 13, 2023
  6. added a commit that references this issue on Mar 14, 2023
  7. added a commit that references this issue on Mar 27, 2023
  8. added 3 commits that reference this issue on Mar 31, 2023
  9. added 2 commits that reference this issue on Apr 8, 2023
  10. added 4 commits that reference this issue on Apr 11, 2023
  11. added a commit that references this issue on Apr 24, 2023
  12. moved this from In Review to Done in Fancy CPython Boardon Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions