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

A collection of hashing improvements from using hashtables. #4094

Merged
merged 5 commits into from
Jul 2, 2024

Conversation

chandlerc
Copy link
Contributor

LLVM's APInt and APFloat need specialized handling to be used effectively in hashtables. We can't inject overrides into LLVM so we need to handle them in our hashing routine.

There were also problematic limits on hashing pairs and tuples. First, the unique-object-representation hashing of pairs was more restricted than tuples which was a problematic asymmetry and isn't needed. But the larger issue is that we didn't support recursively hashing when necessary. That requires a careful predicate to avoid infinite recursion but lets us handle important use cases for hashtables with a tuple as a key.

Also added support for hashing arrays that recurse in addition to arrays where we can hash the raw storage, and added overloads to redirect to common array handling from various array-like types.

Last but not least, re-worked the constraint model for hashing as raw data to not override custom hashing functions.

@github-actions github-actions bot requested a review from josh11b June 30, 2024 03:29
LLVM's `APInt` and `APFloat` need specialized handling to be used
effectively in hashtables. We can't inject overrides into LLVM so we
need to handle them in our hashing routine.

There were also problematic limits on hashing pairs and tuples. First,
the unique-object-representation hashing of pairs was more restricted
than tuples which was a problematic asymmetry and isn't needed. But the
larger issue is that we didn't support recursively hashing when
necessary. That requires a careful predicate to avoid infinite recursion
but lets us handle important use cases for hashtables with a tuple as
a key.

Also added support for hashing arrays that recurse in addition to arrays
where we can hash the raw storage, and added overloads to redirect to
common array handling from various array-like types.

Last but not least, re-worked the constraint model for hashing as raw
data to not override custom hashing functions.
@chandlerc chandlerc force-pushed the hashing-improvements branch from b348a8a to e649adc Compare June 30, 2024 03:30
@chandlerc chandlerc requested a review from zygoloid July 1, 2024 20:10
common/hashing.h Show resolved Hide resolved
common/hashing.h Outdated Show resolved Hide resolved
common/hashing.h Outdated Show resolved Hide resolved
Copy link
Contributor Author

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

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

Thanks for the review. A new version that tries to do this in a bit more principled way.

common/hashing.h Show resolved Hide resolved
common/hashing.h Outdated Show resolved Hide resolved
common/hashing.h Outdated Show resolved Hide resolved
@chandlerc chandlerc requested a review from zygoloid July 2, 2024 19:09
common/hashing.h Outdated Show resolved Hide resolved
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
common/hashing.h Outdated Show resolved Hide resolved
common/hashing.h Outdated Show resolved Hide resolved
common/hashing.h Outdated Show resolved Hide resolved
chandlerc and others added 2 commits July 2, 2024 13:44
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
common/hashing.h Outdated Show resolved Hide resolved
@chandlerc chandlerc enabled auto-merge July 2, 2024 20:48
@chandlerc chandlerc added this pull request to the merge queue Jul 2, 2024
Merged via the queue into carbon-language:trunk with commit bf736e6 Jul 2, 2024
7 checks passed
@chandlerc chandlerc deleted the hashing-improvements branch July 2, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants