-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
GH-133231: Add JIT utilities in sys._jit
#133233
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
base: main
Are you sure you want to change the base?
Conversation
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.
quick doc-only review:
Doc/library/sys.rst
Outdated
Return ``True`` if the topmost Python frame is currently executing JIT | ||
code, and ``False`` otherwise. | ||
|
||
.. note:: | ||
|
||
Due to the nature of tracing JIT compilers, repeated calls to this | ||
function may give surprising results. For example, branching on its | ||
return value will likely lead to unexpected behavior (if doing so | ||
causes JIT code to be entered or exited): |
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.
I think this section should have more emphasis that this is mainly for testing/debugging, per your rationale in Discourse:
- It seems useful for tests for the JIT itself.
- Lots of people have asked: “How do I know if the JIT is actually working?”
I would also suggest upgrading the 'note' about branching to a 'warning', if nothing else changes.
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.
I had thought that "warning" was reserved for security issues, or possible misuse of an API that could corrupt interpreter state or lead to crashes. This is just saying "the results may not be what you expect". Is a warning more appropriate than a note for calling out quirks like this?
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.
How's adding this to the top of the note:
This function is intended for testing and debugging the JIT itself. Beyond using it to confirm that the JIT is actually working, most users will never need to use it.
.. envvar:: PYTHON_JIT | ||
|
||
On builds where experimental just-in-time compilation is available, this | ||
variable can force the JIT to be disabled (``0``) or enabled (``1``) at | ||
interpreter startup. | ||
|
||
.. versionadded:: 3.13 |
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.
We should backport this, should it be split out into a different PR for ease?
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.
We can just backport it separately, since I need the ref for this PR's changes.
I just realized that my approach for |
Okay, reworked to support tail-calling. |
@markshannon, let me know what you think. The bots won't let us merge features without approving review, but I'd like to get something like this in before the freeze. |
sys._jit
#133231📚 Documentation preview 📚: https://cpython-previews--133233.org.readthedocs.build/