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
Pluggable optimizer API #104584
Labels
3.13
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
Comments
markshannon
added
performance
Performance or resource usage
3.13
new features, bugs and security fixes
labels
May 17, 2023
Note that the above API is just the initial version to support our work on speeding up Python 3.13. |
markshannon
added a commit
that referenced
this issue
Jun 2, 2023
markshannon
added a commit
that referenced
this issue
Jun 5, 2023
markshannon
added a commit
that referenced
this issue
Jun 19, 2023
* Add test for long loops * Clear ENTER_EXECUTOR when deopting code objects.
gvanrossum
added a commit
that referenced
this issue
Jun 27, 2023
Added a new, experimental, tracing optimizer and interpreter (a.k.a. "tier 2"). This currently pessimizes, so don't use yet -- this is infrastructure so we can experiment with optimizing passes. To enable it, pass ``-Xuops`` or set ``PYTHONUOPS=1``. To get debug output, set ``PYTHONUOPSDEBUG=N`` where ``N`` is a debug level (0-4, where 0 is no debug output and 4 is excessively verbose). All of this code is likely to change dramatically before the 3.13 feature freeze. But this is a first step.
This was referenced Jun 27, 2023
Closed
gvanrossum
added a commit
that referenced
this issue
Jun 27, 2023
gvanrossum
added a commit
that referenced
this issue
Jun 27, 2023
This was referenced Jun 27, 2023
gvanrossum
added a commit
that referenced
this issue
Jun 27, 2023
This effectively reverts bb578a0, restoring the original DEOPT_IF() macro in ceval_macros.h, and redefining it in the Tier 2 interpreter. We can get rid of the PREDICTED() macros there as well!
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 28, 2023
test_counter_optimizer() and test_long_loop() of test_capi now create a new function at each call. Otherwise, the optimizer counters are not the expected values when the test is run more than once.
vstinner
added a commit
that referenced
this issue
Jun 28, 2023
…6171) test_counter_optimizer() and test_long_loop() of test_capi now create a new function at each call. Otherwise, the optimizer counters are not the expected values when the test is run more than once.
gvanrossum
added a commit
that referenced
this issue
Jun 28, 2023
This produces longer traces (superblocks?). Also improved debug output (uop names are now printed instead of numeric opcodes). This would be simpler if the numeric opcode values were generated by generate_cases.py, but that's another project. Refactored some code in generate_cases.py so the essential algorithm for cache effects is only run once. (Deciding which effects are used and what the total cache size is, regardless of what's used.)
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Jun 30, 2023
vstinner
added a commit
that referenced
this issue
Jun 30, 2023
markshannon
added a commit
that referenced
this issue
Jul 3, 2023
* Check eval-breaker in ENTER_EXECUTOR. * Make sure that frame->prev_instr is set before entering executor.
This was referenced Jul 4, 2023
gvanrossum
added a commit
that referenced
this issue
Jul 6, 2023
When `_PyOptimizer_BackEdge` returns `NULL`, we should restore `next_instr` (and `stack_pointer`). To accomplish this we should jump to `resume_with_error` instead of just `error`. The problem this causes is subtle -- the only repro I have is in PR gh-106393, at commit d7df54b. But the fix is real (as shown later in that PR). While we're at it, also improve the debug output: the offsets at which traces are identified are now measured in bytes, and always show the start offset. This makes it easier to correlate executor calls with optimizer calls, and either with `dis` output. <!-- gh-issue-number: gh-104584 --> * Issue: gh-104584 <!-- /gh-issue-number -->
This was referenced Jul 6, 2023
gvanrossum
added a commit
that referenced
this issue
Jul 6, 2023
The uops test wasn't testing anything by default, and was failing when run with -Xuops. Made the two executor-related context managers global, so TestUops can use them (notably `with temporary_optimizer(opt)`). Made clear_executor() a little more thorough. Fixed a crash upon finalizing a uop optimizer, by adding a `tp_dealloc` handler.
gvanrossum
added a commit
to gvanrossum/cpython
that referenced
this issue
Jul 6, 2023
…6492) The uops test wasn't testing anything by default, and was failing when run with -Xuops. Made the two executor-related context managers global, so TestUops can use them (notably `with temporary_optimizer(opt)`). Made clear_executor() a little more thorough. Fixed a crash upon finalizing a uop optimizer, by adding a `tp_dealloc` handler.
gvanrossum
added a commit
that referenced
this issue
Jul 6, 2023
gvanrossum
added a commit
that referenced
this issue
Jul 7, 2023
Instead of special-casing specific instructions, we add a few more special values to the 'size' field of expansions, so in the future we can automatically handle additional super-instructions in the generator.
gvanrossum
added a commit
that referenced
this issue
Jul 7, 2023
This adds several of unspecialized opcodes to superblocks: TO_BOOL, BINARY_SUBSCR, STORE_SUBSCR, UNPACK_SEQUENCE, LOAD_GLOBAL, LOAD_ATTR, COMPARE_OP, BINARY_OP. While we may not want that eventually, for now this helps finding bugs. There is a rudimentary test checking for UNPACK_SEQUENCE. Once we're ready to undo this, that would be simple: just replace the call to variable_used_unspecialized with a call to variable_used (as shown in a comment). Or add individual opcdes to FORBIDDEN_NAMES_IN_UOPS.
gvanrossum
added a commit
that referenced
this issue
Jul 7, 2023
11 tasks
iritkatriel
added a commit
that referenced
this issue
Jul 11, 2023
brandtbucher
added a commit
that referenced
this issue
Jul 20, 2023
brandtbucher
added a commit
that referenced
this issue
Jul 31, 2023
2 tasks
This was referenced Sep 5, 2023
brandtbucher
added a commit
that referenced
this issue
Sep 6, 2023
brandtbucher
added a commit
that referenced
this issue
Sep 13, 2023
brandtbucher
added a commit
that referenced
this issue
Oct 10, 2023
iritkatriel
added
the
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
label
Nov 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.13
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
We need an API for optimizers to be plugged in to CPython.
The proposed model is that of client server, where the VM is the client and the optimizer is the server.
The optimizer registers with the VM, then VM calls the optimizer when hotspots are detected.
The API:
The semantics of a
PyExecutorObject
is that upon return from itsexecute
function, the VM state will have advancedN
instructions. WhereN
is a non-negative integer.Full discussion here: faster-cpython/ideas#380
This is not a replacement for PEP 523. That will need a PEP. We should get this working first, before we consider replacing PEP 523.
Linked PRs
ENTER_EXECUTOR
#106141-Xuops
#106908frame->stacktop
on optimizer error #108953ip_offset
and simplifyEXIT_TRACE
#108961JUMP_BACKWARD
#109347The text was updated successfully, but these errors were encountered: