Skip to content

Conversation

@notgull
Copy link
Member

@notgull notgull commented Dec 20, 2025

A few years ago, I asked if we should use a different hash algorithm for our hash maps in the Wayland backend. We decided on using ahash, given that
it was the default in hashbrown at the time.
However, hashbrown has since moved to foldhash, along with the rest of the Rust community. So this PR moves this crate to foldhash as well.

This move is done for two primary reasons:

  • This reduces the number of dependencies in the tree for most GUI
    projects. As other projects use foldhash now, this removes ahash
    (as well as its five dependencies) from the tree.

  • In most cases, foldhash is faster than ahash.

  • Tested on all platforms changed

  • Added an entry to the changelog module if knowledge of this change could be valuable to users

  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior

  • Created or updated an example program if it would help users understand this functionality

@notgull
Copy link
Member Author

notgull commented Dec 20, 2025

cc @kchibisov, I know this is performance-sensitive for alacritty.

@notgull
Copy link
Member Author

notgull commented Dec 20, 2025

Hmm, looks like CI is failing because foldhash is released under the Zlib license. Given that a significant portion of our software in this tree is also released under Zlib (e.g. bytemuck), I doubt this should be an issue. That being said, I'm no longer a maintainer, so I'll only add it to the file if given the go-ahead.

//! * `wayland-csd-adwaita-notitle`.
//! * `wayland-csd-adwaita-notitlebar`.
#![allow(clippy::mutable_key_type)]
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: See if there's a way to resolve this from the wayland-rs end

@kchibisov
Copy link
Member

cc @kchibisov, I know this is performance-sensitive for alacritty.

winit code is not perf sensitive to alacritty, but we do use ahash in alacritty and it demonstrated to be faster than other algs.

@notgull
Copy link
Member Author

notgull commented Dec 21, 2025

Was foldhash included in those tests?

@kchibisov
Copy link
Member

I think not, I'll retest, but winit can use anything pretty much.

At the moment, the wayland code uses ahash to perform hashing
in its various hash mas. This was done because ahash was seen as
the best default in the Rust community at the time. However, most
Rust crates (including `hashbrown`) have since moved to using
foldhash instead.

This move is done for two primary reasons:

- This reduces the number of dependencies in the tree for most GUI
  projects. As other projects use foldhash now, this removes ahash
  (as well as its five dependencies) from the tree.
- In most cases, foldhash is faster than ahash.

Signed-off-by: John Nunley <[email protected]>
Signed-off-by: John Nunley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants