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-146099: Optimize _GUARD_CODE_VERSION+IP via function version symbols by Fidget-Spinner · Pull Request #146101 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Mar 18, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Optimize _GUARD_CODE_VERSION and _GUARD_IP__PUSH_FRAME #146099

Sorry, something went wrong.

Uh oh!

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

All reactions
@Fidget-Spinner
Optimize _GUARD_CODE_VERSION+IP via fun version symbols
65e1f94
@Fidget-Spinner
Fidget-Spinner requested review from markshannon, savannahostrowski and tomasr8 as code owners March 18, 2026 09:47
@Fidget-Spinner Fidget-Spinner added the skip news label Mar 18, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Mar 18, 2026
Optimize _GUARD_CODE_VERSION and _GUARD_IP__PUSH_FRAME #146099
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 18, 2026
Fidget-Spinner added 2 commits March 18, 2026 18:10
@Fidget-Spinner
try removing buggy thing
15961e8
@Fidget-Spinner
fix macOS builds
0b05457
markshannon
markshannon requested changes Mar 19, 2026
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.

Thanks for doing this, the general approach looks sound.
I've spotted one correctness issue, and suggested a few minor tweaks

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_bytecodes.c Outdated
PyCodeObject *co = get_current_code_object(ctx);
if (co->co_version == version) {
_Py_BloomFilter_Add(dependencies, co);
if (sym_get_func_version(ctx->frame->callable) != 0) {

@markshannon markshannon Mar 19, 2026

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.

Suggested change
if (sym_get_func_version(ctx->frame->callable) != 0) {
if (sym_get_func_version(ctx->frame->callable) == version) {

If the version is different this guard should fail

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_symbols.c Outdated
| KNOWN_CLASS--+ | | |
| | | | | | PREDICATE RECORDED_VALUE(known type)
| | | INT* | | | |
| | | | FUNC_VERSION | | | <- Anything below this level has a known truthiness.

@markshannon markshannon Mar 19, 2026

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.

The comment says that anything below this line has known truthiness, and functions are always true.
Add a new line below the "Anything below this level has a known truthiness" line

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_symbols.c Outdated
printf("<v%u at %p>", sym->version.version, (void *)sym);
break;
case JIT_SYM_FUNC_VERSION_TAG:
printf("<fv%u at %p>", sym->func_version.func_version, (void *)sym);

@markshannon markshannon Mar 19, 2026

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.

Suggested change
printf("<fv%u at %p>", sym->func_version.func_version, (void *)sym);
printf("<function version=%u>", sym->func_version.func_version);

Be a bit less cryptic (the pointer contains no useful information)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_symbols.c Outdated
((PyFunctionObject *)sym->recorded_value.value)->func_version != version) {
sym_set_bottom(ctx, sym);
return false;
}

@markshannon markshannon Mar 19, 2026

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.

Suggested change
}
}

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 changes and removed awaiting core review labels Mar 19, 2026
@bedevere-app

bedevere-app Bot commented Mar 19, 2026

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
Address review
1ae5bbd
@Fidget-Spinner

Fidget-Spinner commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

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.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Mar 19, 2026
@bedevere-app

bedevere-app Bot commented Mar 19, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@markshannon: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app
bedevere-app Bot requested a review from markshannon March 19, 2026 14:40
@Fidget-Spinner
reduce diff
418eeea
@Fidget-Spinner

Fidget-Spinner commented Mar 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I can confirm this fixes somewhat the regression seen on x86_64 for base16 benchmark in the past few days:

base16_large: Mean +- std dev: [base64_main] 10.2 ms +- 0.2 ms -> [base64_fixed] 9.38 ms +- 0.17 ms: 1.08x faster

All reactions

Sorry, something went wrong.

Uh oh!

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

markshannon
markshannon approved these changes Mar 20, 2026
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.

Looks good now. Thanks

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 change review labels Mar 20, 2026
@markshannon
markshannon merged commit acfb452 into python:main Mar 20, 2026
69 of 70 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 20, 2026
@Fidget-Spinner
Fidget-Spinner deleted the opt_guard_code_version_2 branch March 20, 2026 12:40
@Sacul0457 Sacul0457 mentioned this pull request Mar 21, 2026
gh-131798: Split CHECK_FUNCTION_VERSION into two guards in the JIT #145080
Open
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Mar 22, 2026
@CuriousLearner
Merge remote-tracking branch 'upstream/main' into fix-pythongh-138577
2691ad9
* upstream/main: (1475 commits)
  Docs: replace all `datetime` imports with `import datetime as dt` (python#145640)
  pythongh-146153: Use `frozendict` in pure python fallback for `curses.has_key` (python#146154)
  pythongh-138234: clarify returncode behavior for subprocesses created with `shell=True` (python#138536)
  pythongh-140947: fix contextvars handling for server tasks in asyncio  (python#141158)
  pythonGH-100108: Add async generators best practices section (python#141885)
  pythonGH-145667: Merge `GET_ITER` and `GET_YIELD_FROM_ITER` (pythonGH-146120)
  pythongh-146228: Better fork support in cached FastPath (python#146231)
  pythongh-146227: Fix wrong type in _Py_atomic_load_uint16 in pyatomic_std.h (pythongh-146229)
  pythongh-145980: Fix copy/paste mistake in binascii.c (python#146230)
  pythongh-146092: Raise MemoryError on allocation failure in _zoneinfo (python#146165)
  pythongh-91279: Note `SOURCE_DATE_EPOCH` support in `ZipFile.writestr()` doc (python#139396)
  pythongh-146196: Fix Undefined Behavior in _PyUnicodeWriter_WriteASCIIString() (python#146201)
  pythongh-143930: Reject leading dashes in webbrowser URLs
  pythongh-145916: Soft-deprecate ctypes.util.find_library (pythonGH-145919)
  pythongh-146205: Check the errno with != 0 in close impls in select module (python#146206)
  pythongh-146171: Fix nested AttributeError suggestions (python#146188)
  pythongh-146099: Optimize _GUARD_CODE_VERSION+IP via function version symbols (pythonGH-146101)
  pythongh-145980: Add support for alternative alphabets in the binascii module (pythonGH-145981)
  pythongh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format (python#145756)
  pythongh-145177: Add emscripten run --test, uses test args from config.toml (python#146160)
  ...
@pablogsal pablogsal mentioned this pull request Apr 4, 2026
gh-130273: Fix traceback color output with unicode characters #142529
Merged
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@Fidget-Spinner @ljfp
pythongh-146099: Optimize _GUARD_CODE_VERSION+IP via function version…
13792cd
… symbols (pythonGH-146101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

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

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 @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.