From 060a96f1a9a901b01ed304aa82b886d248ca1cb6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 4 Apr 2024 08:03:27 -0700 Subject: gh-116968: Reimplement Tier 2 counters (#117144) Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``), shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The API used for adaptive specialization counters is changed but the behavior is (supposed to be) identical. The behavior of the Tier 2 counters is changed: - There are no longer dynamic thresholds (we never varied these). - All counters now use the same exponential backoff. - The counter for ``JUMP_BACKWARD`` starts counting down from 16. - The ``temperature`` in side exits starts counting down from 64. --- Modules/_testinternalcapi.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Modules/_testinternalcapi.c') diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index 6b5d99f6ffa..758e88e288b 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -10,6 +10,7 @@ #undef NDEBUG #include "Python.h" +#include "pycore_backoff.h" // JUMP_BACKWARD_INITIAL_VALUE #include "pycore_bitutils.h" // _Py_bswap32() #include "pycore_bytesobject.h" // _PyBytes_Find() #include "pycore_ceval.h" // _PyEval_AddPendingCall() @@ -1819,6 +1820,11 @@ module_exec(PyObject *module) return 1; } + if (PyModule_Add(module, "TIER2_THRESHOLD", + PyLong_FromLong(JUMP_BACKWARD_INITIAL_VALUE)) < 0) { + return 1; + } + return 0; } -- cgit v1.2.3