Skip to content

Commit 4169667

Browse files
committed
pythongh-117122: Fix pystats after incremental GC changes
1 parent 1f8b24e commit 4169667

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Include/cpython/pystats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ typedef struct _gc_stats {
9494
uint64_t collections;
9595
uint64_t object_visits;
9696
uint64_t objects_collected;
97+
uint64_t objects_queued;
9798
} GCStats;
9899

99100
typedef struct _uop_stats {

Python/gc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,6 @@ expand_region_transitively_reachable(PyGC_Head *container, PyGC_Head *gc, GCStat
13841384
static void
13851385
completed_cycle(GCState *gcstate)
13861386
{
1387-
PyGC_Head *not_visited = &gcstate->old[gcstate->visited_space^1].head;
13881387
assert(gc_list_is_empty(not_visited));
13891388
gcstate->visited_space = flip_old_space(gcstate->visited_space);
13901389
if (gcstate->work_to_do > 0) {
@@ -1421,7 +1420,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
14211420
gc_set_old_space(gc, gcstate->visited_space);
14221421
increment_size += expand_region_transitively_reachable(&increment, gc, gcstate);
14231422
}
1424-
GC_STAT_ADD(1, objects_queued, region_size);
1423+
GC_STAT_ADD(1, objects_queued, increment_size);
14251424
PyGC_Head survivors;
14261425
gc_list_init(&survivors);
14271426
gc_collect_region(tstate, &increment, &survivors, UNTRACK_TUPLES, stats);
@@ -1807,10 +1806,10 @@ _PyGC_Collect(PyThreadState *tstate, int generation, _PyGC_Reason reason)
18071806
_PyErr_SetRaisedException(tstate, exc);
18081807
GC_STAT_ADD(generation, objects_collected, stats.collected);
18091808
#ifdef Py_STATS
1810-
if (_py_stats) {
1809+
if (_Py_stats) {
18111810
GC_STAT_ADD(generation, object_visits,
1812-
_py_stats->object_stats.object_visits);
1813-
_py_stats->object_stats.object_visits = 0;
1811+
_Py_stats->object_stats.object_visits);
1812+
_Py_stats->object_stats.object_visits = 0;
18141813
}
18151814
#endif
18161815
validate_old(gcstate);

Python/specialize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ print_gc_stats(FILE *out, GCStats *stats)
212212
fprintf(out, "GC[%d] collections: %" PRIu64 "\n", i, stats[i].collections);
213213
fprintf(out, "GC[%d] object visits: %" PRIu64 "\n", i, stats[i].object_visits);
214214
fprintf(out, "GC[%d] objects collected: %" PRIu64 "\n", i, stats[i].objects_collected);
215+
fprintf(out, "GC[%d] objects queued: %" PRIu64 "\n", i, stats[i].objects_queued);
215216
}
216217
}
217218

Tools/scripts/summarize_stats.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ def calc_gc_stats(stats: Stats) -> Rows:
11031103
Count(gen["collections"]),
11041104
Count(gen["objects collected"]),
11051105
Count(gen["object visits"]),
1106+
Count(gen["objects queued"]),
11061107
)
11071108
for (i, gen) in enumerate(gc_stats)
11081109
]
@@ -1112,7 +1113,13 @@ def calc_gc_stats(stats: Stats) -> Rows:
11121113
"GC collections and effectiveness",
11131114
[
11141115
Table(
1115-
("Generation:", "Collections:", "Objects collected:", "Object visits:"),
1116+
(
1117+
"Generation:",
1118+
"Collections:",
1119+
"Objects collected:",
1120+
"Object visits:",
1121+
"Objects queued:",
1122+
),
11161123
calc_gc_stats,
11171124
)
11181125
],

0 commit comments

Comments
 (0)