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

gh-116381: Specialize CONTAINS_OP #116385

Merged
merged 5 commits into from
Mar 6, 2024

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Mar 5, 2024

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG (it's all just boilerplate :-) but I am curious about whether it makes any difference in perf. It doesn't strike me as all that common an operation, and I also don't think that we gain much here (just the dispatch via the type object, which for most of these ops isn't all that much compared to the actual work that the data type has to do to compute the result).

@Fidget-Spinner Fidget-Spinner merged commit 7114cf2 into python:main Mar 6, 2024
52 checks passed
@Fidget-Spinner Fidget-Spinner deleted the specialize_contains_op branch March 6, 2024 19:30
@Fidget-Spinner Fidget-Spinner restored the specialize_contains_op branch March 6, 2024 19:35
@gvanrossum
Copy link
Member

@Fidget-Spinner Sadly I forgot to check for warnings. On macOS I now get the following warnings:

In file included from Python/optimizer_analysis.c:380:
Python/optimizer_cases.c.h:1133:29: warning: variable 'right' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *right;
                            ^
Python/optimizer_cases.c.h:1134:29: warning: variable 'left' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *left;
                            ^
Python/optimizer_cases.c.h:1150:29: warning: variable 'right' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *right;
                            ^
Python/optimizer_cases.c.h:1151:29: warning: variable 'left' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *left;
                            ^
Python/optimizer_cases.c.h:1162:29: warning: variable 'right' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *right;
                            ^
Python/optimizer_cases.c.h:1163:29: warning: variable 'left' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *left;
                            ^
Python/optimizer_cases.c.h:1174:29: warning: variable 'right' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *right;
                            ^
Python/optimizer_cases.c.h:1175:29: warning: variable 'left' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *left;
                            ^
Python/optimizer_cases.c.h:1186:29: warning: variable 'right' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *right;
                            ^
Python/optimizer_cases.c.h:1187:29: warning: variable 'left' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *left;
                            ^
Python/optimizer_cases.c.h:1198:29: warning: variable 'right' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *right;
                            ^
Python/optimizer_cases.c.h:1199:29: warning: variable 'left' set but not used [-Wunused-but-set-variable]
            _Py_UopsSymbol *left;
                            ^

I suspect that the fix is to rename the args of those specialized ops to unused.

@markshannon
Copy link
Member

markshannon commented Mar 7, 2024

This consumes quite a few tier 1 bytecodes, which is quite a limited resource.
What is the advantage of this PR?
I see no advantage in terms of performance for either tier 1 or tier 2.

We really shouldn't be merging performance PR without a solid justification. It doesn't have to be a clear improvement on pyperformance, but there must be some quantifiable improvement.

@Fidget-Spinner
Copy link
Member Author

This consumes quite a few tier 1 bytecodes, which is quite a limited resource. What is the advantage of this PR? I see no advantage in terms of performance for either tier 1 or tier 2.

We really shouldn't be merging performance PR without a solid justification. It doesn't have to be a clear improvement on pyperformance, but there must be some quantifiable improvement.

It helps propagate more information to tier 2.

@Fidget-Spinner
Copy link
Member Author

Also you listed it in your TODO list. Unless you had in mind something with fewer specializations?

@markshannon
Copy link
Member

Yes, I did. faster-cpython/ideas#660.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
* Specialize CONTAINS_OP

* 📜🤖 Added by blurb_it.

* Add PyAPI_FUNC for JIT

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
* Specialize CONTAINS_OP

* 📜🤖 Added by blurb_it.

* Add PyAPI_FUNC for JIT

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specialize CONTAINS_OP
3 participants