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

enumerate() instantiation time reducing by using PEP 590 vectorcall #87872

Closed
corona10 opened this issue Apr 2, 2021 · 5 comments
Closed

enumerate() instantiation time reducing by using PEP 590 vectorcall #87872

corona10 opened this issue Apr 2, 2021 · 5 comments
Labels
3.11 only security fixes performance Performance or resource usage

Comments

@corona10
Copy link
Member

corona10 commented Apr 2, 2021

BPO 43706
Nosy @vstinner, @JelleZijlstra, @corona10, @tirkarthi, @Fidget-Spinner
PRs
  • bpo-43706: Use PEP 590 vectorcall to speed up enumerate() #25154
  • bpo-46527: allow calling enumerate(iterable=...) again #30904
  • Files
  • bench_enumerate.py
  • 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 = None
    closed_at = <Date 2021-10-21.23:23:14.271>
    created_at = <Date 2021-04-02.17:36:13.800>
    labels = ['3.11', 'performance']
    title = 'enumerate() instantiation time reducing by using PEP 590 vectorcall'
    updated_at = <Date 2022-01-26.03:39:17.414>
    user = 'https://github.com/corona10'

    bugs.python.org fields:

    activity = <Date 2022-01-26.03:39:17.414>
    actor = 'JelleZijlstra'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-21.23:23:14.271>
    closer = 'corona10'
    components = []
    creation = <Date 2021-04-02.17:36:13.800>
    creator = 'corona10'
    dependencies = []
    files = ['49929']
    hgrepos = []
    issue_num = 43706
    keywords = ['patch']
    message_count = 5.0
    messages = ['390083', '404705', '404706', '404707', '404717']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'JelleZijlstra', 'corona10', 'xtreak', 'kj']
    pr_nums = ['25154', '30904']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue43706'
    versions = ['Python 3.11']

    @corona10
    Copy link
    Member Author

    corona10 commented Apr 2, 2021

    Finally, I success to implement PEP-590 for enumerate type which is the well-used type in Python.

    Amazingly enhanced!

    +-----------------+------------------------+----------------------------+
    | Benchmark | enumerate_bench_master | enumerate_bench_vectorcall |
    +=================+========================+============================+
    | bench enumerate | 527 ns | 380 ns: 1.39x faster |
    +-----------------+------------------------+----------------------------+

    @corona10 corona10 added 3.10 only security fixes performance Performance or resource usage labels Apr 2, 2021
    @corona10
    Copy link
    Member Author

    See my last benchmark

    #25154 (comment)

    Same result in both Linux VM and Macbook pro.

    @corona10
    Copy link
    Member Author

    New changeset 83f202a by Dong-hee Na in branch 'main':
    bpo-43706: Use PEP-590 vectorcall to speed up enumerate() (GH-25154)
    83f202a

    @corona10
    Copy link
    Member Author

    Thanks Victor!

    @corona10 corona10 added 3.11 only security fixes and removed 3.10 only security fixes labels Oct 21, 2021
    @corona10
    Copy link
    Member Author

    @vstinner

    I noticed that the msg390083 was based on a non-optimized build.
    #25154 (comment) ran with the same build option condition.

    Here is the PGO + LTO based benchmark.
    Still fast.

    +-----------------+----------+----------------------+
    | Benchmark | base_opt | vectorcall_opt |
    +=================+==========+======================+
    | bench enumerate | 384 ns | 277 ns: 1.39x faster |
    +-----------------+----------+----------------------+

    @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

    1 participant