Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
795ef4940bf6c113188a9e63de39fba9d2d719267107542dd021fc44f886c43306696320b283b36554a592bba642e3ddc1aada1687b5c6553e9f7829a66605108ab7ffac8c74fd3bb4896b7bb2396818b57f417e2c603cc02f1fb4dc414a30ffc2dd2032b9c299a0688e0fb2195eee896936a38a274451f55129e71bd27be834c88cae8f1039bc819ff929372589eb0a2e92a6cbb3ad29910b655102ab6c0c14b47d4f8661981f50b879dab093578cd114944e50ff6554f6cd6e3f18e6608772f1872715460fb398d6f1dba8762c272c2242d76dc8587c0b7224cd7f98ae2e4cf38ef69960d6471798ab1681485f9bb03a84b26cded820e2200c81faba64a5bb00252e754b3b76045a67ec2971fd49e36755892a4dd0e16fd18c1a17d177418ebb6cbc23e591a62fe40e4f1624a7fcf24eb733782b5fe3a3385420cedd7af676faf8cdcce301a3f129e8fff007b2a8caabb17570fee4e9ccc7893eb970e0abecfd68aeabd56bd1541a53ca1dce66f3b57334554aab2dfab7527c7e7b2404a4a31f72e17385e177071e132f0bf175397ab76a886ab7f15f39672440ad039cc79994b4e857a5d918ed601256425fd511f8c3dfbdd21235f4f310b5a9b078adaf4de918cb2e9e2bb901c2d731d3aed17bfac26ac0711dda66058692a99284ee07b72368ed8e62fd192cc140af9ea573ed14020a1bad20498568d44ca1e2dbc29182ec8f1f526688c78a4e6aa92d84253f230ffa2b72897edf51ef4a370e92118c75d91cbf1ddaba64215dda5e7b783c85c36c77ee33fd3ab56429b2f5cfc7a9c5de275b7b3c23cda3dce3f212a44f29dd35af4b0a46c079a4aeb4abfe3a6a110fa14a0f978c43c80446aaf6873547f587a55d766278bbe6f5478807e2bc1dfa3e285251e19e08ec600f7c26d4ae1d6fe0658f1bf8a764ab72ab8b8993e6cfa45ae8308ccc033cf2873163d9b658fd98File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -57,9 +57,10 @@ jobs: | ||
| fail-fast: false | ||
| matrix: | ||
| target: | ||
| - i686-pc-windows-msvc/msvc | ||
| - x86_64-pc-windows-msvc/msvc | ||
| - aarch64-pc-windows-msvc/msvc | ||
| # To re-enable later when we support these. | ||
| # - i686-pc-windows-msvc/msvc | ||
| # - x86_64-pc-windows-msvc/msvc | ||
| # - aarch64-pc-windows-msvc/msvc | ||
Fidget-Spinner marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| - x86_64-apple-darwin/clang | ||
| - aarch64-apple-darwin/clang | ||
| - x86_64-unknown-linux-gnu/gcc | ||
| @@ -70,15 +71,16 @@ jobs: | ||
| llvm: | ||
| - 21 | ||
| include: | ||
| - target: i686-pc-windows-msvc/msvc | ||
| architecture: Win32 | ||
| runner: windows-2022 | ||
| - target: x86_64-pc-windows-msvc/msvc | ||
| architecture: x64 | ||
| runner: windows-2022 | ||
| - target: aarch64-pc-windows-msvc/msvc | ||
| architecture: ARM64 | ||
| runner: windows-11-arm | ||
| # To re-enable later when we support these. | ||
| # - target: i686-pc-windows-msvc/msvc | ||
| # architecture: Win32 | ||
| # runner: windows-2022 | ||
| # - target: x86_64-pc-windows-msvc/msvc | ||
| # architecture: x64 | ||
| # runner: windows-2022 | ||
| # - target: aarch64-pc-windows-msvc/msvc | ||
| # architecture: ARM64 | ||
| # runner: windows-11-arm | ||
| - target: x86_64-apple-darwin/clang | ||
| architecture: x86_64 | ||
| runner: macos-15-intel | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -95,11 +95,24 @@ backoff_counter_triggers(_Py_BackoffCounter counter) | ||
| return counter.value_and_backoff < UNREACHABLE_BACKOFF; | ||
| } | ||
| static inline _Py_BackoffCounter | ||
| trigger_backoff_counter(void) | ||
| { | ||
| _Py_BackoffCounter result; | ||
| result.value_and_backoff = 0; | ||
| return result; | ||
| } | ||
| // Initial JUMP_BACKWARD 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 | ||
| // Note: this should be a prime number-1. This increases the likelihood of | ||
Member 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. If this comment is true, then we should change the backoff counter to use a table lookup instead of using MemberAuthor 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. I manually verified it was true on the nqueens benchmark. it was the main reason why the perf used to be so bad for it. | ||
| // finding a "good" loop iteration to trace. | ||
| // For example, 4095 does not work for the nqueens benchmark on pyperformance | ||
| // 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 12 | ||
| static inline _Py_BackoffCounter | ||
| initial_jump_backoff_counter(void) | ||
| @@ -112,7 +125,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 | ||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -35,10 +35,18 @@ typedef struct _PyUOpInstruction{ | ||
| #endif | ||
| } _PyUOpInstruction; | ||
| // This is the length of the trace we project initially. | ||
| #define UOP_MAX_TRACE_LENGTH 1200 | ||
| // This is the length of the trace we translate initially. | ||
| #define UOP_MAX_TRACE_LENGTH 3000 | ||
Member 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. Based on what you said in the PR comment about seeing a lot of "trace too long" aborts even with the higher limit, I'm wondering if you've benchmarked even higher limits like 5k or 10k? MemberAuthor 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. Oops, the trace too long aborts are with the old limit (1200). I have not benchmarked the stats for the newer limit. We should definitely gather stats for this in the future and fine-tune it though | ||
| #define UOP_BUFFER_SIZE (UOP_MAX_TRACE_LENGTH * sizeof(_PyUOpInstruction)) | ||
| /* Bloom filter with m = 256 | ||
| * https://en.wikipedia.org/wiki/Bloom_filter */ | ||
| #define _Py_BLOOM_FILTER_WORDS 8 | ||
| typedef struct { | ||
| uint32_t bits[_Py_BLOOM_FILTER_WORDS]; | ||
| } _PyBloomFilter; | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly because I don't know the time horizon for getting this support, can we add a link in the comments to the issue where we're tracking this? I think it's #139922, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark says he will add normal switch-case support back to this PR by building on top of it I think. So we should get it nearly immediately after this lands.