Skip to content

Commit 88dcc94

Browse files
PEP 836: Clarify that only the frontend is changing (#5023)
1 parent f2baf02 commit 88dcc94

1 file changed

Lines changed: 24 additions & 17 deletions

File tree

peps/pep-0836.rst

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ At a high level, these are our milestones and goals for the JIT over the next
6161
first implementation should be minimal, may initially use more memory or
6262
perform slightly worse, and may be rolled back to the current tracing
6363
frontend if the approach does not meet the project's goals in the first
64-
year.
64+
year. The rest of the JIT (intermediate representation,
65+
middle-end/optimizer, and Copy and Patch backend), remain almost
66+
completely unchanged from CPython 3.15. **In other words, only what
67+
the JIT selects to compile is evolving from traces to methods,
68+
nothing else is changing from CPython 3.15.**.
6569

6670
* :ref:`Make the JIT compatible with free-threading <836-free-threading>`. We
6771
believe that this is important to prioritize early on in the next phase of
@@ -400,20 +404,21 @@ method frontend are as follows:
400404
* To enable higher-level optimizations more easily, without requiring a higher
401405
JIT tier (which requires another JIT bolted on top) or inter-trace knowledge.
402406

403-
The following is the reference design. It is subject to change as the code
404-
evolves:
405-
406-
* **Uop IR.** The benefits for this are explained in previous sections.
407-
* **Some Single Static Assignment (SSA) form properties over the stack.** This
408-
does not mean we need to rewrite our IR to SSA form, but rather, the
409-
optimizer should have some SSA properties. We believe this aligns more
410-
closely with other compilers (e.g. Cinder, PyPy, Chrome's V8, CRuby's
411-
YJIT/ZJIT), and makes understanding *how* to optimize in the JIT easier and
412-
more powerful. The current JIT optimizer already nearly supports this, and
413-
only requires minimal changes to have SSA properties. An IR with proper stack
414-
discipline already has many useful properties that are analogous to SSA form.
415-
SSA form will basically come for free for stack variables.
416-
* **A simple way to represent high-level constructs.** We have an
407+
The following is the reference design for the evolved frontend.
408+
It is subject to change as the code evolves:
409+
410+
* **Compile one or more methods at a time.** This is self-explanatory in the
411+
name.
412+
* **Some Single Static Assignment (SSA) form properties over the stack.**
413+
The current CPython 3.15 JIT optimizer already nearly supports this, and
414+
only requires minimal changes to have SSA properties. The CPython 3.15
415+
Uop IR also already has many useful properties that are analogous to SSA form.
416+
We want to introduce a few more SSA properties to the Uop IR.
417+
We believe this aligns more closely with other compilers
418+
(e.g. Cinder, PyPy, Chrome's V8, CRuby's YJIT/ZJIT), and makes understanding
419+
*how* to optimize in the JIT easier and more powerful.
420+
* **A simple way to represent high-level constructs.** To represent
421+
high-level control-flow in the method frontend, we have an
417422
implementation that forms *regions* (groups of basic blocks), inspired by the
418423
similarly named concept in MLIR (an LLVM project). Rather than degenerating
419424
programs to single basic blocks pointing to each other, we opt to keep the
@@ -422,6 +427,8 @@ evolves:
422427
better generator/coroutine/loop/etc. (high-level construct) analysis and
423428
optimizations.
424429

430+
**In other words, apart from growing support for analyzing methods,
431+
nothing has changed from CPython 3.15.**
425432
With all of the above, most optimizations in the JIT can be implemented as
426433
local rewrites. This is again, inspired by certain properties of other
427434
runtimes' intermediate representations. Our goal is to make the JIT more
@@ -561,8 +568,8 @@ pyperformance. For example:
561568
when it detects that objects are uniquely referenced. This is a source of
562569
slowdown on architectures where atomics are more expensive.
563570

564-
**We believe that the right framing here is not the JIT *or* free-threading,
565-
but rather, the JIT *and* free-threading**. We understand the JIT may initially
571+
**We believe that the right framing here is not the JIT or free-threading,
572+
but rather, the JIT and free-threading**. We understand the JIT may initially
566573
lose some performance opportunities from free-threading's semantics. However,
567574
both the JIT and free-threading have much to gain. The JIT can recover all of
568575
free-threading's single-threaded performance losses and maybe even more.

0 commit comments

Comments
 (0)