Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-139038: Add JIT What's New for 3.15#142845
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
12 commits Select commit Hold shift + click to select a range
26cdf15 Add What's New for 3.15 JIT
savannahostrowski a851fe1 Fix formatting
savannahostrowski cdeaf99 Move section down
Fidget-Spinner ee16268 add code formatting
Fidget-Spinner 52e3566 Address Adam's review
Fidget-Spinner f133047 reformat
Fidget-Spinner 59f38a8 use rubric instead of title
Fidget-Spinner b5bb5d9 Update 3.15.rst
savannahostrowski 4a0c773 Apply suggestions from code review
savannahostrowski d396a0e Apply suggestions from Hugo's review
Fidget-Spinner d56dbda Align style with rest of bullet points
Fidget-Spinner bb76a0d Apply code review suggestions
Fidget-Spinner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -73,6 +73,7 @@ Summary -- Release highlights | ||
| <whatsnew315-utf8-default>` | ||
| * :pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object | ||
| <whatsnew315-pep782>` | ||
| * :ref:`The JIT compiler has been significantly upgraded <whatsnew315-jit>` | ||
| * :ref:`Improved error messages <whatsnew315-improved-error-messages>` | ||
| @@ -850,6 +851,91 @@ csv | ||
| (Contributed by Maurycy Pawłowski-Wieroński in :gh:`137628`.) | ||
| .. _whatsnew315-jit: | ||
| Upgraded JIT compiler | ||
| ===================== | ||
| Results from the `pyperformance <https://github.com/python/pyperformance>`__ | ||
| benchmark suite report | ||
| `3-4% <https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251214-3.15.0a2%2B-6cddf04-JIT/bm-20251214-vultr-x86_64-python-6cddf04344a1e8ca9df5-3.15.0a2%2B-6cddf04-vs-base.svg>`__ | ||
| geometric mean performance improvement for the JIT over the standard CPython | ||
| interpreter built with all optimizations enabled. The speedups for JIT | ||
| builds versus no JIT builds range from roughly 20% slowdown to over | ||
| 100% speedup (ignoring the ``unpack_sequence`` microbenchmark) on | ||
| x86-64 Linux and AArch64 macOS systems. | ||
| .. attention:: | ||
| These results are not yet final. | ||
| The major upgrades to the JIT are: | ||
| * LLVM 21 build-time dependency | ||
| * New tracing frontend | ||
| * Basic register allocation in the JIT | ||
| * More JIT optimizations | ||
| * Better machine code generation | ||
| .. rubric:: LLVM 21 build-time dependency | ||
| The JIT compiler now uses LLVM 21 for build-time stencil generation. As | ||
| always, LLVM is only needed when building CPython with the JIT enabled; | ||
| end users running Python do not need LLVM installed. Instructions for | ||
| installing LLVM can be found in the `JIT compiler documentation | ||
| <https://github.com/python/cpython/blob/main/Tools/jit/README.md>`__ | ||
| for all supported platforms. | ||
| (Contributed by Savannah Ostrowski in :gh:`140973`.) | ||
| .. rubric:: A new tracing frontend | ||
| The JIT compiler now supports significantly more bytecode operations and | ||
| control flow than in Python 3.14, enabling speedups on a wider variety of | ||
| code. For example, simple Python object creation is now understood by the | ||
| 3.15 JIT compiler. Overloaded operations and generators are also partially | ||
| supported. This was made possible by an overhauled JIT tracing frontend | ||
| that records actual execution paths through code, rather than estimating | ||
| them as the previous implementation did. | ||
| (Contributed by Ken Jin in :gh:`139109`. Support for Windows added by | ||
| Mark Shannon in :gh:`141703`.) | ||
| .. rubric:: Basic register allocation in the JIT | ||
| A basic form of register allocation has been added to the JIT compiler's | ||
| optimizer. This allows the JIT compiler to avoid certain stack operations | ||
| altogether and instead operate on registers. This allows the JIT to produce | ||
| more efficient traces by avoiding reads and writes to memory. | ||
| (Contributed by Mark Shannon in :gh:`135379`.) | ||
| .. rubric:: More JIT optimizations | ||
| More `constant-propagation <https://en.wikipedia.org/wiki/Constant_folding>`__ | ||
| is now performed. This means when the JIT compiler detects that certain user | ||
| code results in constants, the code can be simplified by the JIT. | ||
| (Contributed by Ken Jin and Savannah Ostrowski in :gh:`132732`.) | ||
| The JIT avoids :term:`reference count`\ s where possible. This generally | ||
| reduces the cost of most operations in Python. | ||
| (Contributed by Ken Jin, Donghee Na, Nadeshiko Manju, Savannah Ostrowski, | ||
savannahostrowski marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| Noam Cohen, Tomas Roun, PuQing in :gh:`134584`.) | ||
| .. rubric:: Better machine code generation | ||
| The JIT compiler's machine code generator now produces better machine code | ||
| for x86-64 and AArch64 macOS and Linux targets. In general, users should | ||
| experience lower memory usage for generated machine code and more efficient | ||
| machine code versus the old JIT. | ||
| (Contributed by Brandt Bucher in :gh:`136528` and :gh:`136528`. | ||
savannahostrowski marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| Implementation for AArch64 contributed by Mark Shannon in :gh:`139855`. | ||
| Additional optimizations for AArch64 contributed by Mark Shannon and | ||
| Diego Russo in :gh:`140683` and :gh:`142305`.) | ||
| Removed | ||
| ======= | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.