Skip to content

Conversation

haecker-felix
Copy link

The fxhash crate is no longer maintained. See https://rustsec.org/advisories/RUSTSEC-2025-0057.html

The rustc-hash is pretty much a drop-in replacement for fxhash. It has the same type names, but uses a different hashing algorithm under the hood:

The original hash algorithm provided by this crate was one taken from Firefox, hence the hasher it provides is called FxHasher. This name is kept for backwards compatibility, but the underlying hash has since been replaced. The current design for the hasher is a polynomial hash finished with a single bit rotation, together with a wyhash-inspired compression function for strings/slices, both designed by Orson Peters.

@baszalmstra
Copy link
Collaborator

If we are switching the hash algorithm we could also use ahash instead!

@haecker-felix haecker-felix changed the title chore: Replace fxhash with rustc-hash chore: Replace fxhash with ahash Sep 10, 2025
@haecker-felix haecker-felix force-pushed the fxhash branch 2 times, most recently from fe84a68 to 3ec8a94 Compare September 29, 2025 07:22
@haecker-felix
Copy link
Author

Now using the standard library’s HashMap and HashSet with ahash::RandomState.

Unlike FxHashMap and FxHashSet, the standard library versions no longer guarantee deterministic ordering of elements. I had to update some tests to account for this.

Not sure whether there may be other unintended side effects that the tests haven’t caught...

let mut visited = HashSet::default();

let mut package_names: Vec<_> = packages.keys().collect();
package_names.sort();
Copy link
Author

Choose a reason for hiding this comment

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

Another thing I had to change because of the no longer deterministic ordering of the HashSet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer we use IndexMap for these types to make sure they are deterministic instead of reordering which is more expensive.

Copy link
Author

Choose a reason for hiding this comment

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

FAIL [   0.040s] rattler_conda_types repo_data::topological_sort::tests::test_topological_sort::case_6
  stdout ───

    running 1 test
    test repo_data::topological_sort::tests::test_topological_sort::case_6 ... FAILED

    failures:

    failures:
        repo_data::topological_sort::tests::test_topological_sort::case_6

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 324 filtered out; finished in 0.03s
    
  stderr ───

    thread 'repo_data::topological_sort::tests::test_topological_sort::case_6' panicked at crates/rattler_conda_types/src/repo_data/topological_sort.rs:292:21:
    attempting to install panel (package 336 of 339) but dependency holoviews is not yet installed
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@baszalmstra Even with IndexMap / IndexSet that particular test keeps failing if I don't sort the package names manually.

Could it be possible, that there's a bug which didn't get triggered with FxHashMap as it had a different random ordering - but what happened to be accidentally the correct order for the test to be successful?

@haecker-felix haecker-felix force-pushed the fxhash branch 2 times, most recently from 62ad0b0 to 65e06a6 Compare October 1, 2025 07:37
let mut visited = HashSet::default();

let mut package_names: Vec<_> = packages.keys().collect();
package_names.sort();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer we use IndexMap for these types to make sure they are deterministic instead of reordering which is more expensive.

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.

2 participants