From 26cdf15311ab40af58975811dfec23a0951cd8ca Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Tue, 16 Dec 2025 14:00:18 -0800 Subject: [PATCH 01/12] Add What's New for 3.15 JIT --- Doc/whatsnew/3.15.rst | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 24a51f87c0f410..73a73dfa25b9d6 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -62,6 +62,8 @@ Summary -- Release highlights .. This section singles out the most important changes in Python 3.15. Brevity is key. +* The :ref:`JIT compiler ` has been significantly upgraded, + with 3-4% geometric mean performance improvement on pyperformance benchmarks. .. PEP-sized items next. @@ -850,6 +852,94 @@ csv (Contributed by Maurycy Pawłowski-Wieroński in :gh:`137628`.) +.. _whatsnew315-jit: + +Upgraded JIT Compiler +===================== + +The JIT compiler introduced in +`Python 3.13 `_ +has been significantly upgraded. + +Current results from the pyperformance benchmark suite report +`3-4% `_ +geometric mean performance over the standard CPython interpreter built with +all optimizations enabled. The speedups range from roughly 20% slowdown to +over 100% speedup (ignoring the unpack_sequence microbenchmark) on the +x86-64 Linux and AArch64 macOS systems. These results are not yet final. + +The major upgrades to the JIT are as follows: + +* LLVM 21 build-time dependency +* New tracing frontend +* Basic register allocation in the JIT +* More JIT optimizations +* Better machine code generation + +...watch this space for more to come before 3.15 beta! + +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 `_ for all supported +platforms. + +(Contributed by Savannah Ostrowski in :gh:`140973`.) + +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 :gh:`141703`.) + +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`.) + +More JIT Optimizations +---------------------- + +More `constant-propagation `_ +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, +Noam Cohen, Tomas Roun, PuQing in :gh:`134584`.) + +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`. +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 ======= From a851fe199255060fabdfd94bc3e68252fddfd893 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Tue, 16 Dec 2025 14:02:44 -0800 Subject: [PATCH 02/12] Fix formatting --- Doc/whatsnew/3.15.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 73a73dfa25b9d6..4368f5cb0d77f2 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -875,8 +875,7 @@ The major upgrades to the JIT are as follows: * Basic register allocation in the JIT * More JIT optimizations * Better machine code generation - -...watch this space for more to come before 3.15 beta! +* ...watch this space for more to come before 3.15 beta! LLVM 21 Build-Time Dependency ----------------------------- From cdeaf9938df9bcd2637112e07ad83878b6e3f143 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 22:07:58 +0000 Subject: [PATCH 03/12] Move section down --- Doc/whatsnew/3.15.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 4368f5cb0d77f2..7958d24ebfffb0 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -62,8 +62,6 @@ Summary -- Release highlights .. This section singles out the most important changes in Python 3.15. Brevity is key. -* The :ref:`JIT compiler ` has been significantly upgraded, - with 3-4% geometric mean performance improvement on pyperformance benchmarks. .. PEP-sized items next. @@ -76,6 +74,8 @@ Summary -- Release highlights * :pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object ` * :ref:`Improved error messages ` +* The :ref:`JIT compiler ` has been significantly upgraded, + with 3-4% geometric mean performance improvement on the pyperformance benchmarks. New features From ee162680ccb5456e8c7bf49b4346c1dbc5e18f87 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 22:20:14 +0000 Subject: [PATCH 04/12] add code formatting --- Doc/whatsnew/3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 7958d24ebfffb0..3377bbc41a5491 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -865,7 +865,7 @@ Current results from the pyperformance benchmark suite report `3-4% `_ geometric mean performance over the standard CPython interpreter built with all optimizations enabled. The speedups range from roughly 20% slowdown to -over 100% speedup (ignoring the unpack_sequence microbenchmark) on the +over 100% speedup (ignoring the ``unpack_sequence`` microbenchmark) on the x86-64 Linux and AArch64 macOS systems. These results are not yet final. The major upgrades to the JIT are as follows: From 52e35666fa867ced6112adcadd0d834258d7f142 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 22:55:18 +0000 Subject: [PATCH 05/12] Address Adam's review --- Doc/whatsnew/3.15.rst | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 3377bbc41a5491..ea728c2496e114 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -75,7 +75,8 @@ Summary -- Release highlights ` * :ref:`Improved error messages ` * The :ref:`JIT compiler ` has been significantly upgraded, - with 3-4% geometric mean performance improvement on the pyperformance benchmarks. + with 3-4% geometric mean performance improvement on the `pyperformance + `__ benchmarks. New features @@ -857,16 +858,15 @@ csv Upgraded JIT Compiler ===================== -The JIT compiler introduced in -`Python 3.13 `_ -has been significantly upgraded. - -Current results from the pyperformance benchmark suite report +Results from the pyperformance benchmark suite report `3-4% `_ -geometric mean performance over the standard CPython interpreter built with -all optimizations enabled. The speedups range from roughly 20% slowdown to -over 100% speedup (ignoring the ``unpack_sequence`` microbenchmark) on the -x86-64 Linux and AArch64 macOS systems. These results are not yet final. +geometric mean performance 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 as follows: @@ -875,7 +875,6 @@ The major upgrades to the JIT are as follows: * Basic register allocation in the JIT * More JIT optimizations * Better machine code generation -* ...watch this space for more to come before 3.15 beta! LLVM 21 Build-Time Dependency ----------------------------- From f133047dcab5e4fe01c5cdd68e8d517702a741f1 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 22:56:46 +0000 Subject: [PATCH 06/12] reformat --- Doc/whatsnew/3.15.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index ea728c2496e114..c58dc3414d9e4b 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -860,10 +860,11 @@ Upgraded JIT Compiler Results from the pyperformance benchmark suite report `3-4% `_ -geometric mean performance 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. +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. From 59f38a8b366531a1d4656284efc12a0d2167ed81 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 17 Dec 2025 00:29:07 +0000 Subject: [PATCH 07/12] use rubric instead of title --- Doc/whatsnew/3.15.rst | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index c58dc3414d9e4b..8f997149692715 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -877,8 +877,7 @@ The major upgrades to the JIT are as follows: * More JIT optimizations * Better machine code generation -LLVM 21 Build-Time Dependency ------------------------------ +.. 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; @@ -889,8 +888,7 @@ platforms. (Contributed by Savannah Ostrowski in :gh:`140973`.) -A New Tracing Frontend ----------------------- +.. 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 @@ -903,8 +901,7 @@ them as the previous implementation did. (Contributed by Ken Jin in :gh:`139109`. Support for Windows added by Mark Shannon :gh:`141703`.) -Basic Register Allocation in the JIT ------------------------------------- +.. 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 @@ -913,8 +910,7 @@ more efficient traces by avoiding reads and writes to memory. (Contributed by Mark Shannon in :gh:`135379`.) -More JIT Optimizations ----------------------- +.. rubric:: More JIT Optimizations More `constant-propagation `_ is now performed. This means when the JIT compiler detects that certain user @@ -926,8 +922,7 @@ reduces the cost of most operations in Python. (Contributed by Ken Jin, Donghee Na, Nadeshiko Manju, Savannah Ostrowski, Noam Cohen, Tomas Roun, PuQing in :gh:`134584`.) -Better Machine Code Generation ------------------------------- +.. 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 From b5bb5d929d0fc340bc03c73add3e10bbc2419f8e Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Tue, 16 Dec 2025 18:09:26 -0800 Subject: [PATCH 08/12] Update 3.15.rst Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Doc/whatsnew/3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 8f997149692715..748b95bb976c88 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -912,7 +912,7 @@ more efficient traces by avoiding reads and writes to memory. .. rubric:: More JIT Optimizations -More `constant-propagation `_ +More `constant-propagation `__ 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`.) From 4a0c773febb921c20abacfc44d5e750aa3b13ac0 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Tue, 16 Dec 2025 18:44:44 -0800 Subject: [PATCH 09/12] Apply suggestions from code review Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Doc/whatsnew/3.15.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 748b95bb976c88..1210c7117cfbf7 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -882,9 +882,8 @@ The major upgrades to the JIT are as follows: 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 `_ for all supported -platforms. +installing LLVM can be found in the JIT compiler documentation +(:file:`Tools/jit/README.md`) for all supported platforms. (Contributed by Savannah Ostrowski in :gh:`140973`.) @@ -915,10 +914,12 @@ more efficient traces by avoiding reads and writes to memory. More `constant-propagation `__ 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, Noam Cohen, Tomas Roun, PuQing in :gh:`134584`.) @@ -928,6 +929,7 @@ 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`. Implementation for AArch64 contributed by Mark Shannon in :gh:`139855`. Additional optimizations for AArch64 contributed by Mark Shannon and From d396a0e2264f7596ac97d4973d09dc3c4e5c0f7b Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 17 Dec 2025 11:13:49 +0000 Subject: [PATCH 10/12] Apply suggestions from Hugo's review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/whatsnew/3.15.rst | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 1210c7117cfbf7..c9a32340cedcae 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -75,8 +75,7 @@ Summary -- Release highlights ` * :ref:`Improved error messages ` * The :ref:`JIT compiler ` has been significantly upgraded, - with 3-4% geometric mean performance improvement on the `pyperformance - `__ benchmarks. + with 3-4% geometric mean performance improvement New features @@ -855,11 +854,12 @@ csv .. _whatsnew315-jit: -Upgraded JIT Compiler +Upgraded JIT compiler ===================== -Results from the pyperformance benchmark suite report -`3-4% `_ +Results from the `pyperformance + `__ benchmark suite report +`3-4% `__ 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 @@ -869,7 +869,7 @@ x86-64 Linux and AArch64 macOS systems. .. attention:: These results are not yet final. -The major upgrades to the JIT are as follows: +The major upgrades to the JIT are: * LLVM 21 build-time dependency * New tracing frontend @@ -877,17 +877,18 @@ The major upgrades to the JIT are as follows: * More JIT optimizations * Better machine code generation -.. rubric:: LLVM 21 Build-Time Dependency +.. 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 -(:file:`Tools/jit/README.md`) for all supported platforms. +installing LLVM can be found in the `JIT compiler documentation +`__ +for all supported platforms. (Contributed by Savannah Ostrowski in :gh:`140973`.) -.. rubric:: A New Tracing Frontend +.. 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 @@ -898,9 +899,9 @@ 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 :gh:`141703`.) +Mark Shannon in :gh:`141703`.) -.. rubric:: Basic Register Allocation in the JIT +.. 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 @@ -909,7 +910,7 @@ more efficient traces by avoiding reads and writes to memory. (Contributed by Mark Shannon in :gh:`135379`.) -.. rubric:: More JIT Optimizations +.. rubric:: More JIT optimizations More `constant-propagation `__ is now performed. This means when the JIT compiler detects that certain user @@ -923,7 +924,7 @@ reduces the cost of most operations in Python. (Contributed by Ken Jin, Donghee Na, Nadeshiko Manju, Savannah Ostrowski, Noam Cohen, Tomas Roun, PuQing in :gh:`134584`.) -.. rubric:: Better Machine Code Generation +.. 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 From d56dbdabe20e0b08d45bba906c46086f26fdf998 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 17 Dec 2025 11:19:13 +0000 Subject: [PATCH 11/12] Align style with rest of bullet points --- Doc/whatsnew/3.15.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index c9a32340cedcae..360c137cf4220b 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -74,8 +74,7 @@ Summary -- Release highlights * :pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object ` * :ref:`Improved error messages ` -* The :ref:`JIT compiler ` has been significantly upgraded, - with 3-4% geometric mean performance improvement +* :ref:`The JIT compiler has been significantly upgraded ` New features @@ -857,8 +856,8 @@ csv Upgraded JIT compiler ===================== -Results from the `pyperformance - `__ benchmark suite report +Results from the `pyperformance `__ +benchmark suite report `3-4% `__ geometric mean performance improvement for the JIT over the standard CPython interpreter built with all optimizations enabled. The speedups for JIT From bb76a0d83abf7b14ba35ce3f9cd89bda3d31cb8d Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Wed, 17 Dec 2025 20:09:06 +0800 Subject: [PATCH 12/12] Apply code review suggestions Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/whatsnew/3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 360c137cf4220b..53d613ffb3a471 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -73,8 +73,8 @@ Summary -- Release highlights ` * :pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object ` -* :ref:`Improved error messages ` * :ref:`The JIT compiler has been significantly upgraded ` +* :ref:`Improved error messages ` New features