8000 GH-136410: Faster side exits by markshannon · Pull Request #136411 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-136410: Faster side exits #136411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

markshannon
Copy link
Member
@markshannon markshannon commented Jul 8, 2025

This PR reinstates the _COLD_EXIT uop, but this time expects the exit to be passed, not the executor.
This way we only need one jitted stub, not hundreds.

Using stubs hugely simplifies _EXIT_TRACE as all it needs to do is jump to the exit's executor.

The x86-64 stencil for _EXIT_TRACE shrinks from 384 bytes to 36 bytes, although it does require one extra _CHECK_VALIDITY (19 bytes) to be added to each trace.
Since traces often contain multiple _EXIT_TRACEs this is a substantial space saving.

// from being immediately detected as cold and invalidated.
cold->vm_data.warm = true;
if (_PyJIT_Compile(cold, cold->trace, 1)) {
Py_DECREF(cold);
Copy link
Member
@Fidget-Spinner Fidget-Spinner Jul 8, 2025

Choose a reason for hiding this comment

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

It's immortal. Decrefing won't do anything. I think you mean to call the dealloc function on it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good spot. I think I need to move making it immortal to after it is fully created.

@markshannon
Copy link
Member Author

@pablogsal
Copy link
Member

@pablogsal any ideas what this failure means? https://github.com/python/cpython/actions/runs/16140914160/job/45547999926?pr=136411

Is a race condition in the tests that will be fixed by #136347

@markshannon
Copy link
Member Author

Performance is in the noise:

  • Linux x86 +0.4%
  • Windows x86 -0.1%
  • Mac ARM +0.2%

However, I wouldn't expect much of a speedup by reducing the size of exits, so this seems reasonable.

@Fidget-Spinner
Copy link
Member

I think the benchmarking public mirror is down. Can you please share the link when it comes up again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0