summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c5
-rw-r--r--Objects/floatobject.c2
-rw-r--r--Objects/genobject.c2
-rw-r--r--Objects/listobject.c2
-rw-r--r--Objects/obmalloc.c15
-rw-r--r--Objects/tupleobject.c2
6 files changed, 28 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
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index a5774b9..86861b7 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -141,6 +141,7 @@ PyFloat_FromDouble(double fval)
#endif
state->free_list = (PyFloatObject *) Py_TYPE(op);
state->numfree--;
+ OBJECT_STAT_INC(from_freelist);
}
else
#endif
@@ -256,6 +257,7 @@ _PyFloat_ExactDealloc(PyObject *obj)
state->numfree++;
Py_SET_TYPE(op, (PyTypeObject *)state->free_list);
state->free_list = op;
+ OBJECT_STAT_INC(to_freelist);
#else
PyObject_Free(op);
#endif
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 0a4b43e..b9a0c30 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -1942,6 +1942,7 @@ async_gen_wrapped_val_dealloc(_PyAsyncGenWrappedValue *o)
if (state->value_numfree < _PyAsyncGen_MAXFREELIST) {
assert(_PyAsyncGenWrappedValue_CheckExact(o));
state->value_freelist[state->value_numfree++] = o;
+ OBJECT_STAT_INC(to_freelist);
}
else
#endif
@@ -2018,6 +2019,7 @@ _PyAsyncGenValueWrapperNew(PyObject *val)
if (state->value_numfree) {
state->value_numfree--;
o = state->value_freelist[state->value_numfree];
+ OBJECT_STAT_INC(from_freelist);
assert(_PyAsyncGenWrappedValue_CheckExact(o));
_Py_NewReference((PyObject*)o);
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index ccb9b91..972f995 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -158,6 +158,7 @@ PyList_New(Py_ssize_t size)
if (PyList_MAXFREELIST && state->numfree) {
state->numfree--;
op = state->free_list[state->numfree];
+ OBJECT_STAT_INC(from_freelist);
_Py_NewReference((PyObject *)op);
}
else
@@ -353,6 +354,7 @@ list_dealloc(PyListObject *op)
#endif
if (state->numfree < PyList_MAXFREELIST && PyList_CheckExact(op)) {
state->free_list[state->numfree++] = op;
+ OBJECT_STAT_INC(to_freelist);
}
else
#endif
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 560e1c5..823855c 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -616,6 +616,10 @@ PyMem_Malloc(size_t size)
/* see PyMem_RawMalloc() */
if (size > (size_t)PY_SSIZE_T_MAX)
return NULL;
+ OBJECT_STAT_INC_COND(allocations512, size < 512);
+ OBJECT_STAT_INC_COND(allocations4k, size >= 512 && size < 4094);
+ OBJECT_STAT_INC_COND(allocations_big, size >= 4094);
+ OBJECT_STAT_INC(allocations);
return _PyMem.malloc(_PyMem.ctx, size);
}
@@ -625,6 +629,10 @@ PyMem_Calloc(size_t nelem, size_t elsize)
/* see PyMem_RawMalloc() */
if (elsize != 0 && nelem > (size_t)PY_SSIZE_T_MAX / elsize)
return NULL;
+ OBJECT_STAT_INC_COND(allocations512, elsize < 512);
+ OBJECT_STAT_INC_COND(allocations4k, elsize >= 512 && elsize < 4094);
+ OBJECT_STAT_INC_COND(allocations_big, elsize >= 4094);
+ OBJECT_STAT_INC(allocations);
return _PyMem.calloc(_PyMem.ctx, nelem, elsize);
}
@@ -640,6 +648,7 @@ PyMem_Realloc(void *ptr, size_t new_size)
void
PyMem_Free(void *ptr)
{
+ OBJECT_STAT_INC(frees);
_PyMem.free(_PyMem.ctx, ptr);
}
@@ -696,6 +705,9 @@ PyObject_Malloc(size_t size)
/* see PyMem_RawMalloc() */
if (size > (size_t)PY_SSIZE_T_MAX)
return NULL;
+ OBJECT_STAT_INC_COND(allocations512, size < 512);
+ OBJECT_STAT_INC_COND(allocations4k, size >= 512 && size < 4094);
+ OBJECT_STAT_INC_COND(allocations_big, size >= 4094);
OBJECT_STAT_INC(allocations);
return _PyObject.malloc(_PyObject.ctx, size);
}
@@ -706,6 +718,9 @@ PyObject_Calloc(size_t nelem, size_t elsize)
/* see PyMem_RawMalloc() */
if (elsize != 0 && nelem > (size_t)PY_SSIZE_T_MAX / elsize)
return NULL;
+ OBJECT_STAT_INC_COND(allocations512, elsize < 512);
+ OBJECT_STAT_INC_COND(allocations4k, elsize >= 512 && elsize < 4094);
+ OBJECT_STAT_INC_COND(allocations_big, elsize >= 4094);
OBJECT_STAT_INC(allocations);
return _PyObject.calloc(_PyObject.ctx, nelem, elsize);
}
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index f21d4da..dfb8597 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -1195,6 +1195,7 @@ maybe_freelist_pop(Py_ssize_t size)
#endif
_Py_NewReference((PyObject *)op);
/* END inlined _PyObject_InitVar() */
+ OBJECT_STAT_INC(from_freelist);
return op;
}
}
@@ -1224,6 +1225,7 @@ maybe_freelist_push(PyTupleObject *op)
op->ob_item[0] = (PyObject *) STATE.free_list[index];
STATE.free_list[index] = op;
STATE.numfree[index]++;
+ OBJECT_STAT_INC(to_freelist);
return 1;
}
#endif