-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-139109: A new tracing JIT compiler frontend for CPython #140310
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
Open
Fidget-Spinner
wants to merge
119
commits into
python:main
Choose a base branch
from
Fidget-Spinner:tracing_jit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
795ef49
Basic trace recording
Fidget-Spinner 40bf6c1
WIP generators
Fidget-Spinner 13188a9
refactor to translate on the go
Fidget-Spinner e63de39
working python startup
Fidget-Spinner fba9d2d
fix a bug with specializzation
Fidget-Spinner 7192671
Fully working bm_generators
Fidget-Spinner 07542dd
fix jit build
Fidget-Spinner 021fc44
Fix exception tracing
Fidget-Spinner f886c43
Fix jump tracing
Fidget-Spinner 3066963
Fix handling of ENTER_EXECUTOR
Fidget-Spinner 20b283b
Fix ENTER_EXECUTOR bug
Fidget-Spinner 36554a5
Fix over-tracing bug
Fidget-Spinner 92bba64
fix JIT + debug builds
Fidget-Spinner 2e3ddc1
Fix double-initialization
Fidget-Spinner aada168
fix exception bug
Fidget-Spinner 7b5c655
Fix dispatch_inlined
Fidget-Spinner 3e9f782
Fix handling of EXTENDED_ARG
Fidget-Spinner 9a66605
Fix chain depth bug
Fidget-Spinner 108ab7f
remove printf
Fidget-Spinner fac8c74
fix problem with jumping labels
Fidget-Spinner fd3bb48
Point to previous executor when side-exiting
Fidget-Spinner 96b7bb2
Fix progress needed and warmup
Fidget-Spinner 396818b
Fix unsupported opcode bug, turn off optimizer again
Fidget-Spinner 57f417e
fix branch tracing
Fidget-Spinner 2c603cc
fix branch prediction for real
Fidget-Spinner 02f1fb4
fix non-sstandard C
Fidget-Spinner dc414a3
Track from JUMP_BACKWARD rather than FOR_ITER
Fidget-Spinner 0ffc2dd
Fix bug where code/func get freed halfway
Fidget-Spinner 2032b9c
add back replaced, move jit tracing env var to
Fidget-Spinner 299a068
Handle recursive tracing and CALL_ALLOC_AND_ENTER_INIT
Fidget-Spinner 8e0fb21
Fix recursive tracing and dynamic exits
Fidget-Spinner 95eee89
Fix handling of EXTENDED_ARG
Fidget-Spinner 6936a38
Just punt on large opargs for now
Fidget-Spinner a274451
cleanup a little
Fidget-Spinner f55129e
fix recursive tracing
Fidget-Spinner 71bd27b
comment out debugging
Fidget-Spinner e834c88
Delete out.txt
Fidget-Spinner cae8f10
patch the graphviz dump
Fidget-Spinner 39bc819
fix bug with predicted stuff
Fidget-Spinner ff92937
Properly record the predicted ops
Fidget-Spinner 2589eb0
Re-enable the optimizer
Fidget-Spinner a2e92a6
Delete hello.gvz
Fidget-Spinner cbb3ad2
turn off optimizer again (for now)
Fidget-Spinner 9910b65
Turn off optimizer for real, trace through init
Fidget-Spinner 5102ab6
fix a few tests and their exposed bugs
Fidget-Spinner c0c14b4
Restore the optimizer fully
Fidget-Spinner 7d4f866
invalidate freed code/function objects used for global promotion
Fidget-Spinner 1981f50
Fix tracing
Fidget-Spinner b879dab
fix tracing completely
Fidget-Spinner 093578c
Separate the tracer out into its own file
Fidget-Spinner d114944
Cleanup, bugfixes to sys trace
Fidget-Spinner e50ff65
Whole test suite passing
Fidget-Spinner 54f6cd6
Remove unused buffer
Fidget-Spinner e3f18e6
Cleanup warnings
Fidget-Spinner 608772f
refactor a little
Fidget-Spinner 1872715
Cleanup
Fidget-Spinner 460fb39
📜🤖 Added by blurb_it.
blurb-it[bot] 8d6f1db
Merge remote-tracking branch 'upstream/main' into tracing_jit
Fidget-Spinner a8762c2
Disable windows CI for now, simplify
Fidget-Spinner 72c2242
restore non-jit builds
Fidget-Spinner d76dc85
make mypy happy
Fidget-Spinner 87c0b72
fix linter and mypy?
Fidget-Spinner 24cd7f9
more cleanup to fix CI
Fidget-Spinner 8ae2e4c
Merge remote-tracking branch 'upstream/main' into tracing_jit
Fidget-Spinner f38ef69
Fix lltrace on jit debug builds
Fidget-Spinner 960d647
Turn off tracing on dynamic exit
Fidget-Spinner 1798ab1
Fix _CHECK_PERIODIC insertion
Fidget-Spinner 681485f
Increase uop length to compensate
Fidget-Spinner 9bb03a8
Handle EXTENDED_ARG
Fidget-Spinner 4b26cde
Handle unstable branches
Fidget-Spinner d820e22
Don't JIT short traces except if they end in a loop
Fidget-Spinner 00c81fa
revert last 2 changes
Fidget-Spinner ba64a5b
Support BINARY_OP_INPLACE_ADD_UNICODE
Fidget-Spinner b00252e
Trace through BINARY_OP_SUBSCR_GETITEM
Fidget-Spinner 754b3b7
Close loops
Fidget-Spinner 6045a67
Specialize on deopt when tracing
Fidget-Spinner ec2971f
make mypy happy
Fidget-Spinner d49e367
remedies against trace explosion
Fidget-Spinner 55892a4
lint
Fidget-Spinner dd0e16f
Fix a bug with where the executors get inserted during EXTENDED_ARG
Fidget-Spinner d18c1a1
Revert remedies against trace explosion
Fidget-Spinner 7d17741
First half of reviews
Fidget-Spinner 8ebb6cb
Fix naming of things
Fidget-Spinner c23e591
restore optimizer code
Fidget-Spinner a62fe40
Clean up macros
Fidget-Spinner e4f1624
Clean up the cases generator
Fidget-Spinner a7fcf24
Close loops properly, don't trace into nested loops
Fidget-Spinner eb73378
fix test
Fidget-Spinner 2b5fe3a
debug changes
Fidget-Spinner 3385420
add comment to CI
Fidget-Spinner cedd7af
Rewrite the tracing JIT to use a common opcode handler
Fidget-Spinner 676faf8
Fix ifdefs
Fidget-Spinner cdcce30
Address review of macros
Fidget-Spinner 1a3f129
fix a tracing bug, ifdef out code
Fidget-Spinner e8fff00
fix JIT builds
Fidget-Spinner 7b2a8ca
regen frozenmain
Fidget-Spinner abb1757
fix build on non-JIT
Fidget-Spinner 0fee4e9
fix pystats jit build
Fidget-Spinner ccc7893
Merge remote-tracking branch 'upstream/main' into tracing_jit
Fidget-Spinner eb970e0
specialization and deopt fixes
Fidget-Spinner abecfd6
fix test
Fidget-Spinner 8aeabd5
disable tracing on FT
Fidget-Spinner 6bd1541
Fix FT
Fidget-Spinner a53ca1d
Emit RECORD_DYNAMIC_JUMP_TAKEN automatically
Fidget-Spinner ce66f3b
Remove TIER2_STORE_IP
Fidget-Spinner 5733455
make mypy happy
Fidget-Spinner 4aab2df
Move specializing ddetection to specialize inst
Fidget-Spinner ab7527c
Fix the counters
Fidget-Spinner 7e7b240
fix windows builds
Fidget-Spinner 4a4a31f
Support underflow and yield value in the optimizer
Fidget-Spinner 72e1738
fix
Fidget-Spinner 5e17707
Fix a bug with ENTER_EXECUTOR linking
Fidget-Spinner 1e132f0
up the trace length
Fidget-Spinner bf17539
Change the backoffs to fix nqueens
Fidget-Spinner 7ab76a8
fix no-opt JIT
Fidget-Spinner 86ab7f1
Fix a test
Fidget-Spinner 5f39672
fix up gitattributes
Fidget-Spinner 440ad03
address review
Fidget-Spinner 9cc7999
Address Chris' review
Fidget-Spinner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -99,8 +99,13 @@ backoff_counter_triggers(_Py_BackoffCounter counter) | |||||
| // Must be larger than ADAPTIVE_COOLDOWN_VALUE, otherwise when JIT code is | ||||||
| // invalidated we may construct a new trace before the bytecode has properly | ||||||
| // re-specialized: | ||||||
| #define JUMP_BACKWARD_INITIAL_VALUE 4095 | ||||||
| #define JUMP_BACKWARD_INITIAL_BACKOFF 12 | ||||||
| // Note: this should be a prime number-1. This increases the likelihood of | ||||||
| // finding a "good" loop iteration to trace. | ||||||
| // For example, 4095 does not work for the nqueens benchmark on pyperformanc | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // as we always end up tracing the loop iteration's | ||||||
| // exhaustion iteration. Which aborts our current tracer. | ||||||
| #define JUMP_BACKWARD_INITIAL_VALUE 4000 | ||||||
| #define JUMP_BACKWARD_INITIAL_BACKOFF 14 | ||||||
| static inline _Py_BackoffCounter | ||||||
| initial_jump_backoff_counter(void) | ||||||
| { | ||||||
|
|
@@ -112,7 +117,7 @@ initial_jump_backoff_counter(void) | |||||
| * Must be larger than ADAPTIVE_COOLDOWN_VALUE, | ||||||
| * otherwise when a side exit warms up we may construct | ||||||
| * a new trace before the Tier 1 code has properly re-specialized. */ | ||||||
| #define SIDE_EXIT_INITIAL_VALUE 4095 | ||||||
| #define SIDE_EXIT_INITIAL_VALUE 4000 | ||||||
| #define SIDE_EXIT_INITIAL_BACKOFF 12 | ||||||
|
|
||||||
| static inline _Py_BackoffCounter | ||||||
|
|
@@ -129,6 +134,14 @@ initial_unreachable_backoff_counter(void) | |||||
| return make_backoff_counter(0, UNREACHABLE_BACKOFF); | ||||||
| } | ||||||
|
|
||||||
| // Required to not get stuck in infinite specialization loops due to specialization failure. | ||||||
| // We use 2 here as there are a few scenarios: | ||||||
| // 1. Freshly specialized from unspecialized, in which case the counter will be 1. | ||||||
| // 2. Re-specialized from deopt, in which case the counter will be 1. | ||||||
| // 3. Deopt -> Specialize -> Deopt -> Specialize, in which case the counter will be 2. | ||||||
| // We do not want the 3rd case. | ||||||
| #define MAX_SPECIALIZATION_TRIES 2 | ||||||
|
|
||||||
| #ifdef __cplusplus | ||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.
Oops, something went wrong.
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.