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

Hashing improvements #532

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Hashing improvements #532

wants to merge 1 commit into from

Conversation

hoxxep
Copy link

@hoxxep hoxxep commented Dec 12, 2024

As part of investigating whether rust-prometheus would benefit from rapidhash, I noticed a few improvements that could be made:

  • The MetricVecCore::children hashmap uses keys that are hash values, so introducing NoHashHasher to avoid re-hashing this hash value improves performance.
  • Allow with and get_metric_with to accept hashmaps with custom hashers.
  • Introduce criterion's black_box in some hashmaps to reduce over-optimisation in microbenchmarks. Could be applied to further benchmarks.

Some of the counter.rs benchmarks are including hashmap initialisation and destruction. They are also using fixed values and small keys/values, which means benchmarks were unclear over whether FNV or rapidhash are beneficial (hash clashes, etc). Slightly longer key/value lengths are likely to benefit from rapidhash.

Copy link

ti-chi-bot bot commented Dec 12, 2024

Welcome @hoxxep! It looks like this is your first PR to tikv/rust-prometheus 🎉

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.

1 participant