From a1b679572e7156bc4299819e73235dc608d4a570 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Fri, 28 Jul 2023 13:55:25 +0100 Subject: [PATCH] GH-104580: Put `eval_breaker` back at the start of the interpreter state. (GH-107383) --- Include/internal/pycore_ceval_state.h | 4 +++- Include/internal/pycore_interp.h | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_ceval_state.h b/Include/internal/pycore_ceval_state.h index e56e43c6e0c..1ebfcc9bebd 100644 --- a/Include/internal/pycore_ceval_state.h +++ b/Include/internal/pycore_ceval_state.h @@ -84,7 +84,9 @@ struct _ceval_runtime_state { struct _ceval_state { /* This single variable consolidates all requests to break out of - the fast path in the eval loop. */ + * the fast path in the eval loop. + * It is by far the hottest field in this struct and + * should be placed at the beginning. */ _Py_atomic_int eval_breaker; /* Request for dropping the GIL */ _Py_atomic_int gil_drop_request; diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index bd6a9f28f46..91c473e58ea 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -48,6 +48,11 @@ struct _Py_long_state { */ struct _is { + /* This struct countains the eval_breaker, + * which is by far the hottest field in this struct + * and should be placed at the beginning. */ + struct _ceval_state ceval; + PyInterpreterState *next; int64_t id; @@ -109,8 +114,6 @@ struct _is { // Dictionary of the builtins module PyObject *builtins; - struct _ceval_state ceval; - struct _import_state imports; /* The per-interpreter GIL, which might not be used. */