struct _PyExecutorObject *executor_deletion_list_head;
struct _PyExecutorObject *cold_executor;
int executor_deletion_list_remaining_capacity;
- size_t trace_run_counter;
+ size_t executor_creation_counter;
_rare_events rare_events;
PyDict_WatchCallback builtins_dict_watcher;
#endif
// Used as the threshold to trigger executor invalidation when
-// trace_run_counter is greater than this value.
-#define JIT_CLEANUP_THRESHOLD 100000
+// executor_creation_counter is greater than this value.
+// This value is arbitrary and was not optimized.
+#define JIT_CLEANUP_THRESHOLD 1000
#define TRACE_STACK_SIZE 5
#include "pycore_audit.h" // _PySys_Audit()
#include "pycore_backoff.h"
#include "pycore_cell.h" // PyCell_GetRef()
-#include "pycore_ceval.h"
#include "pycore_code.h"
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
#include "pycore_function.h"
tier2 op(_MAKE_WARM, (--)) {
current_executor->vm_data.warm = true;
- // It's okay if this ends up going negative.
- if (--tstate->interp->trace_run_counter == 0) {
- _Py_set_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
- }
}
tier2 op(_FATAL_ERROR, (--)) {
if ((breaker & _PY_EVAL_JIT_INVALIDATE_COLD_BIT) != 0) {
_Py_unset_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
_Py_Executors_InvalidateCold(tstate->interp);
- tstate->interp->trace_run_counter = JIT_CLEANUP_THRESHOLD;
+ tstate->interp->executor_creation_counter = JIT_CLEANUP_THRESHOLD;
}
/* GIL drop request */
case _MAKE_WARM: {
current_executor->vm_data.warm = true;
- if (--tstate->interp->trace_run_counter == 0) {
- _Py_set_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
- }
break;
}
#include "pycore_interp.h"
#include "pycore_backoff.h"
#include "pycore_bitutils.h" // _Py_popcount32()
+#include "pycore_ceval.h" // _Py_set_eval_breaker_bit
#include "pycore_code.h" // _Py_GetBaseCodeUnit
#include "pycore_function.h" // _PyFunction_LookupByVersion()
#include "pycore_interpframe.h"
return -1;
}
assert(length <= UOP_MAX_TRACE_LENGTH);
+
+ // Check executor coldness
+ PyThreadState *tstate = PyThreadState_Get();
+ // It's okay if this ends up going negative.
+ if (--tstate->interp->executor_creation_counter == 0) {
+ _Py_set_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
+ }
+
*exec_ptr = executor;
return 1;
}
interp->executor_list_head = NULL;
interp->executor_deletion_list_head = NULL;
interp->executor_deletion_list_remaining_capacity = 0;
- interp->trace_run_counter = JIT_CLEANUP_THRESHOLD;
+ interp->executor_creation_counter = JIT_CLEANUP_THRESHOLD;
if (interp != &runtime->_main_interpreter) {
/* Fix the self-referential, statically initialized fields. */
interp->dtoa = (struct _dtoa_state)_dtoa_state_INIT(interp);