Title: Pluggable optimizer API · Issue #104584 · python/cpython · GitHub
Open Graph Title: Pluggable optimizer API · Issue #104584 · python/cpython
X Title: Pluggable optimizer API · Issue #104584 · python/cpython
Description: 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 hot...
Open Graph Description: 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 ...
X Description: 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 ...
Opengraph URL: https://github.com/python/cpython/issues/104584
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pluggable optimizer API","articleBody":"We need an API for optimizers to be plugged in to CPython.\r\n\r\nThe proposed model is that of client server, where the VM is the client and the optimizer is the server.\r\nThe optimizer registers with the VM, then VM calls the optimizer when hotspots are detected.\r\n\r\nThe API:\r\n\r\n```C\r\ntype struct {\r\n OBJECT_HEADER;\r\n _PyInterpreterFrame *(*execute)(PyExecutorObject *self, _PyInterpreterFrame *frame, PyObject **stack_pointer);\r\n /* Data needed by the executor goes here, but is opaque to the VM */\r\n} PyExecutorObject;\r\n\r\n/* This would be nicer as an enum, but C doesn't define the size of enums */\r\n#define PY_OPTIMIZE_FUNCTION_ENTRY 1\r\n#define PY_OPTIMIZE_RESUME_AFTER_YIELD 2\r\n#define PY_OPTIMIZE_BACK_EDGE 4\r\ntypedef uint32_t PyOptimizerCapabilities;\r\n\r\ntype struct {\r\n OBJECT_HEADER;\r\n PyExecutorObject *(*compile)(PyOptimizerObject* self, PyCodeObject *code, int offset);\r\n PyOptimizerCapabilities capabilities;\r\n float optimization_cost;\r\n float run_cost;\r\n /* Data needed by the compiler goes here, but is opaque to the VM */\r\n} PyOptimizerObject;\r\n\r\nvoid _Py_Executor_Replace(PyCodeObject *code, int offset, PyExecutorObject *executor);\r\n\r\nint _Py_Optimizer_Register(PyOptimizerObject* optimizer);\r\n```\r\n\r\nThe semantics of a `PyExecutorObject` is that upon return from its `execute` function, the VM state will have advanced `N` instructions. Where `N` is a non-negative integer.\r\n\r\nFull discussion here: https://github.com/faster-cpython/ideas/discussions/380\r\n\r\nThis is not a replacement for PEP 523. That will need a PEP. We should get this working first, before we consider replacing PEP 523.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105100\n* gh-105244\n* gh-105683\n* gh-105924\n* gh-106126\n* gh-106131\n* gh-106141\n* gh-106146\n* gh-106163\n* gh-106171\n* gh-106277\n* gh-106393\n* gh-106484\n* gh-106489\n* gh-106492\n* gh-106497\n* gh-106500\n* gh-106526\n* gh-106641\n* gh-106908\n* gh-107513\n* gh-108953\n* gh-108961\n* gh-109347\n* gh-110593\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/markshannon","@type":"Person","name":"markshannon"},"datePublished":"2023-05-17T14:50:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/104584/cpython/issues/104584"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:17c73533-0de4-9845-cd3f-bab8730be7e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFF6:236F3C:1FDBFF6:2BA49DB:696AC504 |
| html-safe-nonce | 6ec0d5f0bbc273313fb2a448ee1f08b25f4f37a62d3b01a4a3fb82826282ac8a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkY2OjIzNkYzQzoxRkRCRkY2OjJCQTQ5REI6Njk2QUM1MDQiLCJ2aXNpdG9yX2lkIjoiNTE1NTIzNDA0NzI2ODE0NDM4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f062220698a3dd8ea3f3b9a07e6a5ed7373234c164b081459386886c03196028 |
| hovercard-subject-tag | issue:1714087345 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/104584/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f55c70b36614b4503a6fcc54e5e520aadad6a3fadd2dcc6691065d47e0b16ac9/python/cpython/issues/104584 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f55c70b36614b4503a6fcc54e5e520aadad6a3fadd2dcc6691065d47e0b16ac9/python/cpython/issues/104584 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markshannon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 986b6a1d774985095564e64d6963d11f094da3d0e2bfda2ab1a27d63662eb033 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 89ad2112b9c4e11df6a0c13c8c1f8eedd36b0977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width