FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131798: fold super method lookups in JIT by kumaraditya303 · Pull Request #148231 · python/cpython · GitHub

Repository navigation

gh-131798: fold super method lookups in JIT - #148231

Merged
kumaraditya303 merged 10 commits into
python:mainfrom
kumaraditya303:jit-super
Apr 9, 2026
Merged

kumaraditya303 merged 10 commits into
python:mainfrom
kumaraditya303:jit-super

Conversation

kumaraditya303 commented Apr 7, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Fidget-Spinner changed the title gh-131798: cache super method lookups in JIT gh-131798: fold super method lookups in JIT Apr 7, 2026

Copy link
Copy Markdown
Member

I see a 10% speedup on richards_super with this PR!

Mean +- std dev: [richards_super_main] 28.8 ms +- 0.5 ms -> [richards_super_fold] 26.1 ms +- 0.5 ms: 1.10x faster

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good, just one stylistic nit. Thanks!

return sym_new_not_null(ctx);
}
/* Normal case: obj_type must be a subtype of su_type */
if (!PyType_IsSubtype(obj_type, su_type)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note to self: this is not same as subclasscheck/instancecheck, which can call arbitrary code.

Comment thread Python/optimizer_analysis.c Outdated

Copy link
Copy Markdown
Member

Please fix the merge conflicts. LOAD_CONST_UNDER_INLINE_BORROW was removed as it's a duplicate of _INSERT_1_LOAD_CONST_INLIE_BORROW #148235

Copy link
Copy Markdown
Contributor Author

Please fix the merge conflicts.

Fixed.

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks. This LGTM.

_Py_BloomFilter_Add(dependencies, su_type);
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)obj_type);
_Py_BloomFilter_Add(dependencies, obj_type);
return sym_new_const_steal(ctx, lookup);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note to self: need steal version because _PySuper_Lookup returns a strong reference, unlike _PyType_Lookup

Copy link
Copy Markdown
Member

Please pull in main and regen cases. Thank you.

Copy link
Copy Markdown
Member

Can we have a test for the case where the superclass changes after optimization, to make sure that we de-opt properly?

Copy link
Copy Markdown
Contributor Author

Added test and fixed merge conflicts.

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for adding the test

kumaraditya303 merged commit 458aca9 into python:main Apr 9, 2026
74 checks passed
kumaraditya303 deleted the jit-super branch April 9, 2026 07:55
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL