Commit graph

53 commits

Author SHA1 Message Date
Mark Shannon
b420f6be53
GH-139109: Support switch/case dispatch with the tracing interpreter. (GH-141703) 2025-11-18 13:31:48 +00:00
Ken Jin
4fa80ce74c
gh-139109: A new tracing JIT compiler frontend for CPython (GH-140310)
This PR changes the current JIT model from trace projection to trace recording. Benchmarking: better pyperformance (about 1.7% overall) geomean versus current https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251108-3.15.0a1%2B-7e2bc1d-JIT/bm-20251108-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-7e2bc1d-vs-base.svg, 100% faster Richards on the most improved benchmark versus the current JIT. Slowdown of about 10-15% on the worst benchmark versus the current JIT. **Note: the fastest version isn't the one merged, as it relies on fixing bugs in the specializing interpreter, which is left to another PR**. The speedup in the merged version is about 1.1%. https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251112-3.15.0a1%2B-f8a764a-JIT/bm-20251112-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-f8a764a-vs-base.svg

Stats: 50% more uops executed, 30% more traces entered the last time we ran them. It also suggests our trace lengths for a real trace recording JIT are too short, as a lot of trace too long aborts https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251023-3.15.0a1%2B-eb73378-CLANG%2CJIT/bm-20251023-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-eb73378-pystats-vs-base.md .

This new JIT frontend is already able to record/execute significantly more instructions than the previous JIT frontend. In this PR, we are now able to record through custom dunders, simple object creation, generators, etc. None of these were done by the old JIT frontend. Some custom dunders uops were discovered to be broken as part of this work gh-140277

The optimizer stack space check is disabled, as it's no longer valid to deal with underflow.

Pros:
* Ignoring the generated tracer code as it's automatically created, this is only additional 1k lines of code. The maintenance burden is handled by the DSL and code generator.
* `optimizer.c` is now significantly simpler, as we don't have to do strange things to recover the bytecode from a trace.
* The new JIT frontend is able to handle a lot more control-flow than the old one.
* Tracing is very low overhead. We use the tail calling interpreter/computed goto interpreter to switch between tracing mode and non-tracing mode. I call this mechanism dual dispatch, as we have two dispatch tables dispatching to each other. Specialization is still enabled while tracing.
* Better handling of polymorphism. We leverage the specializing interpreter for this.

Cons:
* (For now) requires tail calling interpreter or computed gotos. This means no Windows JIT for now :(. Not to fret, tail calling is coming soon to Windows though https://github.com/python/cpython/pull/139962

Design:
* After each instruction, the `record_previous_inst` function/label is executed. This does as the name suggests.
* The tracing interpreter lowers bytecode to uops directly so that it can obtain "fresh" values at the point of lowering.
* The tracing version behaves nearly identical to the normal interpreter, in fact it even has specialization! This allows it to run without much of a slowdown when tracing. The actual cost of tracing is only a function call and writes to memory.
* The tracing interpreter uses the specializing interpreter's deopt to naturally form the side exit chains. This allows it to side exit chain effectively, without repeating much code. We force a re-specializing when tracing a deopt.
* The tracing interpreter can even handle goto errors/exceptions, but I chose to disable them for now as it's not tested.
* Because we do not share interpreter dispatch, there is should be no significant slowdown to the original specializing interpreter on tailcall and computed got with JIT disabled. With JIT enabled, there might be a slowdown in the form of the JIT trying to trace.
* Things that could have dynamic instruction pointer effects are guarded on. The guard deopts to a new instruction --- `_DYNAMIC_EXIT`.
2025-11-13 18:08:32 +00:00
Savannah Ostrowski
d162c42790
GH-140479: Update JIT builds to use LLVM 21 (#140973) 2025-11-12 18:09:25 +00:00
Ken Jin
947bb4642c
gh-140889: Bump tailcall and JIT CI to llvm 20 (#140963) 2025-11-03 12:37:29 -08:00
Ken Jin
9791a506c2
gh-140889: Test tailcall and JIT in CI (GH-140891) 2025-11-03 19:07:55 +00:00
Savannah Ostrowski
4e2ff4ac4c
GH-136895: Update JIT builds to use LLVM 20 (#140329)
Co-authored-by: Emma Harper Smith <emma@emmatyping.dev>
2025-11-03 10:01:44 -08:00
Jacob Coffee
1ae9250364
gh-137638: Use macos-15-intel in GitHub Actions (#139154)
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-03 19:49:03 +00:00
Donghee Na
c4f21d7c7c
gh-133171: Re-enable JUMP_BACKWARD to free-threading build (gh-137800) 2025-09-24 14:19:17 +09:00
Donghee Na
8247e1b3e7
gh-137838: Add CI for no-opt JIT (#139081)
* gh-137838: Add CI for no-opt JIT

* nit
2025-09-18 11:46:03 +01:00
Hugo van Kemenade
6e78a539bf
gh-138744: GitHub Actions: pin to windows-2022 (#138743) 2025-09-10 17:28:27 +03:00
Brandt Bucher
d591b5effb
GH-134291: Support older macOS deployment targets for JIT builds (GH-137211) 2025-07-30 15:48:18 -07:00
Ken Jin
b3308973e3
gh-136183: Deal with escapes in JIT optimizer's constant evaluator (GH-136184) 2025-07-02 14:08:25 +08:00
Brandt Bucher
bfcbb28223
GH-113464: Get LLVM from cpython-bin-deps on Windows (GH-133278) 2025-05-02 11:17:15 -07:00
Brandt Bucher
2da48e32f6
GH-133171: Prevent combinations of --disable-gil and --enable-experimental-jit... for now (GH-133179) 2025-05-02 09:26:03 -07:00
Savannah Ostrowski
26c0248b54
GH-114809: Add support for macOS multi-arch builds with the JIT enabled (#131751)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2025-04-30 11:03:57 -07:00
Hugo van Kemenade
10a77619f9
Use Windows ARM64 hosted runners (#132546)
Co-authored-by: Diego Russo <diego.russo@arm.com>
2025-04-16 16:27:20 +03:00
Diego Russo
0dbaeb94a8
Enable Windows on Arm GitHub runners (#131994) 2025-04-03 22:32:29 +02:00
Adam Turner
fda056e64b
gh-130604: Always run all matrix workflows in GitHub Actions (#130603) 2025-02-26 21:44:48 +00:00
Adam Turner
d0a1e5c222
GH-103180: Set a timeout for every job in GitHub Actions (#130375) 2025-02-21 17:11:26 +02:00
Diego Russo
fb17f41522
Revert "Use ubuntu-22.04-arm image for Arm runners. (#129834)" (#130305)
GitHub discovered it was an issue with the underlying hardware
and have migrated all the runners to a different arm sku (dpdsv5).

This reverts commit 80b9e79d84.
2025-02-19 17:06:11 +01:00
Diego Russo
80b9e79d84
Use ubuntu-22.04-arm image for Arm runners. (#129834)
GitHub suggested us to try the 22.04 images for the Arm runners while
they are invetigating the failures we've been having using 24.04.
2025-02-08 08:56:19 +02:00
Hugo van Kemenade
298dda5770
Add colour to GitHub Actions output (#129196) 2025-01-22 21:22:21 +00:00
Diego Russo
6c914bf85c
Move to public Linux arm64 hosted runners (#128964)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-01-20 18:51:09 +02:00
Hugo van Kemenade
ae31df354d
Add zizmor to pre-commit and fix most findings (#127749)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-12-10 12:51:12 +02:00
Diego Russo
7c5a6f67c7
Enable native AArch64 Ubuntu CI jobs (#127584)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2024-12-04 14:12:06 -08:00
Filipe Laíns 🇵🇸
2950bc50af
GH-127429: fix sysconfig data generation on cross-builds (#127430) 2024-12-02 07:12:36 +00:00
Savannah Ostrowski
2247dd0f11
GH-127154: Remove PGO and unknown-linux-gnu/clang from JIT CI (#127212) 2024-11-27 14:36:36 -08:00
alm
09d6f5dc78
GH-126464 Fix JIT CI on aarch64-apple-darwin (GH-126494) 2024-11-07 10:55:31 -08:00
Brandt Bucher
a204c63919
GH-126464: Temporarily disable aarch64-apple-darwin JIT CI jobs (gh-126465)
* Temporarily disable aarch64-apple-darwin JIT CI jobs

* Also up here
2024-11-06 12:09:04 +09:00
Savannah Ostrowski
c84a136511
gh-125560: Pin JIT CI to ubuntu-22.04 (#125564) 2024-11-01 23:43:30 +02:00
Savannah Ostrowski
c29bbe2101
GH-125498: Update JIT builds to use LLVM 19 and preserve_none (GH-125499) 2024-10-30 12:03:31 -07:00
Savannah Ostrowski
b6471f4a39
GH-124408: Temporarily skip test_strftime_y2k for emulated Linux JIT CI (GH-124466) 2024-09-24 18:09:50 -07:00
Savannah Ostrowski
b4d0d7de0f
GH-124398: Pin LLVM to 18.1.0 for Windows JIT CI (GH-124399) 2024-09-24 10:03:16 -07:00
Savannah Ostrowski
fd0f814ade
Add --with-lto back to Linux JIT CI (GH-120921) 2024-06-24 13:16:22 -07:00
Brandt Bucher
b48a3dbff4
GH-113464: Run the JIT interpreter before any other JIT CI (GH-119466) 2024-05-24 03:13:41 +00:00
Savannah Ostrowski
c4722cd057
GH-119292: Add job to JIT CI to build and test with --disable-gil (GH-119293)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-21 11:00:52 -04:00
Savannah Ostrowski
5307f44fb9
GH-119146: Don't run JIT CI on unrelated changes (GH-119147)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-05-19 12:59:12 +00:00
Brandt Bucher
430945db4c
GH-118251: Bump the JIT CI timeout to 90 minutes (#118661) 2024-05-07 01:21:39 +02:00
Brandt Bucher
139dc487b5
GH-118251: Fix incomplete ternary expression in JIT workflow (GH-118564) 2024-05-03 16:10:02 -07:00
Savannah Ostrowski
5248596781
GH-118251: Skip fewer test in emulated JIT CI (GH-118536) 2024-05-03 19:07:10 +00:00
Savannah Ostrowski
8b56d82c59
GH-118306: Update JIT to use LLVM 18 (GH-118307) 2024-04-29 21:09:16 +00:00
Savannah Ostrowski
8942bf41da
GH-118246: Exclude test_pathlib and test_posixpath from emulated JIT CI (GH-118247) 2024-04-24 21:43:50 +00:00
Nikita Sobolev
fc21c7f7a7
Set proper permissions for jit.yml workflow (#118084) 2024-04-23 00:31:01 +03:00
Brandt Bucher
18cf239e39
Increase the JIT CI timeouts to 75 minutes (GH-117342) 2024-03-28 21:02:34 +00:00
Erlend E. Aasland
43c9d6196a
CI: Pass environment variables directly to configure in JIT CI (#116156)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-03-18 10:49:45 +01:00
Brandt Bucher
ffed8d985b
GH-116134: JIT aarch64-pc-windows-msvc (GH-116130) 2024-03-04 10:16:56 -08:00
Erlend E. Aasland
4d1d35b906
gh-116075: Skip test_external_inspection on qemu in JIT CI (#116076) 2024-02-28 23:16:01 +00:00
Guido van Rossum
c0fdfba7ff
Rename tier 2 redundancy eliminator to optimizer (#115888)
The original name is just too much of a mouthful.
2024-02-26 08:42:53 -08:00
Ken Jin
ed23839dc5
Trigger JIT CI with optimizer files (#115483)
* Trigger JIT CI with optimizer files
2024-02-15 14:01:24 +08:00
Nikita Sobolev
1aec064444
GH-114849: Set a 60-minute timeout for JIT CI jobs (GH-114850) 2024-02-01 17:44:01 -08:00