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 — gh-134584: Cleanups for refcount elimination #135860 by Fidget-Spinner · Pull Request #142604 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Dec 11, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This cleans up PR #135860.

Mostly just moving code around.

  • Issue: Eliminate redundant refcounting in the JIT #134584

Sorry, something went wrong.

Uh oh!

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

All reactions
@Fidget-Spinner
Cleanups for refcount elimnation python#136104 and python#135860
10f0bfa
@Fidget-Spinner
Fidget-Spinner requested review from markshannon and tomasr8 as code owners December 11, 2025 21:59
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 11, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 11, 2025
Eliminate redundant refcounting in the JIT #134584
Closed
35 tasks done
@Fidget-Spinner
fix type annotations
93022b2
@Fidget-Spinner Fidget-Spinner added the skip news label Dec 11, 2025
corona10
corona10 approved these changes Dec 12, 2025
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Dec 12, 2025
markshannon
markshannon previously requested changes Dec 12, 2025
View reviewed changes

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a separate PRs for fixing the leak? I'd like to get that in ASAP.

For the larger changes:

  • There is no need for _POP_TOP_NOT_NULL as it still needs to check for immortal objects and NULL is immortal
  • The changes to the code generator need more explanation and maybe a new issue.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/bytecodes.c Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting merge labels Dec 12, 2025
@bedevere-app

bedevere-app Bot commented Dec 12, 2025

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Dec 12, 2025

Copy link
Copy Markdown
Member Author

Can you make a separate PRs for fixing the leak? I'd like to get that in ASAP.

I can't without a partial revert. The problem is that we don't allow live inputs at ERROR_IF. This PR simply changes the ERROR_IF behavior to close all live inputs.

The rest of this PR to the cases generator is just moving stuff around if you take a closer look. I mainly had to expose the close_variable function as it was previously a nested one.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner
address review
ec5a67c
@vstinner vstinner mentioned this pull request Dec 12, 2025
gh-134584: Eliminate redundant refcounting from _CALL_TUPLE_1 #135860
Merged
@Fidget-Spinner Fidget-Spinner mentioned this pull request Dec 12, 2025
gh-134584: Revert partially #135860 #142620
Merged
@Zheaoli

Zheaoli commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

