Skip to content

Conversation

@Fidget-Spinner
Copy link
Member

@Fidget-SpinnerFidget-Spinner commented Mar 7, 2024

Partially reverts some of the bad specializations in #116385. Stats for what are "bad" are from https://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20240307-3.13.0a4%2B-72dbea2.

@Fidget-SpinnerFidget-Spinner changed the title Remove bad specializations, add fail statsgh-116381: Remove bad specializations, add fail statsMar 7, 2024
@bedevere-appbedevere-appbot mentioned this pull request Mar 7, 2024
Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

The stats gathering needs tidying up a bit, but LGTM otherwise

goto success;
}

#ifdef Py_STATS
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this into its own function, like load_attr_fail_kind, then this becomes SPECIALIZATION_FAIL(CONTAINS_OP, contains_fail_kind(value))


#ifdef Py_STATS
if (PyUnicode_CheckExact(value)){
SPECIALIZATION_FAIL(TO_BOOL, SPEC_FAIL_CONTAINS_OP_STR);
Copy link
Member

Choose a reason for hiding this comment

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

TO_BOOL -> CONTAINS_OP and a few more times below

inst(CONTAINS_OP_STR, (unused/1, left, right -- b)){
DEOPT_IF(!PyUnicode_CheckExact(right));
int res = PyUnicode_Contains(right, left);
inst(CONTAINS_OP_MAPPINGPROXY, (unused/1, left, right -- b)){
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised that this is worthwhile.
OOI, what are the numbers for this?

Copy link
MemberAuthor

@Fidget-SpinnerFidget-SpinnerMar 7, 2024

Choose a reason for hiding this comment

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

It might not be. I might just remove it.
On python -m test_typing test_re test_dis test_zlib., I get:

frozenset:278 tuple:261 dict:256 list:225 set:150 str:143 mappingproxy:62 dict_values:9 EnumDict:5 collections.OrderedDict:5 collections.defaultdict:4 _Environ:3 

Copy link
MemberAuthor

@Fidget-SpinnerFidget-SpinnerMar 7, 2024

Choose a reason for hiding this comment

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

Note: I'm not specializing for tuple or list because it's dominated by searching up through the collection anyways so it's not worth it. The rest are O(1) so maybe worth to cut the constant factor.

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@gvanrossumgvanrossum removed their request for review March 7, 2024 15:44
@gvanrossum
Copy link
Member

I'll leave this between the two of you. (TBH I didn't mean for you to merge gh-116385, I should have been clearer -- I was signing off but expected Mark to have something to say and was hoping for a benchmark.)

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

Looks good.

@Fidget-SpinnerFidget-Spinner merged commit 41457c7 into python:mainMar 7, 2024
@Fidget-SpinnerFidget-Spinner deleted the spec_contains_op_fix branch March 7, 2024 16:21
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Fidget-Spinner@gvanrossum@markshannon