Skip to content

Commit 0e949ad

Browse files
address review
1 parent 1446220 commit 0e949ad

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Include/cpython/pystats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ typedef struct _optimization_stats {
142142
uint64_t recursive_call;
143143
uint64_t low_confidence;
144144
uint64_t unknown_callee;
145+
uint64_t trace_immediately_deopts;
145146
uint64_t executors_invalidated;
146147
UOpStats opcode[PYSTATS_MAX_UOP_ID + 1];
147148
uint64_t unsupported_opcode[256];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Protect against specialization failures in the tracing JIT compiler.
1+
Protect against specialization failures in the tracing JIT compiler for performance reasons.

Python/optimizer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,11 @@ _PyJit_translate_single_bytecode_to_trace(
620620
// in the instruction stream, but rather the deopt.
621621
// It's important we check for this, as some specializations might make
622622
// no progress (they can immediately deopt after specializing).
623+
// We do this to improve performance, as otherwise a compiled trace
624+
// will just deopt immediately.
623625
if (backoff != adaptive_counter_cooldown().value_and_backoff &&
624626
backoff != trigger_backoff_counter().value_and_backoff) {
627+
OPT_STAT_INC(trace_immediately_deopts);
625628
opcode = _PyOpcode_Deopt[opcode];
626629
}
627630
}

0 commit comments

Comments
 (0)