Skip to content

Faster code for trial quotient in x_divrem #90662

Description

@tim-one
BPO 46504
Nosy @tim-one, @gpshead, @mdickinson
PRs
  • bpo-46504: faster code for trial quotient in x_divrem() #30856
  • 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/tim-one'
    closed_at = <Date 2022-01-25.01:07:14.086>
    created_at = <Date 2022-01-24.18:46:28.769>
    labels = ['interpreter-core', '3.11', 'performance']
    title = 'Faster code for trial quotient in x_divrem'
    updated_at = <Date 2022-01-25.01:07:14.086>
    user = 'https://github.com/tim-one'

    bugs.python.org fields:

    activity = <Date 2022-01-25.01:07:14.086>
    actor = 'tim.peters'
    assignee = 'tim.peters'
    closed = True
    closed_date = <Date 2022-01-25.01:07:14.086>
    closer = 'tim.peters'
    components = ['Interpreter Core']
    creation = <Date 2022-01-24.18:46:28.769>
    creator = 'tim.peters'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46504
    keywords = ['patch']
    message_count = 2.0
    messages = ['411505', '411542']
    nosy_count = 3.0
    nosy_names = ['tim.peters', 'gregory.p.smith', 'mark.dickinson']
    pr_nums = ['30856']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue46504'
    versions = ['Python 3.11']

    Activity

    1. tim-one commented on Jan 24, 2022

      @tim-one
      MemberAuthor

      x_divrem1() was recently (bpo-46406) changed to generate faster code for division, essentially nudging optimizing compilers into recognizing that modern processors compute the quotient and remainder with a single machine instruction.

      The same can be done for x_divrem(), although it's less valuable there because the HW division generally accounts for a much smaller percent of its total runtime.

      Still, it does cut a multiply and subtract out of the loop, and makes the code more obvious (since it brings x_divrem1() and x_divrem() back into synch).

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      performancePerformance or resource usage
      3.11only security fixes
      on Jan 24, 2022
    3. tim-one commented on Jan 25, 2022

      @tim-one
      MemberAuthor

      New changeset 7c26472 by Tim Peters in branch 'main':
      bpo-46504: faster code for trial quotient in x_divrem() (GH-30856)
      7c26472

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions