Skip to content

Up-to-date TODO list for per-interpreter GIL. #78

Description

@ericsnowcurrently

I'm moving the TODO, etc. to https://github.com/ericsnowcurrently/multi-core-python/wiki/0-The-Plan


Here's a rough TODO list, sort of in order (a lot can be done in parallel).

Note that most of these items fall out of Tools/c-analyzer/cpython/globals-to-fix.tsv. (Run ./python Tools/c-analyzer/table-file.py Tools/c-analyzer/cpython/globals-to-fix.tsv to get counts.)

(python/cpython#84692)

Primary Tasks

  • analysis (summary)
  • proposal: "A Per-Interpreter GIL"
  • tooling (to identify global variables)
    • analyze requirements & make design
    • implement the tool (Tools/c-analyzer)
    • re-enable CI check to prevent addition of more globals (may need fixes)
  • resolve main blockers
    • objects exposed in public C-API (solve with immortal objects)
    • shared vs. per-interpreter allocators (solve with mimalloc)
    • impact on extension maintainers (solve with docs, work with numpy)
  • implementation
    • prerequisites
      • simplify runtime init/fini code (PEP 432, PEP 587)
      • introduce _PyRuntimeState
    • consolidate globals (#81057)
      • ... (move a bunch of stuff into _PyRuntimeState)
      • ... (statically init a bunch of global objects)
      • (maybe?) move some state from PyInterpreterState to _PyRuntimeState
      • drop _Py_IDENTIFIER() in extensions (or modify it to use a statically initialized str?)
        • Modules/_asynciomodule.c
        • Modules/_ctypes/callbacks.c
        • Modules/_ctypes/callproc.c
        • Modules/_ctypes/_ctypes.c
        • Modules/_ctypes/stgdict.c
        • Modules/_cursesmodule.c
        • Modules/_datetimemodule.c
        • Modules/_elementtree.c
        • Modules/_json.c
        • Modules/ossaudiodev.c
        • Modules/_testcapimodule.c
        • Programs/_testembed.c
      • statically init latin-1 chars
      • statically init currently cached str objects
      • deal with PyArg_Parser (#90928, #82322, faster-cpython#281)
      • pull remaining objects into _PyRuntimeState
      • pull remaining state into _PyRuntimeState
    • prep for per-interpreter state
      • solve per-interpreter state for core/builtin static types (e.g. dynamic lookup for some attrs)
      • solve for extensions
      • make some vars atomic?
      • convert stdlib extensions to PEP 630 (see bpo-40077, PEP 687 & the SC discussion)
    • add new C-API and implement runtime machinery
      • ...
    • move state (incl. GIL) to PyInterpreterState
      • enforce restrictions on importing extensions...
      • finally: move some state/objects to PyInterpreterState
      • 💥 move the GIL to PyInterpreterState 💥

Solutions for Blockers

Immortal Objects:

  • analysis, design, and initial discussion (bpo-40255)
  • implement basic solution (gh-19474)
  • run benchmarks (incl. with all objects immortalized at end of runtime init)
  • (maybe?) prepare a contingency plan for if we don't end up with immortal objects
  • write a proposal (PEP 683)
  • present at the language summit
  • enumerate other strategies for getting back to performance neutral
  • implement them
  • PEP accepted
  • merge implementation

mimalloc (thread-safe, performant allocator):

  • get mimalloc working as CPython's allocator (Christian: ...)
  • add static analyzer support (ASAN, valgrind) (Daan)
  • resolve problem with leaking large blocks (Daan/Christian)
  • resolve PGO issues on Windows (Eric: contact MSVC team)
  • merge the implementation
  • sort out GIL guarantees for allocator API

Reduce Impact on Extension Maintainers:

  • add docs (i.e. copy PEP 630)
  • (probably) add some new C-API to solve pain points
  • work with numpy, specifically, to add support for multiple interpreters
  • work with cython

Secondary Tasks

  • finish "c-analyzer.py data count"
  • fix "c-analyzer.py data check" & add to CI
  • statically init other immutables
  • ...

Other Related Items

  • PEP 554 (stdlib module to expose multiple interpreters)
  • help numpy, cython, etc.
  • PEP: add Public C-API as replacement for _Py_IDENTIFIER() (@zooba's staticstr?)
  • "subinterpreters" project: Subinterpreters (view)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions