Skip to content

Commit c5836be

Browse files
committed
Address review comments
1 parent 6c78c01 commit c5836be

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Include/internal/pycore_gc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static inline void _PyObject_GC_TRACK(
253253
uintptr_t not_visited = 1 ^ gcstate->visited_space;
254254
gc->_gc_next = ((uintptr_t)generation0) | not_visited;
255255
generation0->_gc_prev = (uintptr_t)gc;
256-
gcstate->young.count++; /* number of allocated GC objects */
256+
gcstate->young.count++; /* number of tracked GC objects */
257257
gcstate->heap_size++;
258258
if (gcstate->young.count > gcstate->young.threshold) {
259259
_Py_TriggerGC(gcstate);

Objects/tupleobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ _PyTuple_MaybeUntrack(PyObject *op)
158158

159159
/* Fast, but conservative check if an object maybe tracked
160160
May return true for an object that is not tracked,
161-
Will alwys return true for an object that is tracked.
161+
Will always return true for an object that is tracked.
162162
This is a temporary workaround until _PyObject_GC_IS_TRACKED
163163
becomes fast and safe to call on non-GC objects.
164164
*/

Python/gc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,8 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
16571657
if (gcstate->work_to_do < 0) {
16581658
return;
16591659
}
1660+
/* untrack_tuples() may reduce gcstate->young.count to less than zero.
1661+
This is harmless as it will merely delay the next GC a bit. */
16601662
untrack_tuples(&gcstate->young.head);
16611663
if (gcstate->phase == GC_PHASE_MARK) {
16621664
Py_ssize_t objects_marked = mark_at_start(tstate);
@@ -2292,6 +2294,7 @@ _Py_TriggerGC(struct _gc_runtime_state *gcstate)
22922294
{
22932295
PyThreadState *tstate = _PyThreadState_GET();
22942296
if (gcstate->enabled &&
2297+
gcstate->young.threshold != 0 &&
22952298
!_Py_atomic_load_int_relaxed(&gcstate->collecting) &&
22962299
!_PyErr_Occurred(tstate))
22972300
{

0 commit comments

Comments
 (0)