Skip to content

Commit f89efae

Browse files
committed
JIT: Streamline MAKE_WARM - move coldness check to executor creation
1 parent c779f23 commit f89efae

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

Include/internal/pycore_optimizer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ PyAPI_FUNC(void) _Py_Executors_InvalidateCold(PyInterpreterState *interp);
116116

117117
// Used as the threshold to trigger executor invalidation when
118118
// trace_run_counter is greater than this value.
119-
#define JIT_CLEANUP_THRESHOLD 100000
119+
// TODO: Test what should be the optimal value for this.
120+
#define JIT_CLEANUP_THRESHOLD 1000
120121

121122
// This is the length of the trace we project initially.
122123
#define UOP_MAX_TRACE_LENGTH 800

Python/bytecodes.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "pycore_audit.h" // _PySys_Audit()
1212
#include "pycore_backoff.h"
1313
#include "pycore_cell.h" // PyCell_GetRef()
14-
#include "pycore_ceval.h"
1514
#include "pycore_code.h"
1615
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
1716
#include "pycore_function.h"
@@ -5367,10 +5366,6 @@ dummy_func(
53675366

53685367
tier2 op(_MAKE_WARM, (--)) {
53695368
current_executor->vm_data.warm = true;
5370-
// It's okay if this ends up going negative.
5371-
if (--tstate->interp->trace_run_counter == 0) {
5372-
_Py_set_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
5373-
}
53745369
}
53755370

53765371
tier2 op(_FATAL_ERROR, (--)) {

Python/executor_cases.c.h

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "pycore_interp.h"
77
#include "pycore_backoff.h"
88
#include "pycore_bitutils.h" // _Py_popcount32()
9+
#include "pycore_ceval.h" // _Py_set_eval_breaker_bit
910
#include "pycore_code.h" // _Py_GetBaseCodeUnit
1011
#include "pycore_function.h" // _PyFunction_LookupByVersion()
1112
#include "pycore_interpframe.h"
@@ -1322,6 +1323,14 @@ uop_optimize(
13221323
return -1;
13231324
}
13241325
assert(length <= UOP_MAX_TRACE_LENGTH);
1326+
1327+
// Check executor coldness
1328+
PyThreadState *tstate = PyThreadState_Get();
1329+
// It's okay if this ends up going negative.
1330+
if (--tstate->interp->trace_run_counter == 0) {
1331+
_Py_set_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
1332+
}
1333+
13251334
*exec_ptr = executor;
13261335
return 1;
13271336
}

0 commit comments

Comments
 (0)