Skip to content

Remove obsolete counting of objects in young generation of GC #137054

Description

@sergey-miryanov

Feature or enhancement

Proposal:

There is no template and label for refactoring yet.

I have found a dead code in gc.c for young generation.

cpython/Python/gc.c

Lines 1334 to 1342 in ec7fad7

#ifdef Py_STATS
{
Py_ssize_t count = 0;
PyGC_Head *gc;
for (gc = GC_NEXT(young); gc != young; gc = GC_NEXT(gc)) {
count++;
}
}
#endif

It is superseded by counting of object_visits via OBJECT_STAT_INC and adjusted gc_stats[gen].object_visits at the end of the collection.

cpython/Python/gc.c

Lines 2073 to 2079 in ec7fad7

#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

I believe it is worth to remove dead code to decrease code base (yeah, by 9 lines).

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-refactorCode refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions