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-139109: JIT _EXIT_TRACE to ENTER_EXECUTOR rather than _DEOPT by Fidget-Spinner · Pull Request #141573 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Nov 14, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This was responsible for the pretty big perf regression in the final benchmarks over the old JIT. It got missed in the flurry of commits and reviews at the end.

  • Issue: Trace recording JIT #139109

Sorry, something went wrong.

Uh oh!

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

All reactions
@Fidget-Spinner
JIT: _EXIT_TRACE to ENTER_EXECUTOR rather than _DEOPT
a9eac0f
@Fidget-Spinner
Fidget-Spinner requested a review from markshannon as a code owner November 14, 2025 20:47
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 14, 2025
@Fidget-Spinner Fidget-Spinner added the skip news label Nov 14, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 14, 2025
Trace recording JIT #139109
Open
Fidget-Spinner added 2 commits November 14, 2025 22:07
@Fidget-Spinner
Add a test
2cf4f58
@Fidget-Spinner
spelling
ca89c3c
efimov-mikhail
efimov-mikhail reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/optimizer.c Resolved

Uh oh!

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

Comment thread Lib/test/test_capi/test_opt.py Resolved

Uh oh!

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

Comment thread Lib/test/test_capi/test_opt.py Resolved

Uh oh!

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

efimov-mikhail
efimov-mikhail reviewed Nov 15, 2025
View reviewed changes
Comment thread Lib/test/test_capi/test_opt.py Outdated
# Inner loop warms up first.
# Outer loop warms up later, linking to the inner one.
# Therefore, at least two executors.
self.assertGreaterEqual(len(get_all_executors(f)), 2)

@efimov-mikhail efimov-mikhail Nov 15, 2025

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.

Could you please explain, why this test checks _DEOPT vs _EXIT_TRACE pair?
On my machine it passes both on this PR and on main branch.
Using option --enable-experimental-jit=interpreter or --enable-experimental-jit=yes also doesn't matter.

Sorry, something went wrong.

Uh oh!

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

All reactions

@Fidget-Spinner Fidget-Spinner Nov 15, 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.

Hmmm it shouldn't pass on main. Let me strengthen the test.

Sorry, something went wrong.

Uh oh!

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

efimov-mikhail reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@efimov-mikhail efimov-mikhail Nov 15, 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.

This version of test fails on main with --enable-experimental-jit=interpreter or with --enable-experimental-jit=yes as expected.

Sorry, something went wrong.

Uh oh!

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

All reactions
@efimov-mikhail

efimov-mikhail commented Nov 15, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Also, I've noticed related warning:

Python/optimizer.c: In function ‘_PyJit_translate_single_bytecode_to_trace’:
Python/optimizer.c:600:11: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘unsigned int’ due to unsignedness of other operand [-Wsign-compare]
  600 |         ? (int)(target_instr - _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS_PTR)
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All reactions

Sorry, something went wrong.

Uh oh!

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

efimov-mikhail
efimov-mikhail reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/optimizer.c Resolved

Uh oh!

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

@Fidget-Spinner
Fix test
2d735c3
@Fidget-Spinner
Fidget-Spinner requested a review from efimov-mikhail November 15, 2025 14:24
efimov-mikhail
efimov-mikhail approved these changes Nov 15, 2025
View reviewed changes
Comment thread Lib/test/test_capi/test_opt.py Resolved

Uh oh!

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

@Fidget-Spinner
Update test_opt.py
93c9226
@Fidget-Spinner

Fidget-Spinner commented Nov 15, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I'm going to merge this as it's a minor but important fix and I have an approval. Sorry Mark if you want to review it. We can make any further changes in your PR that comes with the switch-case for trace recording.

All reactions

Sorry, something went wrong.

Uh oh!

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

@efimov-mikhail

efimov-mikhail commented Nov 15, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

JFTR, I don't know much about the perfomance implications of this PR.
But I'm sure that it's a clean fix with a correct test.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Nov 15, 2025

Copy link
Copy Markdown
Member Author

Well, I don't know the exact perf implications either. However, the implication is the following:

  1. Currently, when we hit another ENTER_EXECUTOR (ie another executor is seen), we end with _DEOPT.
  2. _DEOPT goes back to the interpreter, and does not link executors.

Meanwhile, _EXIT_TRACE links executors. So if we see an ENTER_EXECUTOR and end with an _EXIT_TRACE, we end up linking from the first executor to the executor at the exit.

For Jitted code, the benefits of staying in jitted code without going from jit -> interpreter -> back to jit is enormous. It's one function call with lots of register moves.

efimov-mikhail and chris-eibl 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.

@efimov-mikhail

efimov-mikhail commented Nov 15, 2025

Copy link
Copy Markdown
Member

Yes, I understand the purpose of this change. Meanwhile, thanks for the detailed clarification.

Fidget-Spinner 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
Fidget-Spinner merged commit ed73c90 into python:main Nov 15, 2025
97 of 99 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 15, 2025
@Fidget-Spinner
Fidget-Spinner deleted the fix_deopt branch November 15, 2025 20:20
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@Fidget-Spinner @StanFromIreland
pythongh-139109: JIT _EXIT_TRACE to ENTER_EXECUTOR rather than _DEOPT (…
0506a48
…pythonGH-141573)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@efimov-mikhail efimov-mikhail efimov-mikhail approved these changes
@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.

2 participants

@Fidget-Spinner @efimov-mikhail
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.