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

Hash stability guarantees #11690

Merged

Conversation

SpecificProtagonist
Copy link
Contributor

Objective

We currently over/underpromise hash stability:

  • HashMap/HashSet use BuildHasherDefault<AHasher> instead of RandomState. As a result, the hash is stable within the same run.
  • aHash isn't stable between devices (and versions), yet it's used for StableHashMap/StableHashSet
  • the specialized hashmaps are stable

Interestingly, StableHashMap/StableHashSet aren't used by Bevy itself (anymore).

Solution

Add/fix documentation

Alternatives

For StableHashMap/StableHashSet:


Changelog

  • added iteration stability guarantees for different hashmaps

@alice-i-cecile
Copy link
Member

I'm tentatively in favor of marking StableHashMap as deprecated in this PR. If they're not used internally, this really doesn't feel like something that Bevy has any business maintaining.

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it A-Utils Utility functions and types labels Feb 5, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 5, 2024
Merged via the queue into bevyengine:main with commit 8faaef1 Feb 5, 2024
26 checks passed
tjamaan pushed a commit to tjamaan/bevy that referenced this pull request Feb 6, 2024
# Objective

We currently over/underpromise hash stability:
- `HashMap`/`HashSet` use `BuildHasherDefault<AHasher>` instead of
`RandomState`. As a result, the hash is stable within the same run.
- [aHash isn't stable between devices (and
versions)](https://github.com/tkaitchuck/ahash?tab=readme-ov-file#goals-and-non-goals),
yet it's used for `StableHashMap`/`StableHashSet`
- the specialized hashmaps are stable

Interestingly, `StableHashMap`/`StableHashSet` aren't used by Bevy
itself (anymore).

## Solution
Add/fix documentation

## Alternatives
For `StableHashMap`/`StableHashSet`:
- remove them
- revive bevyengine#7107

---

## Changelog
- added iteration stability guarantees for different hashmaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Utils Utility functions and types C-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants