MCPcopy Create free account
hub / github.com/zalando/skipper / measureStdDev

Function measureStdDev

loadbalancer/algorithm_test.go:486–498  ·  view source on GitHub ↗

Measures how fair the hash ring is to each endpoint. i.e. Of the possible hashes, how many will go to each endpoint. The lower the standard deviation the better.

(endpoints []string, hashesPerEndpoint int)

Source from the content-addressed store, hash-verified

484// Measures how fair the hash ring is to each endpoint.
485// i.e. Of the possible hashes, how many will go to each endpoint. The lower the standard deviation the better.
486func measureStdDev(endpoints []string, hashesPerEndpoint int) float64 {
487 ch := newConsistentHashInternal(endpoints, hashesPerEndpoint).(*consistentHash)
488 ringOwnership := map[int]uint64{}
489 prevPartitionEndHash := uint64(0)
490 for i := 0; i < len(ch.hashRing); i++ {
491 endpointIndex := ch.hashRing[i].index
492 partitionEndHash := ch.hashRing[i].hash
493 ringOwnership[endpointIndex] += partitionEndHash - prevPartitionEndHash
494 prevPartitionEndHash = partitionEndHash
495 }
496 ringOwnership[ch.hashRing[0].index] += math.MaxUint64 - prevPartitionEndHash
497 return stdDeviation(ringOwnership)
498}
499
500func stdDeviation(counters map[int]uint64) float64 {
501 sum := uint64(0)

Callers 1

Calls 2

stdDeviationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…