Skip to content

Commit cef0ec1

Browse files
authored
gh-116760: Fix pystats for trace attempts (GH-116761)
There are now at least two bytecodes that may attempt to optimize, JUMP_BACK, and more recently, COLD_EXIT. Only the JUMP_BACK was counting the attempt in the stats. This moves that counter to uop_optimize itself so it should always happen no matter where it is called from.
1 parent 8c6db45 commit cef0ec1

File tree

3 files changed

+1
-2
lines changed

3 files changed

+1
-2
lines changed

Python/bytecodes.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,6 @@ dummy_func(
23492349
// Use '>=' not '>' so that the optimizer/backoff bits do not effect the result.
23502350
// Double-check that the opcode isn't instrumented or something:
23512351
if (offset_counter >= threshold && this_instr->op.code == JUMP_BACKWARD) {
2352-
OPT_STAT_INC(attempts);
23532352
_Py_CODEUNIT *start = this_instr;
23542353
/* Back up over EXTENDED_ARGs so optimizer sees the whole instruction */
23552354
while (oparg > 255) {

Python/generated_cases.c.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ uop_optimize(
10031003
_PyBloomFilter dependencies;
10041004
_Py_BloomFilter_Init(&dependencies);
10051005
_PyUOpInstruction buffer[UOP_MAX_TRACE_LENGTH];
1006+
OPT_STAT_INC(attempts);
10061007
int err = translate_bytecode_to_trace(frame, instr, buffer, UOP_MAX_TRACE_LENGTH, &dependencies);
10071008
if (err <= 0) {
10081009
// Error or nothing translated

0 commit comments

Comments
 (0)