python / python/cpython

Performance regression with cyclic GC vs 3.13

Open
#129,210 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core performance type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

While working on the free-threaded GC, I noticed this performance regression with the default build GC. Running the attached script (bm_gc_collect.py) with the main branch of Python shows much worse performance vs 3.13. I get 20.8 seconds for the main branch and 3.3 seconds for 3.13. Adding gc.disable() before calling benchmark_collection() seems to fix it.

bm_gc_collect.py.txt

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-132488

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the attached bm_gc_collect.py script on CPython main and Python 3.13 under Linux, comparing the reported collection times with and without gc.disable(). Read the linked PR gh-132488 and the free-threaded GC changes it addresses; done means resolving the regression so the benchmark is no longer substantially slower than 3.13.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.