This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Split up the CALL_NO_KW and CALL_KW instructions.
Type: performance Stage: resolved
Components: Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon, brandtbucher, kj, pablogsal
Priority: normal Keywords: patch

Created on 2022-01-10 12:54 by Mark.Shannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30855 merged Mark.Shannon, 2022-01-24 16:59
PR 31005 merged kj, 2022-01-29 07:25
PR 31011 closed pablogsal, 2022-01-29 17:57
PR 31033 closed Mark.Shannon, 2022-01-31 13:52
PR 31373 merged Mark.Shannon, 2022-02-16 13:10
PR 31465 merged Mark.Shannon, 2022-02-21 10:45
PR 31496 merged Mark.Shannon, 2022-02-22 10:21
PR 31511 merged brandtbucher, 2022-02-22 22:06
PR 31933 merged Mark.Shannon, 2022-03-16 13:58
Messages (7)
msg410209 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-01-10 12:54
Most calls (not those with *args and/or **kwargs) are compiled to the `CALL_NO_KW` and `CALL_KW` instructions, possibly with a `PRECALL_METHOD` prefix.

We want to unify the `CALL_NO_KW` and `CALL_KW` instructions into a single `CALL` instruction and add two new instructions: `PRECALL_FUNCTION` and `KW_NAMES`.
All call sequences would start with `PRECALL_FUNCTION` or `PRECALL_METHOD`. `PRECALL_METHOD` would continue to pair with `LOAD_METHOD` as it does now. `PRECALL_FUNCTION` would effectively be a no-op, but would be needed to set up internal interpreter variables.

`CALL_NO_KW` would become `CALL` and `CALL_KW` would become `KW_NAMES; CALL`.

Why?

Specializing calls is an important optimization, but calls are complicated and we want to specialized for both the type of the callable and the shape of the call.

By breaking up calls in this way, we can specialize for the type and for the shape mostly independently.
We can specialize for classes, bound-methods and other objects that ultimately call a Python function in the `PRECALL` instruction and specialize for the shape of the arguments in the `CALL` instruction.


See https://github.com/faster-cpython/ideas/discussions/210 for more rationale.
msg411992 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-01-28 12:42
New changeset 89fd7c34520aac493a8784a221366ed04452612b by Mark Shannon in branch 'main':
bpo-46329: Split calls into precall and call instructions. (GH-30855)
https://github.com/python/cpython/commit/89fd7c34520aac493a8784a221366ed04452612b
msg412034 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-01-28 21:33
Seems that this PR is causing some segfaults. See https://github.com/python/cpython/pull/30855#issuecomment-1024658459
msg412089 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-01-29 17:58
I'm reverting PR30855 for the time being given our buildbot policy.
msg413495 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-18 17:19
New changeset cf345e945f48f54785799390c2e92c5310847bd4 by Mark Shannon in branch 'main':
bpo-46329: Change calling sequence (again) (GH-31373)
https://github.com/python/cpython/commit/cf345e945f48f54785799390c2e92c5310847bd4
msg413666 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-21 18:26
New changeset 59585d6b2ea50d7bc3a9b336da5bde61367f527c by Mark Shannon in branch 'main':
bpo-46329: Streamline calling sequence a bit. (GH-31465)
https://github.com/python/cpython/commit/59585d6b2ea50d7bc3a9b336da5bde61367f527c
msg413783 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-23 11:01
New changeset 424023efee5b21567b4725015ef143b627112e3c by Brandt Bucher in branch 'main':
bpo-46329: Fix test failure when `Py_STATS` is enabled (GH-31511)
https://github.com/python/cpython/commit/424023efee5b21567b4725015ef143b627112e3c
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90487
2022-03-17 16:15:27Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-16 13:58:33Mark.Shannonsetpull_requests: + pull_request30025
2022-02-23 11:01:07Mark.Shannonsetmessages: + msg413783
2022-02-22 22:06:33brandtbuchersetpull_requests: + pull_request29638
2022-02-22 10:21:34Mark.Shannonsetpull_requests: + pull_request29626
2022-02-21 18:26:56Mark.Shannonsetmessages: + msg413666
2022-02-21 10:45:57Mark.Shannonsetpull_requests: + pull_request29595
2022-02-18 17:19:21Mark.Shannonsetmessages: + msg413495
2022-02-16 13:10:35Mark.Shannonsetpull_requests: + pull_request29523
2022-01-31 13:52:26Mark.Shannonsetpull_requests: + pull_request29216
2022-01-29 17:58:57pablogsalsetmessages: + msg412089
2022-01-29 17:58:49pablogsalsetmessages: - msg412088
2022-01-29 17:58:31pablogsalsetmessages: + msg412088
2022-01-29 17:57:37pablogsalsetpull_requests: + pull_request29190
2022-01-29 07:25:21kjsetpull_requests: + pull_request29186
2022-01-28 21:33:53pablogsalsetnosy: + pablogsal
messages: + msg412034
2022-01-28 12:42:34Mark.Shannonsetmessages: + msg411992
2022-01-24 16:59:53Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29036
2022-01-10 21:50:32brandtbuchersetnosy: + brandtbucher
2022-01-10 12:54:45Mark.Shannoncreate