From 9eb2489266c4c1f115b8f72c0728db737cc8a815 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 5 Oct 2023 11:12:06 -0400 Subject: gh-109329: Add stat for "trace too short" (GH-110402) --- Include/cpython/pystats.h | 1 + Python/optimizer.c | 1 + Python/specialize.c | 1 + Tools/scripts/summarize_stats.py | 2 ++ 4 files changed, 5 insertions(+) diff --git a/Include/cpython/pystats.h b/Include/cpython/pystats.h index 056406e..4988caa 100644 --- a/Include/cpython/pystats.h +++ b/Include/cpython/pystats.h @@ -110,6 +110,7 @@ typedef struct _optimization_stats { uint64_t trace_stack_overflow; uint64_t trace_stack_underflow; uint64_t trace_too_long; + uint64_t trace_too_short; uint64_t inner_loop; uint64_t recursive_call; UOpStats opcode[512]; diff --git a/Python/optimizer.c b/Python/optimizer.c index f8796eb..65b9638 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -798,6 +798,7 @@ done: return trace_length; } else { + OPT_STAT_INC(trace_too_short); DPRINTF(4, "No trace for %s (%s:%d) at byte offset %d\n", PyUnicode_AsUTF8(code->co_qualname), diff --git a/Python/specialize.c b/Python/specialize.c index ff732eb..49633b1 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -229,6 +229,7 @@ print_optimization_stats(FILE *out, OptimizationStats *stats) fprintf(out, "Optimization trace stack overflow: %" PRIu64 "\n", stats->trace_stack_overflow); fprintf(out, "Optimization trace stack underflow: %" PRIu64 "\n", stats->trace_stack_underflow); fprintf(out, "Optimization trace too long: %" PRIu64 "\n", stats->trace_too_long); + fprintf(out, "Optimization trace too short: %" PRIu64 "\n", stats->trace_too_short); fprintf(out, "Optimization inner loop: %" PRIu64 "\n", stats->inner_loop); fprintf(out, "Optimization recursive call: %" PRIu64 "\n", stats->recursive_call); diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index b9cc2f9..bdca51d 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -760,6 +760,7 @@ def calculate_optimization_stats(stats): trace_stack_overflow = stats["Optimization trace stack overflow"] trace_stack_underflow = stats["Optimization trace stack underflow"] trace_too_long = stats["Optimization trace too long"] + trace_too_short = stats["Optimiztion trace too short"] inner_loop = stats["Optimization inner loop"] recursive_call = stats["Optimization recursive call"] @@ -771,6 +772,7 @@ def calculate_optimization_stats(stats): ("Trace stack overflow", trace_stack_overflow, ""), ("Trace stack underflow", trace_stack_underflow, ""), ("Trace too long", trace_too_long, ""), + ("Trace too short", trace_too_short, ""), ("Inner loop found", inner_loop, ""), ("Recursive call", recursive_call, ""), ] -- cgit v0.12