Skip to content
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

Split up the CALL_NO_KW and CALL_KW instructions. #90487

Closed
markshannon opened this issue Jan 10, 2022 · 7 comments
Closed

Split up the CALL_NO_KW and CALL_KW instructions. #90487

markshannon opened this issue Jan 10, 2022 · 7 comments
Assignees
Labels
3.11 only security fixes performance Performance or resource usage

Comments

@markshannon
Copy link
Member

BPO 46329
Nosy @markshannon, @pablogsal, @brandtbucher, @Fidget-Spinner
PRs
  • bpo-46329: Split calls into precall and call instructions. #30855
  • bpo-46329: Fix refleak in specialized isinstance error path #31005
  • Revert "bpo-46329: Split calls into precall and call instructions." #31011
  • bpo-46329: Reduce default recursion to 800 if Py_DEBUG is enabled. #31033
  • bpo-46329: Change calling sequence (again) #31373
  • bpo-46329: Streamline calling sequence a bit. #31465
  • bpo-46329: Move call specializations from CALL to PRECALL. #31496
  • bpo-46329: Fix test failure when Py_STATS is enabled #31511
  • bpo-46329: Avoid PUSH_NULL when followed by LOAD_GLOBAL #31933
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/markshannon'
    closed_at = <Date 2022-03-17.16:15:27.117>
    created_at = <Date 2022-01-10.12:54:45.748>
    labels = ['3.11', 'performance']
    title = 'Split up the CALL_NO_KW and CALL_KW instructions.'
    updated_at = <Date 2022-03-17.16:15:27.116>
    user = 'https://github.com/markshannon'

    bugs.python.org fields:

    activity = <Date 2022-03-17.16:15:27.116>
    actor = 'Mark.Shannon'
    assignee = 'Mark.Shannon'
    closed = True
    closed_date = <Date 2022-03-17.16:15:27.117>
    closer = 'Mark.Shannon'
    components = []
    creation = <Date 2022-01-10.12:54:45.748>
    creator = 'Mark.Shannon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46329
    keywords = ['patch']
    message_count = 7.0
    messages = ['410209', '411992', '412034', '412089', '413495', '413666', '413783']
    nosy_count = 4.0
    nosy_names = ['Mark.Shannon', 'pablogsal', 'brandtbucher', 'kj']
    pr_nums = ['30855', '31005', '31011', '31033', '31373', '31465', '31496', '31511', '31933']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue46329'
    versions = ['Python 3.11']

    @markshannon
    Copy link
    Member Author

    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 faster-cpython/ideas#210 for more rationale.

    @markshannon markshannon added the 3.11 only security fixes label Jan 10, 2022
    @markshannon markshannon self-assigned this Jan 10, 2022
    @markshannon markshannon added performance Performance or resource usage 3.11 only security fixes labels Jan 10, 2022
    @markshannon markshannon self-assigned this Jan 10, 2022
    @markshannon markshannon added the performance Performance or resource usage label Jan 10, 2022
    @markshannon
    Copy link
    Member Author

    New changeset 89fd7c3 by Mark Shannon in branch 'main':
    bpo-46329: Split calls into precall and call instructions. (GH-30855)
    89fd7c3

    @pablogsal
    Copy link
    Member

    Seems that this PR is causing some segfaults. See #30855 (comment)

    @pablogsal
    Copy link
    Member

    I'm reverting PR30855 for the time being given our buildbot policy.

    @markshannon
    Copy link
    Member Author

    New changeset cf345e9 by Mark Shannon in branch 'main':
    bpo-46329: Change calling sequence (again) (GH-31373)
    cf345e9

    @markshannon
    Copy link
    Member Author

    New changeset 59585d6 by Mark Shannon in branch 'main':
    bpo-46329: Streamline calling sequence a bit. (GH-31465)
    59585d6

    @markshannon
    Copy link
    Member Author

    New changeset 424023e by Brandt Bucher in branch 'main':
    bpo-46329: Fix test failure when Py_STATS is enabled (GH-31511)
    424023e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants