Skip to content
This repository was archived by the owner on Jun 5, 2026. It is now read-only.
This repository was archived by the owner on Jun 5, 2026. It is now read-only.

collector: HashCounter uses DefaultHasher whose algorithm is not guaranteed stable #21

Description

⚠️ AI-generated issue — requires human investigation before acting on it.

Summary

HashCounter in src/collector.rs uses std::collections::hash_map::DefaultHasher for mapping stack traces to buckets. The Rust standard library explicitly documents that the hashing algorithm of DefaultHasher is not guaranteed to be stable across Rust versions or even across program runs (it may use randomisation).

Location

src/collector.rs, lines 124–128:

fn hash(key: &T) -> u64 {
    let mut s = DefaultHasher::new();
    key.hash(&mut s);
    s.finish()
}

Impact

  • A Rust version upgrade could change the hash function, altering bucket distribution and eviction behaviour without notice.
  • Hash randomisation (if ever enabled for DefaultHasher) would randomise which stack traces are evicted under pressure, making profiling results non-reproducible across runs.
  • Poor hash distribution for the specific structure of UnresolvedFrames keys (sequences of instruction pointers) could cause excessive collisions and evictions, silently degrading data accuracy.

Expected behaviour

Use a stable, well-distributed hasher appropriate for profiler workloads, such as fnv, ahash, or rustc-hash. The choice should be documented alongside the eviction policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions