Skip to content

Commit 478c724

Browse files
committed
history: address feedback
1 parent c5e19bf commit 478c724

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,32 @@ import (
1414
// a slice of values).
1515
type thrashing struct {
1616
vs []float64 // the time series input
17-
// Runs are the maximal-length subsequences (computed in slice order) of
18-
// values within which all first differences have the same sign. For example,
19-
// the sequence [1,2,3,2,3,2,1] has the runs [1,2,3], [2,3], [2,1].
20-
// The number of runs equals one plus the number of sign changes in the first
21-
// differences.
22-
runs int
17+
2318
// tdtv is the trend-discounting total variation. It's close to the total
2419
// variation if the time series has no preferred trend (i.e. upwards or
2520
// downwards), but if there is a clear trend, the tdtv will be much smaller,
2621
// counting mainly the movement against the trend. see tdtv for details.
27-
tdtv float64
28-
uptv, dntv float64 // upwards and downwards total variations (both nonnegative)
22+
tdtv float64
2923
// normTV is a normalization factor for the total variation. By default, it is
3024
// initialized to the range of the input values, i.e. max - min (or 1 if max
3125
// == min). `tdtv/normTV` then measures how many times thrashing has "swept out"
3226
// the effective range of values the time series has taken on.
3327
// `tdtv/normTV` can grow arbitrarily large if the time series oscillates
3428
// frequently (and enough datapoints are present). To get a sense of a
3529
// "thrashing rate", `tdtv/(normTV*T)` or `tdtv/(normTV*runs) could be of
36-
// interest.
30+
// interest in the future.
3731
normTV float64
32+
33+
// uptv and dntv are the upwards and downwards total variations (both
34+
// nonnegative). They're kept for informational purposes only.
35+
uptv, dntv float64
36+
// Runs are the maximal-length subsequences (computed in slice order) of
37+
// values within which all first differences have the same sign. For example,
38+
// the sequence [1,2,3,2,3,2,1] has the runs [1,2,3], [2,3], [2,1].
39+
// The number of runs equals one plus the number of sign changes in the first
40+
// differences.
41+
// This is for informational purposes only.
42+
runs int
3843
}
3944

4045
func (th thrashing) String() string {
@@ -163,6 +168,10 @@ func extrema(vs []float64) (vmin, vmax, vrange float64) {
163168
// assumed to be for the same metric.
164169
type ThrashingSlice []thrashing
165170

171+
// normalize installs a common normTV for all thrashing structs in the slice by
172+
// computing the extrema (min/max) over all of the datapoints in the underlying
173+
// time series data. Each thrashing's normTV is replaced by this common
174+
// normalization factor.
166175
func (ths ThrashingSlice) normalize() {
167176
vmin := math.Inf(1)
168177
vmax := math.Inf(-1)

0 commit comments

Comments
 (0)