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

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

Improve efficiency of PRECALL/CALL instructions #90690

markshannon opened this issue Jan 26, 2022 · 4 comments
Assignees
Labels
performance Performance or resource usage type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member

markshannon commented Jan 26, 2022

BPO 46532
Nosy @markshannon
PRs
  • bpo-46532: Reduce number of memory writes to update call_shape.kwnames. #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 = []

    Linked PRs

    @markshannon
    Copy link
    Member Author

    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

    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

    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 A feature request or enhancement performance Performance or resource usage labels Apr 10, 2022
    @markshannon
    Copy link
    Member Author

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

    hugovk added a commit that referenced this issue Sep 6, 2023
    Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 6, 2023
    …H-103910)
    
    (cherry picked from commit f9bd6e4)
    
    Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
    Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    Yhg1s pushed a commit that referenced this issue Sep 8, 2023
    ) (#109027)
    
    GH-90690: Mention removal of ``PRECALL`` in What's New (GH-103910)
    (cherry picked from commit f9bd6e4)
    
    Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
    Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    performance Performance or resource usage type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants