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

Update property_descr_set to use vectorcall if possible. #88827

Closed
corona10 opened this issue Jul 17, 2021 · 6 comments
Closed

Update property_descr_set to use vectorcall if possible. #88827

corona10 opened this issue Jul 17, 2021 · 6 comments
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@corona10
Copy link
Member

BPO 44661
Nosy @vstinner, @corona10, @pablogsal, @erlend-aasland, @Fidget-Spinner
PRs
  • bpo-44661: Update property_descr_set to use vectorcall if possible. #27206
  • Files
  • bench_property.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-07-19.10:14:43.448>
    created_at = <Date 2021-07-17.05:19:43.450>
    labels = ['interpreter-core', '3.11', 'performance']
    title = 'Update property_descr_set to use vectorcall if possible.'
    updated_at = <Date 2021-08-04.15:40:50.400>
    user = 'https://github.com/corona10'

    bugs.python.org fields:

    activity = <Date 2021-08-04.15:40:50.400>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-19.10:14:43.448>
    closer = 'corona10'
    components = ['Interpreter Core']
    creation = <Date 2021-07-17.05:19:43.450>
    creator = 'corona10'
    dependencies = []
    files = ['50155']
    hgrepos = []
    issue_num = 44661
    keywords = ['patch']
    message_count = 6.0
    messages = ['397701', '397702', '397703', '397783', '397784', '398907']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'corona10', 'pablogsal', 'erlendaasland', 'kj']
    pr_nums = ['27206']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue44661'
    versions = ['Python 3.11']

    @corona10
    Copy link
    Member Author

    It shows a consistent 1-2% performance improvement.

    Mean +- std dev: [property_base] 40.6 ns +- 0.6 ns -> [property_vectorcall] 40.0 ns +- 0.7 ns: 1.01x faster

    @corona10 corona10 added 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Jul 17, 2021
    @corona10
    Copy link
    Member Author

    Oops sorry, it was the wrong benchmark, it will be faster.. ;)

    Mean +- std dev: [property_base] 140 ns +- 5 ns -> [property_vectorcall] 125 ns +- 2 ns: 1.12x faster

    @corona10
    Copy link
    Member Author

    I updated the benchmark, and it shows 1.12x faster

    @corona10
    Copy link
    Member Author

    New changeset 635bfe8 by Dong-hee Na in branch 'main':
    bpo-44661: Update property_descr_set to use vectorcall if possible. (GH-27206)
    635bfe8

    @corona10
    Copy link
    Member Author

    class Person:
        def __init__(self):
            self.__age = 0
    
        @property
        def age(self):
            return self.__age
    
        @age.setter
        def age(self, value):
            self.__age = value
    
    p = Person()
    p.age = 10 # Now become faster

    @vstinner
    Copy link
    Member

    vstinner commented Aug 4, 2021

    Mean +- std dev: [property_base] 140 ns +- 5 ns -> [property_vectorcall] 125 ns +- 2 ns: 1.12x faster

    Ah! That's better. If it was only 1.01x faster, I would say that it's not worth it. But 1.12x is worth it. Thanks for this optimization.

    @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 interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants