Skip to content

[3.13] GH-124567: Revert the Incremental GC in 3.13 #124770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix TSan build of freethreaded python.
  • Loading branch information
Yhg1s committed Sep 29, 2024
commit a0d5270203fbddd9359f56a073dcb5e0d0f184d9
22 changes: 11 additions & 11 deletions Python/gc_free_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,9 +1090,18 @@ record_deallocation(PyThreadState *tstate)
}

static void
gc_collect_internal(PyInterpreterState *interp, struct collection_state *state)
gc_collect_internal(PyInterpreterState *interp, struct collection_state *state, int generation)
{
_PyEval_StopTheWorld(interp);

// update collection and allocation counters
if (generation+1 < NUM_GENERATIONS) {
state->gcstate->generations[generation+1].count += 1;
}
for (int i = 0; i <= generation; i++) {
state->gcstate->generations[i].count = 0;
}

// merge refcounts for all queued objects
merge_all_queued_objects(interp, state);
process_delayed_frees(interp);
Expand Down Expand Up @@ -1158,7 +1167,6 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state)
static Py_ssize_t
gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
{
int i;
Py_ssize_t m = 0; /* # objects collected */
Py_ssize_t n = 0; /* # unreachable objects that couldn't be collected */
PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
Expand Down Expand Up @@ -1205,22 +1213,14 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
PyDTrace_GC_START(generation);
}

/* update collection and allocation counters */
if (generation+1 < NUM_GENERATIONS) {
gcstate->generations[generation+1].count += 1;
}
for (i = 0; i <= generation; i++) {
gcstate->generations[i].count = 0;
}

PyInterpreterState *interp = tstate->interp;

struct collection_state state = {
.interp = interp,
.gcstate = gcstate,
};

gc_collect_internal(interp, &state);
gc_collect_internal(interp, &state, generation);

m = state.collected;
n = state.uncollectable;
Expand Down
Loading