Title: [3.14t] Free-threaded GC performance regression on tuples · Issue #142531 · python/cpython · GitHub
Open Graph Title: [3.14t] Free-threaded GC performance regression on tuples · Issue #142531 · python/cpython
X Title: [3.14t] Free-threaded GC performance regression on tuples · Issue #142531 · python/cpython
Description: Bug report Bug description: I am observing a significant performance regression in the Python 3.14.2 Free-Threading build compared to the build with GIL when constructing large lists of tuples. This seems related to the recent work in is...
Open Graph Description: Bug report Bug description: I am observing a significant performance regression in the Python 3.14.2 Free-Threading build compared to the build with GIL when constructing large lists of tuples. Thi...
X Description: Bug report Bug description: I am observing a significant performance regression in the Python 3.14.2 Free-Threading build compared to the build with GIL when constructing large lists of tuples. Thi...
Opengraph URL: https://github.com/python/cpython/issues/142531
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[3.14t] Free-threaded GC performance regression on tuples","articleBody":"# Bug report\n\n### Bug description:\n\nI am observing a significant performance regression in the Python 3.14.2 Free-Threading build compared to the build with GIL when constructing large lists of tuples.\n\nThis seems related to the recent work in issue #139951 and PR #140262. While the Standard 3.14.2 build appears to have resolved the performance regression, the Free-Threading build is still significantly slower in this scenario. I have confirmed that 3.14.0 (regular builld) shows the performance regression, 3.14.2 (regular) seems to have fixed it (thanks to the previous PR) but 3.14.2t (at least the version shipped on uv) still contains the issue.\n\nI also see what is the output of `gc.is_tracked` (see below) for free threaded vs standard, there seems to be a difference but I did not dig into the details so far on how GC works on standard vs free threaded Python, sorry.\n\n### Benchmark Results (N=15,000,000) (r6id.8xlarge AWS instance)\n\n| Build | GC State | Time | `gc.is_tracked` says |\n| :--- | :--- | :--- | :--- |\n| **3.14.0 (Standard)** | Enabled | **142.876s** | `True` |\n| **3.14.0 (Standard)** | Disabled | **1.068s** | `True` |\n| **3.14.0 (Free-Threaded)** | Enabled | **37.074s** | `False` |\n| **3.14.0 (Free-Threaded)** | Disabled | **0.637s** | `False` |\n| **3.14.2 (Standard)** | Enabled | **0.974s** | `True` |\n| **3.14.2 (Standard)** | Disabled | **0.969s** | `True` |\n| **3.14.2 (Free-Threaded)** | Enabled | **36.679s** | `False` |\n| **3.14.2 (Free-Threaded)** | **Disabled** | **0.644s** | `False` |\n\n### Reproduction Script\n\n```python\nimport time\nimport gc\nimport sys\n\ndef benchmark_step(disable_gc):\n if disable_gc: \n gc.disable()\n \n t0 = time.perf_counter()\n _ = [(0, 0, i) for i in range(15_000_000)]\n dt = time.perf_counter() - t0\n \n status = \"GC DISABLED\" if disable_gc else \"GC ENABLED \"\n print(f\"{status}: {dt:.3f}s\")\n \n if disable_gc:\n gc.enable()\n\nif __name__ == \"__main__\":\n print(f\"Python Version: {sys.version}\")\n sample = (0, 0, 1)\n print(f\"Is tuple(int, int, int) tracked? {gc.is_tracked(sample)}\")\n \n print(\"--- Benchmark ---\")\n benchmark_step(disable_gc=False)\n benchmark_step(disable_gc=True)\n```\n\nIn more detail this is my 3.14.2 regular build:\nPython Version: 3.14.2 (main, Dec 9 2025, 19:03:28) [Clang 21.1.4 ]\n\nAnd my free threaded build:\nPython Version: 3.14.2 free-threading build (main, Dec 9 2025, 19:03:17) [Clang 21.1.4 ]\n\nIt's particularly weird that when disabling GC (despite the tuple being untracked) the regression goes away... Is it possible there is a disconnect between the flag `is_tracked` checks and the actual logic used by the free-threaded collector?\n\ncc @colesbury @nascheme @markshannon \n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-142562\n* gh-142617\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/MaxiBoether","@type":"Person","name":"MaxiBoether"},"datePublished":"2025-12-10T19:53:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/142531/cpython/issues/142531"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5c9a775a-2dcd-a78b-862e-6692e2d756ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D85C:15DFF5:170C3FF:1FC9ED6:696AA958 |
| html-safe-nonce | a473fa0d299e3f97167dde5da53e928ddd0d240071b4494f2a08c4e4bad4e89c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODVDOjE1REZGNToxNzBDM0ZGOjFGQzlFRDY6Njk2QUE5NTgiLCJ2aXNpdG9yX2lkIjoiODk4MDc1NDM1MjU5NDEzNTM4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 86f263f4e46a358de35bcc6c8cdb1dfd25128f452edc377bc40924c60cce354c |
| hovercard-subject-tag | issue:3716569473 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/142531/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c7b5c0b22a6be1465612c2d0ab337bb86fabc4ae785d8914f01f520fcd4da71d/python/cpython/issues/142531 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c7b5c0b22a6be1465612c2d0ab337bb86fabc4ae785d8914f01f520fcd4da71d/python/cpython/issues/142531 |
| og:image:alt | Bug report Bug description: I am observing a significant performance regression in the Python 3.14.2 Free-Threading build compared to the build with GIL when constructing large lists of tuples. Thi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MaxiBoether |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3eaf9b8cf1badcd7041a8ad480b9d9b28bea0ef1cc821ca9ff20f2cc7f4fe4b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd9a979046e6382bd084e2bd873bf65f797125ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width