Skip to content

gh-111964: Implement stop-the-world pauses#112471

Merged
ericsnowcurrently merged 5 commits intopython:mainfrom
colesbury:stop-the-world
Jan 23, 2024
Merged

gh-111964: Implement stop-the-world pauses#112471
ericsnowcurrently merged 5 commits intopython:mainfrom
colesbury:stop-the-world

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Nov 27, 2023

The --disable-gil builds occasionally need to pause all but one thread. Some examples include:

  • Cyclic garbage collection, where this is often called a "stop the world event"
  • Before calling fork(), to ensure a consistent state for internal data structures
  • During interpreter shutdown, to ensure that daemon threads aren't accessing Python objects

This adds the following functions to implement global and per-interpreter pauses:

  • _PyRuntimeState_StopTheWorld and _PyRuntimeState_StartTheWorld
  • _PyInterpreterState_StopTheWorld and _PyInterpreterState_StartTheWorld

These functions are no-ops outside of the --disable-gil build.

This also adds _PyRWMutex, a "readers-writer" lock, which is used to serialize global stop-the-world pauses with per-interpreter pauses.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants