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: Eliminate redundant refcounting from `_CALL_TUPLE_1` by noamcohen97 · Pull Request #135860 · python/cpython

Conversation

@noamcohen97

@noamcohen97 noamcohen97 commented Jun 23, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • 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
@noamcohen97
eliminate refcount from _CALL_TUPLE_1
af1172a
@noamcohen97
noamcohen97 requested review from Fidget-Spinner, markshannon and tomasr8 as code owners June 23, 2025 20:19
@bedevere-app bedevere-app Bot added the awaiting review label Jun 23, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Jun 23, 2025
Eliminate redundant refcounting in the JIT #134584
Closed
35 tasks done
noamcohen97 added 2 commits June 23, 2025 23:23
@noamcohen97
test case
5a805a9
@noamcohen97
news entry
c7c4873
@noamcohen97
noamcohen97 force-pushed the refcount-call-tuple-1 branch from f99ffdd to c7c4873 Compare June 23, 2025 20:24
@Fidget-Spinner

Fidget-Spinner commented Jun 23, 2025

Copy link
Copy Markdown
Member

Nice! That was fast. This PR LGTM, but we need to wait will Mark merges his register allocation PR to get the benefits of this work. See my other comment here #135818 (comment)

noamcohen97 and auvipy reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner
Fidget-Spinner reviewed Dec 11, 2025
View reviewed changes
Comment thread Python/bytecodes.c Resolved

Uh oh!

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

noamcohen97 added 3 commits December 11, 2025 15:07
@noamcohen97
Merge branch 'main' into refcount-call-tuple-1
6c4d7f3
@noamcohen97
move INPUTS_DEAD() to the right place
f392667
@noamcohen97
add pop_3_error
2aaafd2
Fidget-Spinner
Fidget-Spinner reviewed Dec 11, 2025
View reviewed changes
Comment thread Python/bytecodes.c Resolved

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Dec 11, 2025

Copy link
Copy Markdown
Member

Cool. I see an ~5% improvement in this code:

def foo():
    for x in range(200000000):
        tuple(())
    return None

foo()
Before:
real	0m3.497s

After:
real	0m3.323s

Considering only one reference count was eliminated, this is good news for everything else that will remove more!

noamcohen97 reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner
Fidget-Spinner approved these changes Dec 11, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Dec 11, 2025
@Fidget-Spinner
Fidget-Spinner merged commit a78f43b into python:main Dec 11, 2025
74 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 11, 2025
@Fidget-Spinner

Fidget-Spinner commented Dec 11, 2025

Copy link
Copy Markdown
Member

@markshannon sorry can you please check if this is correct? I think the ERROR_IF might be misplaced, sorry!

noamcohen97 reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Dec 11, 2025

Copy link
Copy Markdown
Member

the generated code looks correct but I wonder if the C analyzer treats it any differently

All reactions

Sorry, something went wrong.

Uh oh!

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

@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

@markshannon sorry can you please check if this is correct? I think the ERROR_IF might be misplaced, sorry!

So this seems to be the case. If you look at the error case, it leaks a reference on exit, as it doesn't decref/close it. Sorry I have to revert this PR, or provide a fix. So sorry again!

All reactions

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner added a commit to Fidget-Spinner/cpython that referenced this pull request Dec 11, 2025
@Fidget-Spinner
Cleanups for refcount elimnation python#136104 and python#135860
f8d4df7
Fidget-Spinner added a commit to Fidget-Spinner/cpython that referenced this pull request Dec 11, 2025
@Fidget-Spinner
Cleanups for refcount elimnation python#136104 and python#135860
10f0bfa
@Fidget-Spinner Fidget-Spinner mentioned this pull request Dec 11, 2025
gh-134584: Cleanups for refcount elimination #135860 #142604
Merged
@markshannon

markshannon commented Dec 12, 2025

Copy link
Copy Markdown
Member

I think the ERROR_IF might be misplaced, sorry!

Yes, this leaks arg

All reactions

Sorry, something went wrong.

Uh oh!

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

fatelei pushed a commit to fatelei/cpython that referenced this pull request Dec 12, 2025
@noamcohen97 @fatelei
pythongh-134584: Eliminate redundant refcounting from _CALL_TUPLE_1 (…
55856a3
…pythonGH-135860)
Fidget-Spinner added a commit to Fidget-Spinner/cpython that referenced this pull request Dec 12, 2025
@Fidget-Spinner
Revert partially python#135860
e2f0de3
@vstinner

vstinner commented Dec 12, 2025

Copy link
Copy Markdown
Member

I confirm that this change introduced a memory leak in the following tests:

7 tests failed:
    test.test_multiprocessing_fork.test_processes
    test.test_multiprocessing_fork.test_threads
    test.test_multiprocessing_forkserver.test_processes
    test.test_multiprocessing_forkserver.test_threads
    test.test_multiprocessing_spawn.test_processes
    test.test_multiprocessing_spawn.test_threads test_dbm_dumb

Example AMD64 Fedora Stable Refleaks 3.x: https://buildbot.python.org/#/builders/320/builds/3425

$ ./python -m test test.test_multiprocessing_fork.test_threads -R 3:3 -m test_map_handle_iterable_exception

test.test_multiprocessing_fork.test_threads leaked [4, 4, 4] references, sum=12
test.test_multiprocessing_fork.test_threads leaked [2, 2, 2] memory blocks, sum=6
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Dec 12, 2025

Copy link
Copy Markdown
Member

@Fidget-Spinner wrote #142604 to fix the leak.

All reactions

Sorry, something went wrong.

Uh oh!

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

@noamcohen97

noamcohen97 commented Dec 12, 2025

Copy link
Copy Markdown
Contributor Author

Sorry about that! Thanks @Fidget-Spinner 🙏

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Dec 12, 2025

Copy link
Copy Markdown
Member

@Fidget-Spinner wrote #142604 to fix the leak.

He wrote another change to fix the leak: #142620.

All reactions

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner added a commit that referenced this pull request Dec 12, 2025
@Fidget-Spinner
gh-134584: Revert partially GH-135860 (GH-142620)
a3a611b
Fidget-Spinner added a commit that referenced this pull request Dec 13, 2025
@Fidget-Spinner
gh-134584: Cleanups for GH-135860 (GH-142604)
e02a35c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Fidget-Spinner Fidget-Spinner Fidget-Spinner 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

None yet

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.

4 participants

@noamcohen97 @Fidget-Spinner @markshannon @vstinner
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.