Skip to content

Commit 9eb2489

Browse files
authored
gh-109329: Add stat for "trace too short" (GH-110402)
1 parent 1328fa3 commit 9eb2489

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

Include/cpython/pystats.h

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ typedef struct _optimization_stats {
110110
uint64_t trace_stack_overflow;
111111
uint64_t trace_stack_underflow;
112112
uint64_t trace_too_long;
113+
uint64_t trace_too_short;
113114
uint64_t inner_loop;
114115
uint64_t recursive_call;
115116
UOpStats opcode[512];

Python/optimizer.c

+1
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ translate_bytecode_to_trace(
798798
return trace_length;
799799
}
800800
else {
801+
OPT_STAT_INC(trace_too_short);
801802
DPRINTF(4,
802803
"No trace for %s (%s:%d) at byte offset %d\n",
803804
PyUnicode_AsUTF8(code->co_qualname),

Python/specialize.c

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ print_optimization_stats(FILE *out, OptimizationStats *stats)
229229
fprintf(out, "Optimization trace stack overflow: %" PRIu64 "\n", stats->trace_stack_overflow);
230230
fprintf(out, "Optimization trace stack underflow: %" PRIu64 "\n", stats->trace_stack_underflow);
231231
fprintf(out, "Optimization trace too long: %" PRIu64 "\n", stats->trace_too_long);
232+
fprintf(out, "Optimization trace too short: %" PRIu64 "\n", stats->trace_too_short);
232233
fprintf(out, "Optimization inner loop: %" PRIu64 "\n", stats->inner_loop);
233234
fprintf(out, "Optimization recursive call: %" PRIu64 "\n", stats->recursive_call);
234235

Tools/scripts/summarize_stats.py

+2
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def calculate_optimization_stats(stats):
760760
trace_stack_overflow = stats["Optimization trace stack overflow"]
761761
trace_stack_underflow = stats["Optimization trace stack underflow"]
762762
trace_too_long = stats["Optimization trace too long"]
763+
trace_too_short = stats["Optimiztion trace too short"]
763764
inner_loop = stats["Optimization inner loop"]
764765
recursive_call = stats["Optimization recursive call"]
765766

@@ -771,6 +772,7 @@ def calculate_optimization_stats(stats):
771772
("Trace stack overflow", trace_stack_overflow, ""),
772773
("Trace stack underflow", trace_stack_underflow, ""),
773774
("Trace too long", trace_too_long, ""),
775+
("Trace too short", trace_too_short, ""),
774776
("Inner loop found", inner_loop, ""),
775777
("Recursive call", recursive_call, ""),
776778
]

0 commit comments

Comments
 (0)