Just for personal thought(correct me plz if I'm wrong)

The root cause about this refleak is related with the wrong position about ERROR_IF. In this case, in old generated code, the arg will leak after ERROR_IF

So the core point about this PR is the behavior change "raise an exception when here's live variable on TOS -> close all the live variable"

So we can mark the stack INPUT_DEAD safety after ERROR_IF after this PR

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Dec 12, 2025

Copy link
Copy Markdown
Member Author

@Zheaoli yes you're right

Zheaoli reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner added 3 commits December 13, 2025 00:24
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into cleanups_refcount
18217d3
@Fidget-Spinner
merge changes from upstream
b2668b9
@Fidget-Spinner
undo code generator changes
c633ddf
@Fidget-Spinner Fidget-Spinner changed the title gh-134584: Cleanups for refcount elimination #136104 and #135860 gh-134584: Cleanups for refcount elimination #135860 Dec 13, 2025
@Fidget-Spinner
Fidget-Spinner requested a review from markshannon December 13, 2025 00:32
@Fidget-Spinner

Fidget-Spinner commented Dec 13, 2025

Copy link
Copy Markdown
Member Author

Can you make a separate PRs for fixing the leak? I'd like to get that in ASAP.

For the larger changes:

  • There is no need for _POP_TOP_NOT_NULL as it still needs to check for immortal objects and NULL is immortal
  • The changes to the code generator need more explanation and maybe a new issue.

I removed all the changes to the code generator and POP_TOP_NOT_NULL. As such, this review is now stale.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner
Fidget-Spinner dismissed markshannon’s stale review December 13, 2025 14:28

I removed all the changes that were contentious. This PR is now just a re-implementation of #135860. So it's fine now as that was previously approved and merged.

corona10
corona10 approved these changes Dec 13, 2025
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the current change is only a reimplementation of _CALL_TUPLE_1 from #135860, it looks good to me.

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting changes labels Dec 13, 2025
@Fidget-Spinner
Fidget-Spinner merged commit e02a35c into python:main Dec 13, 2025
71 of 72 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 13, 2025
@Fidget-Spinner
Fidget-Spinner deleted the cleanups_refcount branch December 13, 2025 14:38
@bedevere-bot

bedevere-bot commented Dec 13, 2025

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows PGO NoGIL 3.x (tier-1) has failed when building commit e02a35c.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1622/builds/3361) and take a look at the build logs.
  4. Check if the failure is related to this commit (e02a35c) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1622/builds/3361

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 30, done.        
remote: Counting objects:   3% (1/27)        
remote: Counting objects:   7% (2/27)        
remote: Counting objects:  11% (3/27)        
remote: Counting objects:  14% (4/27)        
remote: Counting objects:  18% (5/27)        
remote: Counting objects:  22% (6/27)        
remote: Counting objects:  25% (7/27)        
remote: Counting objects:  29% (8/27)        
remote: Counting objects:  33% (9/27)        
remote: Counting objects:  37% (10/27)        
remote: Counting objects:  40% (11/27)        
remote: Counting objects:  44% (12/27)        
remote: Counting objects:  48% (13/27)        
remote: Counting objects:  51% (14/27)        
remote: Counting objects:  55% (15/27)        
remote: Counting objects:  59% (16/27)        
remote: Counting objects:  62% (17/27)        
remote: Counting objects:  66% (18/27)        
remote: Counting objects:  70% (19/27)        
remote: Counting objects:  74% (20/27)        
remote: Counting objects:  77% (21/27)        
remote: Counting objects:  81% (22/27)        
remote: Counting objects:  85% (23/27)        
remote: Counting objects:  88% (24/27)        
remote: Counting objects:  92% (25/27)        
remote: Counting objects:  96% (26/27)        
remote: Counting objects: 100% (27/27)        
remote: Counting objects: 100% (27/27), done.        
remote: Compressing objects:   7% (1/13)        
remote: Compressing objects:  15% (2/13)        
remote: Compressing objects:  23% (3/13)        
remote: Compressing objects:  30% (4/13)        
remote: Compressing objects:  38% (5/13)        
remote: Compressing objects:  46% (6/13)        
remote: Compressing objects:  53% (7/13)        
remote: Compressing objects:  61% (8/13)        
remote: Compressing objects:  69% (9/13)        
remote: Compressing objects:  76% (10/13)        
remote: Compressing objects:  84% (11/13)        
remote: Compressing objects:  92% (12/13)        
remote: Compressing objects: 100% (13/13)        
remote: Compressing objects: 100% (13/13), done.        
remote: Total 30 (delta 16), reused 14 (delta 14), pack-reused 3 (from 2)        
From https://github.com/python/cpython
 * branch                    main       -> FETCH_HEAD
Note: switching to 'e02a35c36535330bb86b4067104f537aa6da00e4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at e02a35c3653 gh-134584: Cleanups for GH-135860 (GH-142604)
Switched to and reset branch 'main'

Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\*.pgc
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\Lib\*.pyc
'"C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\\..\python.bat"' is not recognized as an internal or external command,
operable program or batch file.
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\*.pgc
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\Lib\*.pyc
'"C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\\..\python.bat"' is not recognized as an internal or external command,
operable program or batch file.
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\Lib\*.pyc
The system cannot find the file specified.
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\python*.zip
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\*.pgc
Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\Lib\*.pyc

Could Not Find C:\Users\Administrator\buildarea\3.x.itamaro-win64-srv-22-aws.nogil.pgo\build\PCbuild\python*.zip
All reactions

Sorry, something went wrong.

Uh oh!

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

@Zheaoli Zheaoli mentioned this pull request Dec 14, 2025
gh-134584: Eliminate redundant refcounting from _CALL_STR_1 #136070
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@corona10 corona10 corona10 approved these changes
@tomasr8 tomasr8 Awaiting requested review from tomasr8 tomasr8 is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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

@Fidget-Spinner @Zheaoli @bedevere-bot @corona10 @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.