summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-05-03 22:40:24 (GMT)
committerGitHub <noreply@github.com>2022-05-03 22:40:24 (GMT)
commit836b17c9c3ea313e400e58a75f52b63f96e498bb (patch)
tree8b1a1c9e2466fa72ceee01558e76989b35c8bd56 /Python
parente8d7661ff25fb698062ab07e37362c2c20471984 (diff)
downloadcpython-836b17c9c3ea313e400e58a75f52b63f96e498bb.zip
cpython-836b17c9c3ea313e400e58a75f52b63f96e498bb.tar.gz
cpython-836b17c9c3ea313e400e58a75f52b63f96e498bb.tar.bz2
Add more stats for freelist use and allocations. (GH-92211)
Diffstat (limited to 'Python')
-rw-r--r--Python/context.c2
-rw-r--r--Python/specialize.c5
2 files changed, 7 insertions, 0 deletions
diff --git a/Python/context.c b/Python/context.c
index a77cd14..ef9db6a 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -351,6 +351,7 @@ _context_alloc(void)
state->numfree--;
ctx = state->freelist;
state->freelist = (PyContext *)ctx->ctx_weakreflist;
+ OBJECT_STAT_INC(from_freelist);
ctx->ctx_weakreflist = NULL;
_Py_NewReference((PyObject *)ctx);
}
@@ -482,6 +483,7 @@ context_tp_dealloc(PyContext *self)
state->numfree++;
self->ctx_weakreflist = (PyObject *)state->freelist;
state->freelist = self;
+ OBJECT_STAT_INC(to_freelist);
}
else
#endif
diff --git a/Python/specialize.c b/Python/specialize.c
index 9449ac1..12871ce 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -183,7 +183,12 @@ print_call_stats(FILE *out, CallStats *stats)
static void
print_object_stats(FILE *out, ObjectStats *stats)
{
+ fprintf(out, "Object allocations from freelist: %" PRIu64 "\n", stats->from_freelist);
+ fprintf(out, "Object frees to freelist: %" PRIu64 "\n", stats->to_freelist);
fprintf(out, "Object allocations: %" PRIu64 "\n", stats->allocations);
+ fprintf(out, "Object allocations to 512 bytes: %" PRIu64 "\n", stats->allocations512);
+ fprintf(out, "Object allocations to 4 kbytes: %" PRIu64 "\n", stats->allocations4k);
+ fprintf(out, "Object allocations over 4 kbytes: %" PRIu64 "\n", stats->allocations_big);
fprintf(out, "Object frees: %" PRIu64 "\n", stats->frees);
fprintf(out, "Object new values: %" PRIu64 "\n", stats->new_values);
fprintf(out, "Object materialize dict (on request): %" PRIu64 "\n", stats->dict_materialized_on_request);