mirror of
https://github.com/python/cpython.git
synced 2026-04-26 22:01:08 +00:00
gh-146073: Add fitness/exit quality mechanism for JIT trace frontend (GH-148089)
* Replaces ad-hoc logic for ending traces with a simple inequality: `fitness < exit_quality` * Fitness starts high and is reduced for branches, backward edges, calls and trace length * Exit quality reflect how good a spot that instruction is to end a trace. Closing a loop is very, specializable instructions are very low and the others in between.
This commit is contained in:
parent
448d7b96c1
commit
618b726d68
10 changed files with 205 additions and 45 deletions
7
Python/generated_cases.c.h
generated
7
Python/generated_cases.c.h
generated
|
|
@ -5913,7 +5913,7 @@
|
|||
int og_oparg = (oparg & ~255) | executor->vm_data.oparg;
|
||||
next_instr = this_instr;
|
||||
if (_PyJit_EnterExecutorShouldStopTracing(og_opcode)) {
|
||||
if (_PyOpcode_Caches[_PyOpcode_Deopt[opcode]]) {
|
||||
if (_PyOpcode_Caches[_PyOpcode_Deopt[og_opcode]]) {
|
||||
PAUSE_ADAPTIVE_COUNTER(this_instr[1].counter);
|
||||
}
|
||||
opcode = og_opcode;
|
||||
|
|
@ -12497,7 +12497,10 @@
|
|||
tracer->prev_state.instr_frame = frame;
|
||||
tracer->prev_state.instr_oparg = oparg;
|
||||
tracer->prev_state.instr_stacklevel = PyStackRef_IsNone(frame->f_executable) ? 2 : STACK_LEVEL();
|
||||
if (_PyOpcode_Caches[_PyOpcode_Deopt[opcode]]) {
|
||||
if (_PyOpcode_Caches[_PyOpcode_Deopt[opcode]]
|
||||
// Branch opcodes use the cache for branch history, not
|
||||
// specialization counters. Don't reset it.
|
||||
&& !IS_CONDITIONAL_JUMP_OPCODE(opcode)) {
|
||||
(&next_instr[1])->counter = trigger_backoff_counter();
|
||||
}
|
||||
const _PyOpcodeRecordEntry *record_entry = &_PyOpcode_RecordEntries[opcode];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue