Skip to content

gh-109329: Add stat for "trace too short" #110402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Include/cpython/pystats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ translate_bytecode_to_trace(
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),
Expand Down
1 change: 1 addition & 0 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions Tools/scripts/summarize_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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, ""),
]
Expand Down