Skip to content

Include hashes of containing types when computing hash in EEClassHashTable - #61652

Closed
VSadov wants to merge 4 commits into
dotnet:mainfrom
VSadov:hash4
Closed

Include hashes of containing types when computing hash in EEClassHashTable#61652
VSadov wants to merge 4 commits into
dotnet:mainfrom
VSadov:hash4

Conversation

@VSadov

@VSadovVSadov commented Nov 16, 2021

Copy link
Copy Markdown
Member

Prior to this change all nested types with the same name would be placed into the same hash bucket, regardless of their enclosing types. That ensures collisions for common type names like Enumerator or <>c .

The approach in this change is similar to what we do in R2R hash - the hash function will now include hashes of enclosing types if such exist. The main difference from R2R approach is that we do this only for case-sensitive flavor of the table.
Case-insensitive table may be created as needed from case-sensitive prototype. Case-insensitive table by construction shares the encloser items with the prototype table and thus cannot use encloser hashes, since they would not be in the canonical casing.
That basically means the case-insensitive use stays on the same plan as before. It appears to be a relatively rare scenario to support some reflection features.


After measuring, the effects of the change appear to be fairly minor. It does reduce some collisions, but it is not a lot to start with and in case-insensitive case the collisions are still there, so we still have outliers.
I am not sure the result justifies the added complexity.

@ghost

Copy link
Copy Markdown

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@VSadovVSadov changed the title Consider containing types when computing hash in EEClassHashTableInclude hashes of containing types when computing hash in EEClassHashTableNov 16, 2021
@VSadov
VSadov marked this pull request as ready for review November 16, 2021 23:27
@VSadov
VSadov marked this pull request as draft November 17, 2021 00:27
@VSadovVSadov closed this Nov 17, 2021
@VSadov

Copy link
Copy Markdown
MemberAuthor

@jkotas - FYI, I have implemented this change to reduce hash collisions in EEClassHashTable, but decided that the results are not worth the added complexity.

@ghostghost locked as resolved and limited conversation to collaborators Dec 17, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@VSadov