Skip to content

reduce gc_collect_harder default to 1 on CPython#14441

Draft
miketheman wants to merge 1 commit intopytest-dev:mainfrom
miketheman:miketheman/speed-up-test-sutie
Draft

reduce gc_collect_harder default to 1 on CPython#14441
miketheman wants to merge 1 commit intopytest-dev:mainfrom
miketheman:miketheman/speed-up-test-sutie

Conversation

@miketheman
Copy link
Copy Markdown
Contributor

The 5-iteration default was borrowed from the Trio project, where it was determined empirically to handle PyPy's object resurrection behavior: on PyPy, objects like coroutines can survive GC rounds because executing their del can resurrect them.

On CPython, reference counting frees most objects immediately. One GC pass is sufficient to handle reference cycles, as confirmed by all test_unraisableexception tests passing (including the refcycle variants).

Use 1 pass on CPython and retain 5 on PyPy.

The 5-iteration default was borrowed from the Trio project, where it was
determined empirically to handle PyPy's object resurrection behavior: on
PyPy, objects like coroutines can survive GC rounds because executing their
__del__ can resurrect them.

On CPython, reference counting frees most objects immediately. One GC pass
is sufficient to handle reference cycles, as confirmed by all
test_unraisableexception tests passing (including the refcycle variants).

Use 1 pass on CPython and retain 5 on PyPy.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman
Copy link
Copy Markdown
Contributor Author

Draft, since I'm not certain this is a good idea.
I was able to shave ~30% of test runtime on a CPython-only test run locally, I'm curious to see the timings produced by GH Actions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant