Conversation
|
Welcome @hoxxep! It looks like this is your first PR to tikv/rust-prometheus 🎉 |
Signed-off-by: Liam Gray <hoxxep@gmail.com>
lucab
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I'd be happy to land something like this but I'm slightly wary about the state of https://github.com/paritytech/nohash-hasher.
Would you be open to drop nohash-hasher and directly implement a NoHasherU64 in here?
Signed-off-by: Liam Gray <hoxxep@gmail.com>
Signed-off-by: Liam Gray <hoxxep@gmail.com>
|
@lucab sure! I've removed the nohash-hasher dependency and had a sparring session with the DCO signoff bot, but that should be done now 👍 |
lucab
left a comment
There was a problem hiding this comment.
This generally looks fine, I only have a minor question.
It also needs a final cargo fmt --all in order to pass CI all checks.
src/nohash.rs
Outdated
| pub struct NoHashHasher(u64); | ||
|
|
||
| pub type BuildNoHashHasher = BuildHasherDefault<NoHashHasher>; |
There was a problem hiding this comment.
I think these two can be more properly restricted to pub(crate), right?
There was a problem hiding this comment.
Yeah. They're technically never re-exported, but I've adjusted to pub(crate) per your request so that it's explicit to the reader.
Signed-off-by: Liam Gray <hoxxep@gmail.com>
As part of investigating whether rust-prometheus would benefit from rapidhash, I noticed a few improvements that could be made:
MetricVecCore::childrenhashmap uses keys that are hash values, so introducingNoHashHasherto avoid re-hashing this hash value improves performance.withandget_metric_withto accept hashmaps with custom hashers.black_boxin some hashmaps to reduce over-optimisation in microbenchmarks. Could be applied to further benchmarks.Some of the
counter.rsbenchmarks 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.