Skip to content

Regression in the AC generated code #91583

Description

@serhiy-storchaka

Argument Clinic now generates less efficient code using _PyArg_ParseStackAndKeywords instead of _PyArg_UnpackKeywords. It is a regression introduced after establishing module state. For example see #23393. It may be a cause of #91404.

@erlend-aasland

Activity

  1. erlend-aasland commented on Apr 15, 2022

    @erlend-aasland
    Contributor

    FYI GH-23393 is also in 3.10, not just 3.11 (seeing that GH-91404 has the title Possible slowdown of regex searching in 3.11)

  2. erlend-aasland commented on Apr 15, 2022

    @erlend-aasland
    Contributor

    Did you benchmark the difference?

  3. serhiy-storchaka commented on Apr 15, 2022

    @serhiy-storchaka
    MemberAuthor

    No, but _PyArg_ParseStackAndKeywords adds some overhead, and I do not see reason of not using more efficient code here. It seems that adding the implicit cls parameter broke some checks in Argument Clinic. These checks should ignore that parameter (as they ignore self), it does not affect the parsing code.

  4. erlend-aasland commented on Apr 15, 2022

    @erlend-aasland
    Contributor

    I do not see reason of not using more efficient code here

    +1

    It seems that adding the implicit cls parameter broke some checks in Argument Clinic. These checks should ignore that parameter (as they ignore self), it does not affect the parsing code.

    In sqlite3, for the sqlite3.Connection class, I store a pointer to the module state in the class context. A module state lookup in any of the connection methods is simply a class context member lookup. We could do a similar optimisation here.

  5. added a commit that references this issue on Apr 20, 2022
  6. serhiy-storchaka commented on Apr 20, 2022

    @serhiy-storchaka
    MemberAuthor

    METH_METHOD was introduced in 3.9, and Argument Clinic support was added at the same time.

  7. added 3 commits that reference this issue on Apr 30, 2022
  8. added 2 commits that reference this issue on May 3, 2022
  9. added a commit that references this issue on Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions