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

gh-144991: Use runtime JIT threshold in _testinternalcapi by corona10 · Pull Request #145496 · python/cpython · GitHub

Repository navigation

gh-144991: Use runtime JIT threshold in _testinternalcapi - #145496

Merged
corona10 merged 4 commits into
python:mainfrom
corona10:gh-144991
Mar 5, 2026
Merged

corona10 merged 4 commits into
python:mainfrom
corona10:gh-144991

Conversation

corona10 commented Mar 4, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

bedevere-app Bot added the tests Tests in the Lib/test dir label Mar 4, 2026

corona10 commented Mar 4, 2026

Copy link
Copy Markdown
Member Author

@markshannon @Fidget-Spinner

TIER2_THRESHOLD was hardcoded using the JUMP_BACKWARD_INITIAL_VALUE,
which doesn't reflect runtime overrides.
This fix intends to read the actual value from interp->opt_config at module init instead.

Comment thread Modules/_testinternalcapi.c Outdated
if (PyModule_Add(module, "TIER2_THRESHOLD",
// + 1 more due to one loop spent on tracing.
PyLong_FromLong(JUMP_BACKWARD_INITIAL_VALUE + 2)) < 0) {
PyLong_FromLong(interp->opt_config.jump_backward_initial_value + 2)) < 0) {

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

You may use PyLong_FromUnsignedLong() since the member is unsigned (uint16_t). Suggestion to use shorter lines:

    PyInterpreterState *interp = PyInterpreterState_Get();
    // + 1 more due to one loop spent on tracing.
    unsigned long threshold = interp->opt_config.jump_backward_initial_value + 2;
    if (PyModule_Add(module, "TIER2_THRESHOLD",
                        PyLong_FromUnsignedLong(threshold)) < 0) {
        return 1;
    }

vstinner commented Mar 4, 2026

Copy link
Copy Markdown
Member

"aarch64-pc-windows-msvc/msvc (Debug)" failed with:

Assertion failed: index < _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES, file C:\a\cpython\cpython\Objects\typeobject.c, line 323

The recent change commit e6c3c04 added a new static type to static_types array. I suppose that #define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 201 should be updated.

corona10 requested a review from vstinner March 4, 2026 14:26
Comment thread Modules/_testinternalcapi.c Outdated
Co-authored-by: Victor Stinner <vstinner@python.org>
Comment thread Modules/_testinternalcapi.c Outdated

vstinner 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

LGTM

/* For now we hard-code this to a value for which we are confident
all the static builtin types will fit (for all builds). */
#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 201
#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 202

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

Why was this changed?

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

Because a new static type was added recently, and JIT tests crash or fail with an assertion error without this change: #145496 (comment)

corona10 merged commit 8b54313 into python:main Mar 5, 2026
67 checks passed
corona10 deleted the gh-144991 branch March 15, 2026 10:11
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

Labels

skip news tests Tests in the Lib/test dir topic-JIT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL