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-119866: Don't clear `frame->stackpointer` on release builds by brandtbucher · Pull Request #131750 · python/cpython

Conversation

@brandtbucher

@brandtbucher brandtbucher commented Mar 26, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This is only useful for asserts to make sure that we're spilling and restoring the stack pointer in all the right places. Removing these frequent stores makes the interpreter 0.7% faster and the JIT 0.4% faster.

  • Issue: Spill the stack pointer across calls in the interpreter. #119866

Sorry, something went wrong.

Uh oh!

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

All reactions
@brandtbucher
Don't set the stack pointer to NULL on release builds
7b432e3
@brandtbucher brandtbucher added performance Performance or resource usage skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 26, 2025
@brandtbucher
brandtbucher requested a review from markshannon March 26, 2025 00:44
@brandtbucher brandtbucher self-assigned this Mar 26, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 26, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 26, 2025
Spill the stack pointer across calls in the interpreter. #119866
Closed
chris-eibl
chris-eibl reviewed Mar 26, 2025
View reviewed changes
Comment thread Include/internal/pycore_interpframe.h
{
assert(frame->stackpointer != NULL);
_PyStackRef *sp = frame->stackpointer;
#ifndef NDEBUG

@chris-eibl chris-eibl Mar 26, 2025 •
edited
Loading

Uh oh!

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

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.

Maybe then update the comment

Having stackpointer == NULL ensures that invalid
   values are not visible to the cycle GC.

Seems that this was done for the cycle GC - if this is no longer needed, just remove the comment?

Out of curiousity: is it safe in release builds to let the cycle GC see invalid values?

Sorry, something went wrong.

Uh oh!

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

All reactions

@brandtbucher brandtbucher Mar 26, 2025

Copy link
Copy Markdown
Member Author

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.

We want to have "deferred" references on the stack, which means that the GC must be able to see all stack values, and only valid stack values.

Setting the stack pointer to NULL is only useful for our asserts, which are sprinkled throughout to make sure that we're spilling and restoring in the correct places. Basically, the GC should never see an invalid stack pointer. On debug builds, we make this easier to detect by setting invalid stack pointers to NULL and checking for this.

Either way, I'll update the comment.

Sorry, something went wrong.

Uh oh!

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

chris-eibl reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Fidget-Spinner
Fidget-Spinner approved these changes Mar 26, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 26, 2025
@brandtbucher
Update comment
a0c76fd
@brandtbucher
brandtbucher enabled auto-merge (squash) March 26, 2025 18:33
@brandtbucher
brandtbucher merged commit 4b3d5b6 into python:main Mar 26, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 26, 2025
@colesbury colesbury mentioned this pull request Mar 28, 2025
computed-goto interpreter: Prevent the compiler from merging DISPATCH calls #129987
Closed
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 1, 2025
@brandtbucher @diegorusso
pythonGH-119866: Don't clear frame->stackpointer on release builds (p…
c797eca
…ythonGH-131750)
@mpage mpage mentioned this pull request Apr 9, 2025
gh-129987: Disable GCC SLP autovectorization for the interpreter loop on x86-64 #132295
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chris-eibl chris-eibl chris-eibl left review comments
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes
@markshannon markshannon Awaiting requested review from markshannon

Uh oh!

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

Assignees

@brandtbucher brandtbucher

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage 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.

3 participants

@brandtbucher @Fidget-Spinner @chris-eibl
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.