10000 GH-90230: Add stats to breakdown the origin of calls to `PyEval_EvalFrame` by markshannon · Pull Request #93284 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-90230: Add stats to breakdown the origin of calls to PyEval_EvalFrame #93284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tidy up
  • Loading branch information
markshannon committed May 26, 2022
commit ef21097e41031456a26f4abedfc42201215ac946
2 changes: 1 addition & 1 deletion Include/pystats.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
#define EVAL_CALL_VECTOR 1
#define EVAL_CALL_GENERATOR 2
#define EVAL_CALL_LEGACY 3
#define EVAL_CALL_FUNCTION 4
#define EVAL_CALL_FUNCTION_VECTORCALL 4
#define EVAL_CALL_BUILD_CLASS 5
#define EVAL_CALL_SLOT 6
#define EVAL_CALL_FUNCTION_EX 7
Expand Down
14 changes: 3 additions & 11 deletions Objects/call.c
8000
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,7 @@ _PyObject_Call(PyThreadState *tstate, PyObject *callable,
assert(!_PyErr_Occurred(tstate));
assert(PyTuple_Check(args));
assert(kwargs == NULL || PyDict_Check(kwargs));
#ifdef Py_STATS
if (PyFunction_Check(callable)) {
EVAL_CALL_STAT_INC(EVAL_CALL_API);
}
#endif
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, callable);
vectorcallfunc vector_func = _PyVectorcall_Function(callable);
if (vector_func != NULL) {
return _PyVectorcall_Call(tstate, vector_func, callable, args, kwargs);
Expand Down Expand Up @@ -400,7 +396,7 @@ _PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
assert(nargs >= 0);
PyThreadState *tstate = _PyThreadState_GET();
assert(nargs == 0 || stack != NULL);
EVAL_CALL_STAT_INC(EVAL_CALL_FUNCTION);
EVAL_CALL_STAT_INC(EVAL_CALL_FUNCTION_VECTORCALL);
if (((PyCodeObject *)f->func_code)->co_flags & CO_OPTIMIZED) {
return _PyEval_Vector(tstate, f, NULL, stack, nargs, kwnames);
}
Expand Down Expand Up @@ -532,11 +528,7 @@ _PyObject_CallFunctionVa(PyThreadState *tstate, PyObject *callable,
if (stack == NULL) {
return NULL;
}
#ifdef Py_STATS
if (PyFunction_Check(callable)) {
EVAL_CALL_STAT_INC(EVAL_CALL_API);
}
#endif
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, callable);
if (nargs == 1 && PyTuple_Check(stack[0])) {
/* Special cases for backward compatibility:
- PyObject_CallFunction(func, "O", tuple) calls func(*tuple)
Expand Down
6 changes: 1 addition & 5 deletions Objects/typeobject.c
72F6
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,7 @@ vectorcall_unbound(PyThreadState *tstate, int unbound, PyObject *func,
args++;
nargsf = nargsf - 1 + PY_VECTORCALL_ARGUMENTS_OFFSET;
}
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_SLOT, func);
return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL);
}

Expand Down Expand Up @@ -1705,11 +1706,6 @@ vectorcall_maybe(PyThreadState *tstate, PyObject *name,
Py_RETURN_NOTIMPLEMENTED;
return NULL;
}
#ifdef Py_STATS
if (PyFunction_Check(func)) {
EVAL_CALL_STAT_INC(EVAL_CALL_SLOT);
}
#endif
PyObject *retval = vectorcall_unbound(tstate, unbound, func, args, nargs);
Py_DECREF(func);
return retval;
Expand Down
0