mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
Add some GC stats to Py_STATS (GH-107581)
This commit is contained in:
parent
fa45958450
commit
2ba7c7f7b1
5 changed files with 80 additions and 1 deletions
|
|
@ -460,6 +460,7 @@ update_refs(PyGC_Head *containers)
|
|||
static int
|
||||
visit_decref(PyObject *op, void *parent)
|
||||
{
|
||||
OBJECT_STAT_INC(object_visits);
|
||||
_PyObject_ASSERT(_PyObject_CAST(parent), !_PyObject_IsFreed(op));
|
||||
|
||||
if (_PyObject_IS_GC(op)) {
|
||||
|
|
@ -498,6 +499,7 @@ subtract_refs(PyGC_Head *containers)
|
|||
static int
|
||||
visit_reachable(PyObject *op, PyGC_Head *reachable)
|
||||
{
|
||||
OBJECT_STAT_INC(object_visits);
|
||||
if (!_PyObject_IS_GC(op)) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -725,6 +727,7 @@ clear_unreachable_mask(PyGC_Head *unreachable)
|
|||
static int
|
||||
visit_move(PyObject *op, PyGC_Head *tolist)
|
||||
{
|
||||
OBJECT_STAT_INC(object_visits);
|
||||
if (_PyObject_IS_GC(op)) {
|
||||
PyGC_Head *gc = AS_GC(op);
|
||||
if (gc_is_collecting(gc)) {
|
||||
|
|
@ -1195,6 +1198,12 @@ gc_collect_main(PyThreadState *tstate, int generation,
|
|||
Py_ssize_t *n_collected, Py_ssize_t *n_uncollectable,
|
||||
int nofail)
|
||||
{
|
||||
GC_STAT_ADD(generation, collections, 1);
|
||||
#ifdef Py_STATS
|
||||
if (_py_stats) {
|
||||
_py_stats->object_stats.object_visits = 0;
|
||||
}
|
||||
#endif
|
||||
int i;
|
||||
Py_ssize_t m = 0; /* # objects collected */
|
||||
Py_ssize_t n = 0; /* # unreachable objects that couldn't be collected */
|
||||
|
|
@ -1351,6 +1360,15 @@ gc_collect_main(PyThreadState *tstate, int generation,
|
|||
stats->collected += m;
|
||||
stats->uncollectable += n;
|
||||
|
||||
GC_STAT_ADD(generation, objects_collected, m);
|
||||
#ifdef Py_STATS
|
||||
if (_py_stats) {
|
||||
GC_STAT_ADD(generation, object_visits,
|
||||
_py_stats->object_stats.object_visits);
|
||||
_py_stats->object_stats.object_visits = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (PyDTrace_GC_DONE_ENABLED()) {
|
||||
PyDTrace_GC_DONE(n + m);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue