Skip to content

Commit 5cccfa2

Browse files
committed
Add a "unknown callee" stat
1 parent e7362f5 commit 5cccfa2

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

Include/cpython/pystats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ typedef struct _optimization_stats {
129129
uint64_t inner_loop;
130130
uint64_t recursive_call;
131131
uint64_t low_confidence;
132+
uint64_t unknown_callee;
132133
uint64_t executors_invalidated;
133134
UOpStats opcode[PYSTATS_MAX_UOP_ID + 1];
134135
uint64_t unsupported_opcode[256];

Python/optimizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ translate_bytecode_to_trace(
757757
opcode == SEND_GEN)
758758
{
759759
DPRINTF(2, "Bailing due to dynamic target\n");
760-
OPT_STAT_INC(low_confidence);
760+
OPT_STAT_INC(unknown_callee);
761761
return 0;
762762
}
763763
assert(_PyOpcode_Deopt[opcode] == CALL || _PyOpcode_Deopt[opcode] == CALL_KW);
@@ -824,7 +824,7 @@ translate_bytecode_to_trace(
824824
goto top;
825825
}
826826
DPRINTF(2, "Bail, new_code == NULL\n");
827-
OPT_STAT_INC(low_confidence);
827+
OPT_STAT_INC(unknown_callee);
828828
return 0;
829829
}
830830

Python/specialize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ print_optimization_stats(FILE *out, OptimizationStats *stats)
260260
fprintf(out, "Optimization inner loop: %" PRIu64 "\n", stats->inner_loop);
261261
fprintf(out, "Optimization recursive call: %" PRIu64 "\n", stats->recursive_call);
262262
fprintf(out, "Optimization low confidence: %" PRIu64 "\n", stats->low_confidence);
263+
fprintf(out, "Optimization unknown callee: %" PRIu64 "\n", stats->unknown_callee);
263264
fprintf(out, "Executors invalidated: %" PRIu64 "\n", stats->executors_invalidated);
264265

265266
print_histogram(out, "Trace length", stats->trace_length_hist);

Tools/scripts/summarize_stats.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
457457
inner_loop = self._data["Optimization inner loop"]
458458
recursive_call = self._data["Optimization recursive call"]
459459
low_confidence = self._data["Optimization low confidence"]
460+
unknown_callee = self._data["Optimization unknown callee"]
460461
executors_invalidated = self._data["Executors invalidated"]
461462

462463
return {
@@ -497,6 +498,10 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
497498
"A trace is abandoned because the likelihood of the jump to top being taken "
498499
"is too low.",
499500
): (low_confidence, attempts),
501+
Doc(
502+
"Unknown callee",
503+
"A trace is abandoned because the target of a call is unknown.",
504+
): (unknown_callee, attempts),
500505
Doc(
501506
"Executors invalidated",
502507
"The number of executors that were invalidated due to watched "

0 commit comments

Comments
 (0)