summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
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 /Objects/dictobject.c
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 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 8a93ae9..063fd24 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -624,6 +624,7 @@ new_keys_object(uint8_t log2_size, bool unicode)
#endif
if (log2_size == PyDict_LOG_MINSIZE && unicode && state->keys_numfree > 0) {
dk = state->keys_free_list[--state->keys_numfree];
+ OBJECT_STAT_INC(from_freelist);
}
else
#endif
@@ -681,6 +682,7 @@ free_keys_object(PyDictKeysObject *keys)
&& state->keys_numfree < PyDict_MAXFREELIST
&& DK_IS_UNICODE(keys)) {
state->keys_free_list[state->keys_numfree++] = keys;
+ OBJECT_STAT_INC(to_freelist);
return;
}
#endif
@@ -726,6 +728,7 @@ new_dict(PyDictKeysObject *keys, PyDictValues *values, Py_ssize_t used, int free
mp = state->free_list[--state->numfree];
assert (mp != NULL);
assert (Py_IS_TYPE(mp, &PyDict_Type));
+ OBJECT_STAT_INC(from_freelist);
_Py_NewReference((PyObject *)mp);
}
else
@@ -1544,6 +1547,7 @@ dictresize(PyDictObject *mp, uint8_t log2_newsize, int unicode)
state->keys_numfree < PyDict_MAXFREELIST)
{
state->keys_free_list[state->keys_numfree++] = oldkeys;
+ OBJECT_STAT_INC(to_freelist);
}
else
#endif
@@ -2381,6 +2385,7 @@ dict_dealloc(PyDictObject *mp)
#endif
if (state->numfree < PyDict_MAXFREELIST && Py_IS_TYPE(mp, &PyDict_Type)) {
state->free_list[state->numfree++] = mp;
+ OBJECT_STAT_INC(to_freelist);
}
else
#endif