Closed Purpzie closed 9 months ago
@SoniEx2 There doesn't seem to be a way to avoid that in the first place, since it's a problem in the compiler itself.
the point is "stop relying on current implementation details".
like sure, use a faster hasher. but don't break if TypeId
changes.
(not panicking/doing nothing in write
would be a good start, but would leave hashes as 0. it'd still work if TypeId changed at least, even if a lot slower due to hash collisions. alternatively having a slow path write
and a fast path write_u64
would work.)
Hi @Purpzie , Thanks for the contribution! I'm certainly open to performance improvements if they're correct and significant enough to offset any extra complexity. Have you measured the difference in performance (i.e. is hashing typeids a significant overhead)?
TypeIds are already hashes from the compiler, so they don't need to be hashed again. I've added a dummy hasher which just passes the TypeId through without modifying it.
For example, the
tracing-subscriber
crate does the same thing: https://github.com/tokio-rs/tracing/blob/3517552c319a22c108d423ca9a1675e632f616a3/tracing-subscriber/src/registry/extensions.rs#L12-L34