https://github.com/python/cpython/commit/cef0ec1a3ca40db69b56bcd736c1b3bb05a1cf48
commit: cef0ec1a3ca40db69b56bcd736c1b3bb05a1cf48
branch: main
author: Michael Droettboom <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2024-03-13T22:13:33Z
summary:
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.
files:
M Python/bytecodes.c
M Python/generated_cases.c.h
M Python/optimizer.c
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index ec05e40bd23fcb..af2e2c8f52ee29 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -2349,7 +2349,6 @@ dummy_func(
// Use '>=' not '>' so that the optimizer/backoff bits do not
effect the result.
// Double-check that the opcode isn't instrumented or something:
if (offset_counter >= threshold && this_instr->op.code ==
JUMP_BACKWARD) {
- OPT_STAT_INC(attempts);
_Py_CODEUNIT *start = this_instr;
/* Back up over EXTENDED_ARGs so optimizer sees the whole
instruction */
while (oparg > 255) {
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 72892725fb25d8..7d02e49d040c23 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -3371,7 +3371,6 @@
// Use '>=' not '>' so that the optimizer/backoff bits do not
effect the result.
// Double-check that the opcode isn't instrumented or something:
if (offset_counter >= threshold && this_instr->op.code ==
JUMP_BACKWARD) {
- OPT_STAT_INC(attempts);
_Py_CODEUNIT *start = this_instr;
/* Back up over EXTENDED_ARGs so optimizer sees the whole
instruction */
while (oparg > 255) {
diff --git a/Python/optimizer.c b/Python/optimizer.c
index aaf75b2339cd2e..88c45f2e73c682 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -1003,6 +1003,7 @@ uop_optimize(
_PyBloomFilter dependencies;
_Py_BloomFilter_Init(&dependencies);
_PyUOpInstruction buffer[UOP_MAX_TRACE_LENGTH];
+ OPT_STAT_INC(attempts);
int err = translate_bytecode_to_trace(frame, instr, buffer,
UOP_MAX_TRACE_LENGTH, &dependencies);
if (err <= 0) {
// Error or nothing translated
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]