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

Regression in the AC generated code #91583

Closed
serhiy-storchaka opened this issue Apr 15, 2022 · 5 comments · Fixed by #91739
Closed

Regression in the AC generated code #91583

serhiy-storchaka opened this issue Apr 15, 2022 · 5 comments · Fixed by #91739
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes performance Performance or resource usage topic-argument-clinic

Comments

@serhiy-storchaka
Copy link
Member

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

@serhiy-storchaka serhiy-storchaka added performance Performance or resource usage 3.11 only security fixes topic-argument-clinic labels Apr 15, 2022
@erlend-aasland
Copy link
Contributor

erlend-aasland commented Apr 15, 2022

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)

@erlend-aasland
Copy link
Contributor

Did you benchmark the difference?

@serhiy-storchaka
Copy link
Member Author

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.

@erlend-aasland
Copy link
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.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 20, 2022
Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
@serhiy-storchaka serhiy-storchaka added 3.10 only security fixes 3.9 only security fixes labels Apr 20, 2022
@serhiy-storchaka
Copy link
Member Author

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

serhiy-storchaka added a commit that referenced this issue Apr 30, 2022
)

Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 30, 2022
…_class (pythonGH-91739)

Argument Clinic now generates the same efficient code as before
adding the defining_class parameter..
(cherry picked from commit a055dac)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 30, 2022
…class (pythonGH-91739)

Argument Clinic now generates the same efficient code as before
adding the defining_class parameter..
(cherry picked from commit a055dac)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue May 3, 2022
…GH-91739) (GH-92079)

Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
(cherry picked from commit a055dac)
serhiy-storchaka added a commit that referenced this issue May 3, 2022
…H-91739) (GH-92080)

Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
(cherry picked from commit a055dac)
hello-adam pushed a commit to hello-adam/cpython that referenced this issue Jun 2, 2022
…class (pythonGH-91739) (pythonGH-92080)

Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
(cherry picked from commit a055dac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes performance Performance or resource usage topic-argument-clinic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants