summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-02-02 11:01:33 (GMT)
committerGitHub <noreply@github.com>2022-02-02 11:01:33 (GMT)
commit187930f74c44e460ba09c60ba5d9bb4fac543d8f (patch)
tree34c1c536986e6a5b33b66e4aad10e7594ccb3ba0 /Python
parenta05866ce3e617e2b74c205f27a89eab63c7b3101 (diff)
downloadcpython-187930f74c44e460ba09c60ba5d9bb4fac543d8f.zip
cpython-187930f74c44e460ba09c60ba5d9bb4fac543d8f.tar.gz
cpython-187930f74c44e460ba09c60ba5d9bb4fac543d8f.tar.bz2
bpo-46072: Add some frame stats. (GH-31060)
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c5
-rw-r--r--Python/frame.c2
-rw-r--r--Python/pystate.c2
-rw-r--r--Python/specialize.c2
4 files changed, 10 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b69d5aa..70748e8 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2242,6 +2242,7 @@ handle_eval_breaker:
if (new_frame == NULL) {
goto error;
}
+ CALL_STAT_INC(frames_pushed);
_PyFrame_InitializeSpecials(new_frame, getitem,
NULL, code->co_nlocalsplus);
STACK_SHRINK(2);
@@ -4660,6 +4661,7 @@ handle_eval_breaker:
if (new_frame == NULL) {
goto error;
}
+ CALL_STAT_INC(inlined_py_calls);
STACK_SHRINK(argcount);
for (int i = 0; i < argcount; i++) {
new_frame->localsplus[i] = stack_pointer[i];
@@ -4690,6 +4692,7 @@ handle_eval_breaker:
if (new_frame == NULL) {
goto error;
}
+ CALL_STAT_INC(inlined_py_calls);
STACK_SHRINK(argcount);
for (int i = 0; i < argcount; i++) {
new_frame->localsplus[i] = stack_pointer[i];
@@ -4708,7 +4711,6 @@ handle_eval_breaker:
_PyFrame_SetStackPointer(frame, stack_pointer);
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
- CALL_STAT_INC(inlined_py_calls);
goto start_frame;
}
@@ -6078,6 +6080,7 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
{
PyCodeObject * code = (PyCodeObject *)func->func_code;
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
+ CALL_STAT_INC(frames_pushed);
InterpreterFrame *frame = _PyThreadState_BumpFramePointer(tstate, size);
if (frame == NULL) {
goto fail;
diff --git a/Python/frame.c b/Python/frame.c
index 771de75..ca7c5f9 100644
--- a/Python/frame.c
+++ b/Python/frame.c
@@ -1,6 +1,7 @@
#include "Python.h"
#include "frameobject.h"
+#include "pycore_code.h" // stats
#include "pycore_frame.h"
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "opcode.h"
@@ -113,6 +114,7 @@ _PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func)
{
PyCodeObject *code = (PyCodeObject *)func->func_code;
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
+ CALL_STAT_INC(frames_pushed);
InterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size);
if (new_frame == NULL) {
return NULL;
diff --git a/Python/pystate.c b/Python/pystate.c
index 4378d78..7746794 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -3,6 +3,7 @@
#include "Python.h"
#include "pycore_ceval.h"
+#include "pycore_code.h" // stats
#include "pycore_frame.h"
#include "pycore_initconfig.h"
#include "pycore_object.h" // _PyType_InitCache()
@@ -2219,6 +2220,7 @@ _PyThreadState_PushFrame(PyThreadState *tstate, PyFunctionObject *func, PyObject
int nlocalsplus = code->co_nlocalsplus;
size_t size = nlocalsplus + code->co_stacksize +
FRAME_SPECIALS_SIZE;
+ CALL_STAT_INC(frames_pushed);
InterpreterFrame *frame = _PyThreadState_BumpFramePointer(tstate, size);
if (frame == NULL) {
return NULL;
diff --git a/Python/specialize.c b/Python/specialize.c
index 5771a41..9290fbe 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -169,6 +169,8 @@ print_call_stats(FILE *out, CallStats *stats)
{
fprintf(out, "Calls to PyEval_EvalDefault: %" PRIu64 "\n", stats->pyeval_calls);
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);
}
static void