]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109329: Add stat for "trace too short" (GH-110402)
authorMichael Droettboom <mdboom@gmail.com>
Thu, 5 Oct 2023 15:12:06 +0000 (11:12 -0400)
committerGitHub <noreply@github.com>
Thu, 5 Oct 2023 15:12:06 +0000 (16:12 +0100)
Include/cpython/pystats.h
Python/optimizer.c
Python/specialize.c
Tools/scripts/summarize_stats.py

index 056406e6b5d99242ab5ce5f99436ff8bd5a29c6e..4988caa803723d76c9bea7e636267e776f834985 100644 (file)
@@ -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];
index f8796eb24073d2b2c5197288105293235218993c..65b9638be25e98b6fec4432bc47544a2aaf61550 100644 (file)
@@ -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),
index ff732eb30ca1e0995ae1b3854cbd2760637dfec6..49633b103b3815b8bbfa21cddf5d07bf03dcfe90 100644 (file)
@@ -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);
 
index b9cc2f94080b883da91263a8e24e66fc2097c4d0..bdca51df3dac532032e053b9687d0490c6a98d40 100644 (file)
@@ -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, ""),
     ]