diff --git a/Include/internal/pycore_backoff.h b/Include/internal/pycore_backoff.h index b5e33fa8b7abc0..6d9e36b6a7741b 100644 --- a/Include/internal/pycore_backoff.h +++ b/Include/internal/pycore_backoff.h @@ -116,14 +116,13 @@ initial_jump_backoff_counter(void) * Must be larger than ADAPTIVE_COOLDOWN_VALUE, * otherwise when a side exit warms up we may construct * a new trace before the Tier 1 code has properly re-specialized. */ -#define SIDE_EXIT_INITIAL_VALUE 4095 -#define SIDE_EXIT_INITIAL_BACKOFF 12 +#define SIDE_EXIT_INITIAL_VALUE 16383 +#define SIDE_EXIT_INITIAL_BACKOFF 14 static inline _Py_BackoffCounter initial_temperature_backoff_counter(void) { - return make_backoff_counter(SIDE_EXIT_INITIAL_VALUE, - SIDE_EXIT_INITIAL_BACKOFF); + return forge_backoff_counter(SIDE_EXIT_INITIAL_VALUE); } /* Unreachable backoff counter. */ diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 7ffe2f5b940942..3db7b5713f2a97 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -4850,9 +4850,8 @@ dummy_func( Py_CLEAR(exit->executor); } if (exit->executor == NULL) { - _Py_BackoffCounter temperature = exit->temperature; - if (!backoff_counter_triggers(temperature)) { - exit->temperature = advance_backoff_counter(temperature); + if (exit->temperature.value_and_backoff) { + exit->temperature.value_and_backoff--; tstate->previous_executor = (PyObject *)current_executor; GOTO_TIER_ONE(target); } @@ -4865,7 +4864,7 @@ dummy_func( int chain_depth = current_executor->vm_data.chain_depth + 1; int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, chain_depth); if (optimized <= 0) { - exit->temperature = restart_backoff_counter(temperature); + exit->temperature = initial_temperature_backoff_counter(); if (optimized < 0) { GOTO_UNWIND(); } @@ -4965,13 +4964,13 @@ dummy_func( Py_INCREF(executor); } else { - if (!backoff_counter_triggers(exit->temperature)) { - exit->temperature = advance_backoff_counter(exit->temperature); + if (exit->temperature.value_and_backoff) { + exit->temperature.value_and_backoff--; GOTO_TIER_ONE(target); } int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, 0); if (optimized <= 0) { - exit->temperature = restart_backoff_counter(exit->temperature); + exit->temperature = initial_temperature_backoff_counter(); if (optimized < 0) { GOTO_UNWIND(); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 976a3429b2e603..8a825598eabc02 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -5722,9 +5722,8 @@ Py_CLEAR(exit->executor); } if (exit->executor == NULL) { - _Py_BackoffCounter temperature = exit->temperature; - if (!backoff_counter_triggers(temperature)) { - exit->temperature = advance_backoff_counter(temperature); + if (exit->temperature.value_and_backoff) { + exit->temperature.value_and_backoff--; tstate->previous_executor = (PyObject *)current_executor; GOTO_TIER_ONE(target); } @@ -5739,7 +5738,7 @@ int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, chain_depth); stack_pointer = _PyFrame_GetStackPointer(frame); if (optimized <= 0) { - exit->temperature = restart_backoff_counter(temperature); + exit->temperature = initial_temperature_backoff_counter(); if (optimized < 0) { GOTO_UNWIND(); } @@ -5913,15 +5912,15 @@ Py_INCREF(executor); } else { - if (!backoff_counter_triggers(exit->temperature)) { - exit->temperature = advance_backoff_counter(exit->temperature); + if (exit->temperature.value_and_backoff) { + exit->temperature.value_and_backoff--; GOTO_TIER_ONE(target); } _PyFrame_SetStackPointer(frame, stack_pointer); int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, 0); stack_pointer = _PyFrame_GetStackPointer(frame); if (optimized <= 0) { - exit->temperature = restart_backoff_counter(exit->temperature); + exit->temperature = initial_temperature_backoff_counter(); if (optimized < 0) { GOTO_UNWIND(); }