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

Improve efficiency of PRECALL/CALL instructions #90690

Open
markshannon opened this issue Jan 26, 2022 · 4 comments
Open

Improve efficiency of PRECALL/CALL instructions #90690

markshannon opened this issue Jan 26, 2022 · 4 comments
Assignees
Labels
performance type-feature

Comments

@markshannon
Copy link
Member

@markshannon markshannon commented Jan 26, 2022

BPO 46532
Nosy @markshannon
PRs
  • #31231
  • 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 = None
    created_at = <Date 2022-01-26.09:44:42.979>
    labels = []
    title = 'Improve efficiency of PRECALL/CALL instructions'
    updated_at = <Date 2022-02-10.12:57:59.448>
    user = 'https://github.com/markshannon'

    bugs.python.org fields:

    activity = <Date 2022-02-10.12:57:59.448>
    actor = 'Mark.Shannon'
    assignee = 'Mark.Shannon'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2022-01-26.09:44:42.979>
    creator = 'Mark.Shannon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46532
    keywords = ['patch']
    message_count = 3.0
    messages = ['411721', '411723', '412996']
    nosy_count = 1.0
    nosy_names = ['Mark.Shannon']
    pr_nums = ['31231']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46532'
    versions = []

    @markshannon
    Copy link
    Member Author

    @markshannon markshannon commented Jan 26, 2022

    The PRECALL/CALL bytecode pair for calls is new (still in review at time of writing) and is not as efficient as it could be.

    Some possible improvements are:

    Transfer refcount of func when making a frame.

    NULL call_shape.kwnames after use instead of in PRECALL, as many specialized instructions already assert that it is NULL.

    Specialize the PRECALL instructions. Either for simple cases like type(arg) so we can skip the CALL, or for complex cases like PythonClass(args) where PRECALL can create object, and set up the frame so that CALL calls the init function.

    @markshannon
    Copy link
    Member Author

    @markshannon markshannon commented Jan 26, 2022

    Possibly consider replacing the specializations for str(arg) and tuple(arg) with a more general bytecode that can be used for other objects as well.

    @markshannon markshannon changed the title Improve effeciency of PRECALL/CALL instructions Improve efficiency of PRECALL/CALL instructions Feb 9, 2022
    @markshannon markshannon changed the title Improve effeciency of PRECALL/CALL instructions Improve efficiency of PRECALL/CALL instructions Feb 9, 2022
    @markshannon
    Copy link
    Member Author

    @markshannon markshannon commented Feb 10, 2022

    New changeset 2cea8c2 by Mark Shannon in branch 'main':
    bpo-46532: Reduce number of memory writes to update call_shape.kwnames. (GH-31231)
    2cea8c2

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @AlexWaygood AlexWaygood added type-feature performance labels Apr 10, 2022
    @markshannon
    Copy link
    Member Author

    @markshannon markshannon commented May 18, 2022

    As described here we can remove the PRECALL instruction entirely, shortening the call sequence for many calls.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    performance type-feature
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants