mirror of
https://github.com/golang/go
synced 2024-11-18 06:04:53 -07:00
runtime: raise alert threshold on window smhasher test
This alert is triggering occasionally. I've investigated the collisions that happen, and they all seem to be pairwise, so they are not a big deal. "pairwise" = when there are 32 collisions, it is two keys mapping to the same hash, 32 times, not 33 keys all mapping to the same hash. Add some t.Logf calls in case this comes back, which will help isolate the problem. Fixes #39352 Change-Id: I1749d7c8efd0afcf9024d8964d15bc0f58a86e4f Reviewed-on: https://go-review.googlesource.com/c/go/+/237718 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7d975ae9c0
commit
8dae5390cb
@ -152,14 +152,13 @@ func (s *HashSet) addS_seed(x string, seed uintptr) {
|
|||||||
s.add(StringHash(x, seed))
|
s.add(StringHash(x, seed))
|
||||||
}
|
}
|
||||||
func (s *HashSet) check(t *testing.T) {
|
func (s *HashSet) check(t *testing.T) {
|
||||||
const SLOP = 10.0
|
const SLOP = 50.0
|
||||||
collisions := s.n - len(s.m)
|
collisions := s.n - len(s.m)
|
||||||
//fmt.Printf("%d/%d\n", len(s.m), s.n)
|
|
||||||
pairs := int64(s.n) * int64(s.n-1) / 2
|
pairs := int64(s.n) * int64(s.n-1) / 2
|
||||||
expected := float64(pairs) / math.Pow(2.0, float64(hashSize))
|
expected := float64(pairs) / math.Pow(2.0, float64(hashSize))
|
||||||
stddev := math.Sqrt(expected)
|
stddev := math.Sqrt(expected)
|
||||||
if float64(collisions) > expected+SLOP*(3*stddev+1) {
|
if float64(collisions) > expected+SLOP*(3*stddev+1) {
|
||||||
t.Errorf("unexpected number of collisions: got=%d mean=%f stddev=%f", collisions, expected, stddev)
|
t.Errorf("unexpected number of collisions: got=%d mean=%f stddev=%f threshold=%f", collisions, expected, stddev, expected+SLOP*(3*stddev+1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,8 +563,11 @@ func avalancheTest1(t *testing.T, k Key) {
|
|||||||
|
|
||||||
// All bit rotations of a set of distinct keys
|
// All bit rotations of a set of distinct keys
|
||||||
func TestSmhasherWindowed(t *testing.T) {
|
func TestSmhasherWindowed(t *testing.T) {
|
||||||
|
t.Logf("32 bit keys")
|
||||||
windowed(t, &Int32Key{})
|
windowed(t, &Int32Key{})
|
||||||
|
t.Logf("64 bit keys")
|
||||||
windowed(t, &Int64Key{})
|
windowed(t, &Int64Key{})
|
||||||
|
t.Logf("string keys")
|
||||||
windowed(t, &BytesKey{make([]byte, 128)})
|
windowed(t, &BytesKey{make([]byte, 128)})
|
||||||
}
|
}
|
||||||
func windowed(t *testing.T, k Key) {
|
func windowed(t *testing.T, k Key) {
|
||||||
|
Loading…
Reference in New Issue
Block a user