Skip to content

Commit d995e25

Browse files
craig[bot]wenyihu6tbg
committed
Merge #153897
153897: asim: deflake TestThrashing r=tbg a=wenyihu6 Previously, tsFromFunc generated 100 values using math.Sin(math.Pi * float64(tick) / 10) to produce oscillating numbers for thrashing tests. Small differences in the least significant digits (up to ~1e-10) can occur across architectures due to slight variations in sin computation, but these are negligible. This commit attempts to deflake this test by rounding the numbers generated to 6 digits. Fixes: #153876 Release note: none Co-authored-by: wenyihu6 <[email protected]> Co-authored-by: Tobias Grieger <[email protected]>
2 parents 78cbed5 + ae07ac9 commit d995e25

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/kv/kvserver/asim/history/testdata/TestThrashing/oscillate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
echo
22
----
33
An example that the thrashing percentage can arbitarily exceed 200%.
4-
input: [0 0.3090169943749474 0.5877852522924731 0.8090169943749475 0.9510565162951535 1 0.9510565162951536 0.8090169943749475 0.5877852522924732 0.3090169943749475 1.2246467991473515e-16 -0.3090169943749469 -0.587785252292473 -0.8090169943749473 -0.9510565162951535 -1 -0.9510565162951536 -0.8090169943749476 -0.5877852522924732 -0.3090169943749476 -2.449293598294703e-16 0.3090169943749472 0.5877852522924722 0.8090169943749472 0.9510565162951535 1 0.9510565162951538 0.8090169943749476 0.5877852522924734 0.3090169943749478 3.6739403974420544e-16 -0.30901699437494706 -0.5877852522924728 -0.8090169943749472 -0.9510565162951534 -1 -0.9510565162951538 -0.8090169943749477 -0.5877852522924735 -0.3090169943749479 -4.898587196589406e-16 0.30901699437494523 0.5877852522924728 0.8090169943749471 0.9510565162951529 1 0.9510565162951538 0.8090169943749468 0.5877852522924737 0.30901699437494967 6.123233995736757e-16 -0.3090169943749451 -0.5877852522924726 -0.8090169943749481 -0.9510565162951534 -1 -0.9510565162951539 -0.8090169943749489 -0.5877852522924737 -0.3090169943749498 -7.347880794884109e-16 0.3090169943749484 0.5877852522924725 0.809016994374948 0.9510565162951533 1 0.9510565162951539 0.809016994374949 0.5877852522924738 0.3090169943749465 8.57252759403146e-16 -0.3090169943749483 -0.5877852522924724 -0.8090169943749458 -0.9510565162951533 -1 -0.9510565162951539 -0.809016994374947 -0.5877852522924739 -0.3090169943749467 -9.797174393178812e-16 0.3090169943749448 0.5877852522924695 0.8090169943749479 0.9510565162951533 1 0.951056516295154 0.809016994374949 0.5877852522924769 0.3090169943749468 1.1021821192326163e-15 -0.3090169943749447 -0.5877852522924722 -0.8090169943749458 -0.9510565162951543 -1 -0.951056516295154 -0.8090169943749491 -0.587785252292477 -0.3090169943749469]
4+
input: [0 0.309017 0.587785 0.809017 0.951057 1 0.951057 0.809017 0.587785 0.309017 0 -0.309017 -0.587785 -0.809017 -0.951057 -1 -0.951057 -0.809017 -0.587785 -0.309017 -0 0.309017 0.587785 0.809017 0.951057 1 0.951057 0.809017 0.587785 0.309017 0 -0.309017 -0.587785 -0.809017 -0.951057 -1 -0.951057 -0.809017 -0.587785 -0.309017 -0 0.309017 0.587785 0.809017 0.951057 1 0.951057 0.809017 0.587785 0.309017 0 -0.309017 -0.587785 -0.809017 -0.951057 -1 -0.951057 -0.809017 -0.587785 -0.309017 -0 0.309017 0.587785 0.809017 0.951057 1 0.951057 0.809017 0.587785 0.309017 0 -0.309017 -0.587785 -0.809017 -0.951057 -1 -0.951057 -0.809017 -0.587785 -0.309017 -0 0.309017 0.587785 0.809017 0.951057 1 0.951057 0.809017 0.587785 0.309017 0 -0.309017 -0.587785 -0.809017 -0.951057 -1 -0.951057 -0.809017 -0.587785 -0.309017]
55
1.00 ┤ ╭╮ ╭╮ ╭╮ ╭╮ ╭─╮
66
0.80 ┤╭╯│ ╭╯│ ╭╯│ ╭╯│ │ │
77
0.60 ┤│ ╰╮ │ ╰╮ │ ╰╮ │ │ │ │

pkg/kv/kvserver/asim/history/thrashing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
func tsFromFunc(ticks int, f func(tick int) float64) []float64 {
2525
vs := make([]float64, ticks)
2626
for i := 0; i < ticks; i++ {
27-
vs[i] = f(i)
27+
vs[i] = math.Round(f(i)*1e6) / 1e6
2828
}
2929
return vs
3030
}

0 commit comments

Comments
 (0)