[Python-checkins] Gather stats for PRECALL_METHOD. (GH-31259)

markshannon webhook-mailer at python.org
Thu Feb 10 10:56:04 EST 2022


https://github.com/python/cpython/commit/1a6411f5738895fa48d35a93435f7c7b6c17bdb9
commit: 1a6411f5738895fa48d35a93435f7c7b6c17bdb9
branch: main
author: Mark Shannon <mark at hotpy.org>
committer: markshannon <mark at hotpy.org>
date: 2022-02-10T15:55:52Z
summary:

Gather stats for PRECALL_METHOD. (GH-31259)

files:
M Python/ceval.c
M Python/specialize.c

diff --git a/Python/ceval.c b/Python/ceval.c
index c3703a75ce0ca..ffce6b735c1c2 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4451,8 +4451,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
             assert(call_shape.kwnames == NULL);
 #ifdef Py_STATS
             extern int _PySpecialization_ClassifyCallable(PyObject *);
-            _py_stats.opcode_stats[PRECALL_FUNCTION].specialization.failure++;
-            _py_stats.opcode_stats[PRECALL_FUNCTION].specialization.failure_kinds[_PySpecialization_ClassifyCallable(call_shape.callable)]++;
+            SpecializationStats *stats =
+                &_py_stats.opcode_stats[PRECALL_FUNCTION].specialization;
+            stats->failure++;
+            int kind = _PySpecialization_ClassifyCallable(call_shape.callable);
+            stats->failure_kinds[kind]++;
 #endif
             DISPATCH();
         }
@@ -4493,6 +4496,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
 
             call_shape.total_args = nargs;
             assert(call_shape.kwnames == NULL);
+#ifdef Py_STATS
+            extern int _PySpecialization_ClassifyCallable(PyObject *);
+            SpecializationStats *stats =
+                &_py_stats.opcode_stats[PRECALL_METHOD].specialization;
+            stats->failure++;
+            int kind = _PySpecialization_ClassifyCallable(call_shape.callable);
+            stats->failure_kinds[kind]++;
+#endif
             DISPATCH();
         }
 
diff --git a/Python/specialize.c b/Python/specialize.c
index 940ab172d55fe..b051f45157ad3 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -176,6 +176,7 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
      * even though we don't specialize them yet. */
     fprintf(out, "    opcode[%d].specializable : 1\n", FOR_ITER);
     fprintf(out, "    opcode[%d].specializable : 1\n", PRECALL_FUNCTION);
+    fprintf(out, "    opcode[%d].specializable : 1\n", PRECALL_METHOD);
     fprintf(out, "    opcode[%d].specializable : 1\n", UNPACK_SEQUENCE);
     for (int i = 0; i < 256; i++) {
         if (adaptive_opcodes[i]) {



More information about the Python-checkins mailing list