@@ -753,20 +753,18 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable)
753753* and is much faster than a more complex approach that
754754* would untrack all relevant tuples.
755755*/
756- static Py_ssize_t
756+ static void
757757untrack_tuples (PyGC_Head * head )
758758{
759- Py_ssize_t untracked = 0 ;
760759 PyGC_Head * gc = GC_NEXT (head );
761760 while (gc != head ) {
762761 PyObject * op = FROM_GC (gc );
763762 PyGC_Head * next = GC_NEXT (gc );
764763 if (PyTuple_CheckExact (op )) {
765- untracked += _PyTuple_MaybeUntrack (op );
764+ _PyTuple_MaybeUntrack (op );
766765 }
767766 gc = next ;
768767 }
769- return untracked ;
770768}
771769
772770/* Return true if object has a pre-PEP 442 finalization method. */
@@ -1378,7 +1376,7 @@ gc_collect_young(PyThreadState *tstate,
13781376 validate_spaces (gcstate );
13791377 PyGC_Head * young = & gcstate -> young .head ;
13801378 PyGC_Head * visited = & gcstate -> old [gcstate -> visited_space ].head ;
1381- stats -> untracked_tuples += untrack_tuples (young );
1379+ untrack_tuples (young );
13821380 GC_STAT_ADD (0 , collections , 1 );
13831381
13841382 PyGC_Head survivors ;
@@ -1656,7 +1654,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
16561654 GC_STAT_ADD (1 , collections , 1 );
16571655 GCState * gcstate = & tstate -> interp -> gc ;
16581656 gcstate -> work_to_do += assess_work_to_do (gcstate );
1659- stats -> untracked_tuples += untrack_tuples (& gcstate -> young .head );
1657+ untrack_tuples (& gcstate -> young .head );
16601658 if (gcstate -> phase == GC_PHASE_MARK ) {
16611659 Py_ssize_t objects_marked = mark_at_start (tstate );
16621660 GC_STAT_ADD (1 , objects_transitively_reachable , objects_marked );
@@ -1718,7 +1716,7 @@ gc_collect_full(PyThreadState *tstate,
17181716 PyGC_Head * young = & gcstate -> young .head ;
17191717 PyGC_Head * pending = & gcstate -> old [gcstate -> visited_space ^1 ].head ;
17201718 PyGC_Head * visited = & gcstate -> old [gcstate -> visited_space ].head ;
1721- stats -> untracked_tuples += untrack_tuples (young );
1719+ untrack_tuples (young );
17221720 /* merge all generations into visited */
17231721 gc_list_merge (young , pending );
17241722 gc_list_validate_space (pending , 1 - gcstate -> visited_space );
@@ -1758,7 +1756,7 @@ gc_collect_region(PyThreadState *tstate,
17581756 gc_list_init (& unreachable );
17591757 deduce_unreachable (from , & unreachable );
17601758 validate_consistent_old_space (from );
1761- stats -> untracked_tuples += untrack_tuples (from );
1759+ untrack_tuples (from );
17621760
17631761 /* Move reachable objects to next generation. */
17641762 validate_consistent_old_space (to );
@@ -2100,30 +2098,12 @@ _PyGC_Collect(PyThreadState *tstate, int generation, _PyGC_Reason reason)
21002098 default :
21012099 Py_UNREACHABLE ();
21022100 }
2103- gcstate -> generation_stats [generation ].untracked_tuples += stats .untracked_tuples ;
2104- gcstate -> generation_stats [0 ].total_untracked_tuples += stats .untracked_tuples ;
21052101 if (PyDTrace_GC_DONE_ENABLED ()) {
21062102 PyDTrace_GC_DONE (stats .uncollectable + stats .collected );
21072103 }
21082104 if (reason != _Py_GC_REASON_SHUTDOWN ) {
21092105 invoke_gc_callback (gcstate , "stop" , generation , & stats );
21102106 }
2111- else if (false) {
2112- FILE * out = stderr ;
2113-
2114- fprintf (out , "GC[%d] total tuples : %zd\n" , 0 , gcstate -> generation_stats [0 ].total_tuples );
2115- fprintf (out , "GC[%d] total untracked_tuples : %zd\n" , 0 , gcstate -> generation_stats [0 ].total_untracked_tuples );
2116- for (int i = 0 ; i < 33 ; i ++ ) {
2117- fprintf (out , "GC[%d] by size %d : %zd\n" , 0 , i , gcstate -> generation_stats [0 ].tuples_by_size [i ]);
2118- }
2119-
2120- for (int i = 0 ; i < NUM_GENERATIONS ; i ++ ) {
2121- fprintf (out , "GC[%d] collections : %zd\n" , i , gcstate -> generation_stats [i ].collections );
2122- fprintf (out , "GC[%d] collected : %zd\n" , i , gcstate -> generation_stats [i ].collected );
2123- fprintf (out , "GC[%d] uncollectable : %zd\n" , i , gcstate -> generation_stats [i ].uncollectable );
2124- fprintf (out , "GC[%d] untracked_tuples: %zd\n" , i , gcstate -> generation_stats [i ].untracked_tuples );
2125- }
2126- }
21272107 _PyErr_SetRaisedException (tstate , exc );
21282108 GC_STAT_ADD (generation , objects_collected , stats .collected );
21292109#ifdef Py_STATS
0 commit comments