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

Make hash collisions in the registry much less likely #657

Merged
merged 3 commits into from Oct 15, 2019
Merged

Commits on Oct 14, 2019

  1. Expose bug #633

    Signed-off-by: beorn7 <beorn@grafana.com>
    beorn7 committed Oct 14, 2019
    Copy the full SHA
    bf9ff71 View commit details
    Browse the repository at this point in the history
  2. Minimal “fix” for hash collisions

    This makes the collisions a bit less likely by XOR'ing descIDs rather
    than adding them up for the collectorID.
    
    Signed-off-by: beorn7 <beorn@grafana.com>
    beorn7 committed Oct 14, 2019
    Copy the full SHA
    c2e3855 View commit details
    Browse the repository at this point in the history
  3. Move registry hashing to xxhash

    This is a much stronger hash function than fnv64a and comparably fast
    (with super-fast assembly implementation for amd64).
    
    Performance is not critical here anyway.
    
    The old fnv64a is kept for vectors, where collision detection is in
    place and the weakness of the hashing doesn't matter that much. I
    implemented a vector version with xxhash and found that xxhash is
    slower in all cases except very very high cardinality (where it is
    only slightly faster). Also, ``xxhash.New`` comes with an allocation
    of 80 bytes. Thus, to keep vectors alloc-free, we needed to add a
    `sync.Pool`, which would have an additional performance overhead.
    
    Signed-off-by: beorn7 <beorn@grafana.com>
    beorn7 committed Oct 14, 2019
    Copy the full SHA
    ee1078a View commit details
    Browse the repository at this point in the history