diff options
author | Russ Cox <rsc@golang.org> | 2017-03-02 09:24:42 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2017-03-06 15:05:42 +0000 |
commit | 06a6b3a4134f1c7b93308a4f45eed6aeaa9a5f00 (patch) | |
tree | 9ad0e7b89fc528d04898b785058fa9d93e8270a9 | |
parent | 2ec77d3457aaa9e07ac5c765a0323fc9c3ef889f (diff) | |
download | go-06a6b3a4134f1c7b93308a4f45eed6aeaa9a5f00.tar.gz go-06a6b3a4134f1c7b93308a4f45eed6aeaa9a5f00.zip |
test/locklinear: deflake again
On overloaded machines once we get to big N, the machine slowness dominates.
But we only retry once we get to a big N.
Instead, retry for small N too, and die on the first big N that fails.
Change-Id: I3ab9cfb88832ad86e2ba1389a926045091268aeb
Reviewed-on: https://go-review.googlesource.com/37543
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r-- | test/locklinear.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/locklinear.go b/test/locklinear.go index 3585b40d67..f1e912a2a3 100644 --- a/test/locklinear.go +++ b/test/locklinear.go @@ -49,18 +49,19 @@ func checkLinear(typ string, tries int, f func(n int)) { if t1*3/2 < t2 && t2 < t1*5/2 { return } - // If 2n ops run in under a second and the ratio - // doesn't work out, make n bigger, trying to reduce - // the effect that a constant amount of overhead has - // on the computed ratio. - if t2 < 1*time.Second { - n *= 2 - continue - } // Once the test runs long enough for n ops, // try to get the right ratio at least once. // If many in a row all fail, give up. - if fails++; fails >= 10 { + if fails++; fails >= 5 { + // If 2n ops run in under a second and the ratio + // doesn't work out, make n bigger, trying to reduce + // the effect that a constant amount of overhead has + // on the computed ratio. + if t2 < time.Second*4/10 { + fails = 0 + n *= 2 + continue + } panic(fmt.Sprintf("%s: too slow: %d ops: %v; %d ops: %v\n\n%s", typ, n, t1, 2*n, t2, buf.String())) } |