summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-05-27 15:31:41 (GMT)
committerGitHub <noreply@github.com>2022-05-27 15:31:41 (GMT)
commitbbcf42449e13c0b62f145cd49d12674ef3d5bf64 (patch)
tree68d3a84f78de47229c46df66eafd4c27474379a7 /Python
parent8995177030c8b41885ad92b260279b7e622ecaea (diff)
downloadcpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.zip
cpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.tar.gz
cpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.tar.bz2
GH-90230: Add stats to breakdown the origin of calls to `PyEval_EvalFrame` (GH-93284)
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c1
-rw-r--r--Python/ceval.c5
-rw-r--r--Python/specialize.c5
3 files changed, 9 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 072bf75..6284bbd 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -198,6 +198,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
goto error;
}
PyThreadState *tstate = _PyThreadState_GET();
+ EVAL_CALL_STAT_INC(EVAL_CALL_BUILD_CLASS);
cell = _PyEval_Vector(tstate, (PyFunctionObject *)func, ns, NULL, 0, NULL);
if (cell != NULL) {
if (bases != orig_bases) {
diff --git a/Python/ceval.c b/Python/ceval.c
index 56b1017..6158524 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1207,6 +1207,7 @@ PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
if (func == NULL) {
return NULL;
}
+ EVAL_CALL_STAT_INC(EVAL_CALL_LEGACY);
PyObject *res = _PyEval_Vector(tstate, func, locals, NULL, 0, NULL);
Py_DECREF(func);
return res;
@@ -6432,6 +6433,7 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
if (frame == NULL) {
return NULL;
}
+ EVAL_CALL_STAT_INC(EVAL_CALL_VECTOR);
PyObject *retval = _PyEval_EvalFrame(tstate, frame, 0);
assert(
_PyFrame_GetStackPointer(frame) == _PyFrame_Stackbase(frame) ||
@@ -6507,6 +6509,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
if (func == NULL) {
goto fail;
}
+ EVAL_CALL_STAT_INC(EVAL_CALL_LEGACY);
res = _PyEval_Vector(tstate, func, locals,
allargs, argcount,
kwnames);
@@ -7299,7 +7302,6 @@ do_call_core(PyThreadState *tstate,
)
{
PyObject *result;
-
if (PyCFunction_CheckExact(func) || PyCMethod_CheckExact(func)) {
C_TRACE(result, PyObject_Call(func, callargs, kwdict));
return result;
@@ -7329,6 +7331,7 @@ do_call_core(PyThreadState *tstate,
return result;
}
}
+ EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
return PyObject_Call(func, callargs, kwdict);
}
diff --git a/Python/specialize.c b/Python/specialize.c
index 7148b5d..a2fb460 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -176,6 +176,9 @@ print_call_stats(FILE *out, CallStats *stats)
fprintf(out, "Calls to Python functions inlined: %" PRIu64 "\n", stats->inlined_py_calls);
fprintf(out, "Frames pushed: %" PRIu64 "\n", stats->frames_pushed);
fprintf(out, "Frame objects created: %" PRIu64 "\n", stats->frame_objects_created);
+ for (int i = 0; i < EVAL_CALL_KINDS; i++) {
+ fprintf(out, "Calls via PyEval_EvalFrame[%d] : %" PRIu64 "\n", i, stats->eval_calls[i]);
+ }
}
static void
@@ -904,7 +907,7 @@ typedef enum {
MANAGED_DICT = 2,
OFFSET_DICT = 3,
NO_DICT = 4,
- LAZY_DICT = 5,
+ LAZY_DICT = 5,
} ObjectDictKind;
// Please collect stats carefully before and after modifying. A subtle change