GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.14] GH-139951: Fix major GC performance regression (GH-140262) by miss-islington · Pull Request #140423 · python/cpython

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 21, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead

  • Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
    (cherry picked from commit 0c01090)

Co-authored-by: Mark Shannon [email protected]

  • Issue: Potentially serious regression in garbage collector performance in Python 3.14 #139951

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon @miss-islington
pythonGH-139951: Fix major GC performance regression (pythonGH-140262)
f778f01
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead

* Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
(cherry picked from commit 0c01090)

Co-authored-by: Mark Shannon <[email protected]>
@bedevere-app bedevere-app Bot mentioned this pull request Oct 21, 2025
Potentially serious regression in garbage collector performance in Python 3.14 #139951
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Oct 21, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Oct 21, 2025
GH-139951: Fix major GC performance regression #140262
Merged
@sergey-miryanov

sergey-miryanov commented Oct 21, 2025 •
edited by hugovk
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The following change fixes free-threading tests (mainly -1386,10 +1385,6 fixes tests, other is a cleanup):

diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index db643330894..d7a4c066437 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -3,8 +3,7 @@
 from test import support
 from test.support import (verbose, refcount_test,
                           cpython_only, requires_subprocess,
-                          requires_gil_enabled,
-                          Py_GIL_DISABLED)
+                          requires_gil_enabled)
 from test.support.import_helper import import_module
 from test.support.os_helper import temp_dir, TESTFN, unlink
 from test.support.script_helper import assert_python_ok, make_script, run_test_script
@@ -1386,10 +1385,6 @@ def callback(ignored):
         junk = []
         i = 0
         detector = GC_Detector()
-        if Py_GIL_DISABLED:
-            # The free-threaded build doesn't have multiple generations, so
-            # just trigger a GC manually.
-            gc.collect()
         assert not detector.gc_happened
         while not detector.gc_happened:
             i += 1
@@ -1459,10 +1454,6 @@ def __del__(self):
         detector = GC_Detector()
         junk = []
         i = 0
-        if Py_GIL_DISABLED:
-            # The free-threaded build doesn't have multiple generations, so
-            # just trigger a GC manually.
-            gc.collect()
         while not detector.gc_happened:
             i += 1
             if i > 50000:

Is it fine if I add such commit to this PR? Should we apply this change to the main?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@efimov-mikhail

efimov-mikhail commented Oct 22, 2025

Copy link
Copy Markdown
Member

Сс @colesbury

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@colesbury

colesbury commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

The test has a @unittest.skipIf(Py_GIL_DISABLED, "requires GC generations or increments") on main, it should have the same on 3.14

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@colesbury colesbury mentioned this pull request Oct 22, 2025
[3.14] GH-139951: Fix major GC performance regression. Backport of GH-140262 #140447
Merged
@markshannon

markshannon commented Oct 23, 2025

Copy link
Copy Markdown
Member

Closing in favor of #140447

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon markshannon closed this Oct 23, 2025
@miss-islington
miss-islington deleted the backport-0c01090-3.14 branch January 2, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@miss-islington @sergey-miryanov @efimov-mikhail @colesbury @markshannon
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.