Skip to content

Specialize COMPARE_OP #90043

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
sweeneyde opened this issue Nov 23, 2021 · 5 comments
Closed

Specialize COMPARE_OP #90043

sweeneyde opened this issue Nov 23, 2021 · 5 comments
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@sweeneyde
Copy link
Member

sweeneyde commented Nov 23, 2021

BPO 45885
Nosy @markshannon, @brandtbucher, @sweeneyde
PRs
  • bpo-45885: Specialize COMPARE_OP #29734
  • bpo-45885: Add more stats for COMPARE_OP in specialize.c #31040
  • bpo-45885: Don't un-adapt COMPARE_OP when collecting stats #31516
  • 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-12-03.23:45:56.141>
    created_at = <Date 2021-11-23.21:00:24.137>
    labels = ['interpreter-core', '3.11', 'performance']
    title = 'Specialize COMPARE_OP'
    updated_at = <Date 2022-02-23.11:06:35.684>
    user = 'https://github.com/sweeneyde'

    bugs.python.org fields:

    activity = <Date 2022-02-23.11:06:35.684>
    actor = 'Mark.Shannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-03.23:45:56.141>
    closer = 'Dennis Sweeney'
    components = ['Interpreter Core']
    creation = <Date 2021-11-23.21:00:24.137>
    creator = 'Dennis Sweeney'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45885
    keywords = ['patch']
    message_count = 5.0
    messages = ['406887', '406930', '407577', '412441', '413784']
    nosy_count = 3.0
    nosy_names = ['Mark.Shannon', 'brandtbucher', 'Dennis Sweeney']
    pr_nums = ['29734', '31040', '31516']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue45885'
    versions = ['Python 3.11']

    Linked PRs

    @sweeneyde
    Copy link
    Member Author

    Some specialization statistics:

    https://gist.github.com/sweeneyde/49cc3a9d074d56cf095cb0a42d13d7a4

    Including 3 opcodes: COMPARE_OP_INT and COMPARE_OP_FLOAT and COMPARE_OP_STR (equality only) seems to give pretty good specialization numbers, better than just 2.

    @sweeneyde sweeneyde added 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Nov 23, 2021
    @markshannon
    Copy link
    Member

    Is COMPARE_OP worth specializing by itself?

    Most comparisons are followed by a jump, and much of the overhead is in the branching around the choice of operator as well as pushing and popping (with inc/decrefs) a value that has only one bit of information (True/False).

    @markshannon
    Copy link
    Member

    New changeset 03768c4 by Dennis Sweeney in branch 'main':
    bpo-45885: Specialize COMPARE_OP (GH-29734)
    03768c4

    @markshannon
    Copy link
    Member

    New changeset 674ab66 by Dennis Sweeney in branch 'main':
    bpo-45885: Add more stats for COMPARE_OP in specialize.c (GH-31040)
    674ab66

    @markshannon
    Copy link
    Member

    New changeset 375a56b by Brandt Bucher in branch 'main':
    bpo-45885: Don't un-adapt COMPARE_OP when collecting stats (GH-31516)
    375a56b

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    carljm added a commit to carljm/cpython that referenced this issue Dec 16, 2022
    * main:
      pythongh-99540: Constant hash for _PyNone_Type to aid reproducibility (pythonGH-99541)
      pythongh-100039: enhance __signature__ to work with str and callables (pythonGH-100168)
      pythongh-99830: asyncio: Document returns of remove_{reader,writer} (python#100302)
      "Compound statement" docs: Fix with-statement step indexing (python#100286)
      pythonGH-90043: Handle NaNs in COMPARE_OP_FLOAT_JUMP (pythonGH-100278)
    shihai1991 added a commit to shihai1991/cpython that referenced this issue Dec 18, 2022
    * origin/main: (1306 commits)
      Correct CVE-2020-10735 documentation (python#100306)
      pythongh-100272: Fix JSON serialization of OrderedDict (pythonGH-100273)
      pythongh-93649: Split tracemalloc tests from _testcapimodule.c (python#99551)
      Docs: Use `PY_VERSION_HEX` for version comparison (python#100179)
      pythongh-97909: Fix markup for `PyMethodDef` members (python#100089)
      pythongh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (python#99890)
      pythongh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (python#99890)
      pythonGH-98831: Add DECREF_INPUTS(), expanding to DECREF() each stack input (python#100205)
      pythongh-78707: deprecate passing >1 argument to `PurePath.[is_]relative_to()` (pythonGH-94469)
      pythongh-99540: Constant hash for _PyNone_Type to aid reproducibility (pythonGH-99541)
      pythongh-100039: enhance __signature__ to work with str and callables (pythonGH-100168)
      pythongh-99830: asyncio: Document returns of remove_{reader,writer} (python#100302)
      "Compound statement" docs: Fix with-statement step indexing (python#100286)
      pythonGH-90043: Handle NaNs in COMPARE_OP_FLOAT_JUMP (pythonGH-100278)
      Improve stats presentation for calls. (pythonGH-100274)
      Better stats for `LOAD_ATTR` and `STORE_ATTR` (pythonGH-100295)
      pythongh-81057: Move the Cached Parser Dummy Name to _PyRuntimeState (python#100277)
      Document that zipfile's pwd parameter is a `bytes` object (python#100209)
      pythongh-99767: mark `PyTypeObject.tp_watched` as internal use only in table (python#100271)
      Fix typo in introduction.rst (python#100266)
      ...
    # for free to join this conversation on GitHub. Already have an account? # 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