]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-112175: Add `eval_breaker` to `PyThreadState` (#115194)
authorBrett Simmers <swtaarrs@users.noreply.github.com>
Tue, 20 Feb 2024 14:57:48 +0000 (06:57 -0800)
committerGitHub <noreply@github.com>
Tue, 20 Feb 2024 14:57:48 +0000 (09:57 -0500)
commit0749244d13412d7cb5b53d834f586f2198f5b9a6
tree06387c5b41cd14cdf230f71eab6fd92873c3d5a9
parente71468ba4f5fb2da0cefe9e923b01811cb53fb5f
gh-112175: Add `eval_breaker` to `PyThreadState` (#115194)

This change adds an `eval_breaker` field to `PyThreadState`. The primary
motivation is for performance in free-threaded builds: with thread-local eval
breakers, we can stop a specific thread (e.g., for an async exception) without
interrupting other threads.

The source of truth for the global instrumentation version is stored in the
`instrumentation_version` field in PyInterpreterState. Threads usually read the
version from their local `eval_breaker`, where it continues to be colocated
with the eval breaker bits.
19 files changed:
Include/cpython/pystate.h
Include/internal/pycore_ceval.h
Include/internal/pycore_ceval_state.h
Include/internal/pycore_gc.h
Include/internal/pycore_runtime.h
Misc/NEWS.d/next/Core and Builtins/2024-02-09-18-59-22.gh-issue-112175.qglugr.rst [new file with mode: 0644]
Modules/signalmodule.c
Python/brc.c
Python/bytecodes.c
Python/ceval.c
Python/ceval_gil.c
Python/ceval_macros.h
Python/executor_cases.c.h
Python/gc.c
Python/gc_free_threading.c
Python/generated_cases.c.h
Python/instrumentation.c
Python/pylifecycle.c
Python/pystate.c