Repository navigation
Pluggable optimizer API #104584
Description
Activity
- addedperformancePerformance or resource usagePerformance or resource usage3.13only security fixesonly security fixes
on May 17, 2023 Note that the above API is just the initial version to support our work on speeding up Python 3.13.
It will probably need to be extended to support PyTorch Dynamo and other users of PEP 523 that cannot use PEP 669, but that is for another issue.Reacted by gouzil- added 4 commits that reference this issue
on Jun 27, 2023 9 remaining items
- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Nov 27, 2023 Is documenting these planned for 3.13?
Since we are removing them in 3.14, probably not.
Since we are removing them in 3.14, probably not.
If possible, I would like to backport #120643 to Python 3.13, to solve a C99 compatibility issue.
A bunch of PRs were merged; a quick glance at the PR list suggests that this issue can be closed as completed. Are there further work to be done?
We discussed the optimizer API offline. In short: we should rip the API itself out, and just keep all of the code that does that actual optimizing.
The API itself is constantly changing, poorly-defined, and undocumented. There's a bunch of infrastructure required just to test the API (not the actual optimizations we perform), and it introduces indirection and artificial boundaries into some pretty performance-sensitive stuff. Nobody it using it that we're aware of, nobody we've talked to is planning on using it, and frankly we don't want anyone to start using it. So let's remove it.
Reacted by Guido van RossumNitpick: I suggest opening a new issue to remove it.
- Reacted by Victor Stinner
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
PyExecutorObjectis that upon return from itsexecutefunction, the VM state will have advancedNinstructions. WhereNis 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->stacktopon optimizer error #108953ip_offsetand simplifyEXIT_TRACE#108961JUMP_BACKWARD#109347