github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/util/hash_fp.go (about)

     1  package util
     2  
     3  import "github.com/prometheus/common/model"
     4  
     5  // HashFP simply moves entropy from the most significant 48 bits of the
     6  // fingerprint into the least significant 16 bits (by XORing) so that a simple
     7  // MOD on the result can be used to pick a mutex while still making use of
     8  // changes in more significant bits of the fingerprint. (The fast fingerprinting
     9  // function we use is prone to only change a few bits for similar metrics. We
    10  // really want to make use of every change in the fingerprint to vary mutex
    11  // selection.)
    12  func HashFP(fp model.Fingerprint) uint32 {
    13  	return uint32(fp ^ (fp >> 32) ^ (fp >> 16))
    14  }