Restructure stats into delta, mask, and aggregate layers
This commit is contained in:
@@ -152,9 +152,11 @@ const (
|
||||
)
|
||||
|
||||
// One sampler for both directions, so they are read back to back on one clock
|
||||
// rather than drifting apart on two.
|
||||
// rather than drifting apart on two. Whatever each tick lets through the mask
|
||||
// goes on into the history's buckets.
|
||||
type sampler struct {
|
||||
dirs []*direction
|
||||
hist *history
|
||||
}
|
||||
|
||||
func (s *sampler) run(done *atomic.Bool, startTx <-chan struct{}) {
|
||||
@@ -166,7 +168,7 @@ func (s *sampler) run(done *atomic.Bool, startTx <-chan struct{}) {
|
||||
for !done.Load() {
|
||||
<-tick.C
|
||||
for _, d := range s.dirs {
|
||||
d.sample()
|
||||
s.hist.addFaults(time.Now(), d.sample())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,7 +243,7 @@ func run(aName, bName string) (err error) {
|
||||
|
||||
var dirs []*direction
|
||||
for _, p := range [][2]endpoint{{a, b}, {b, a}} {
|
||||
d, err := buildDirection(p[0].name+"->"+p[1].name, p[0], p[1], &diag.measuring)
|
||||
d, err := buildDirection(p[0].name+"->"+p[1].name, p[0], p[1], &diag.masked)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -277,7 +279,8 @@ func run(aName, bName string) (err error) {
|
||||
for _, d := range dirs {
|
||||
d.start(&wg, &done, &rxReady, startTx)
|
||||
}
|
||||
samp := &sampler{dirs: dirs}
|
||||
hist := newHistory(time.Now())
|
||||
samp := &sampler{dirs: dirs, hist: hist}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@@ -289,7 +292,7 @@ func run(aName, bName string) (err error) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
defer holdPanic()
|
||||
m.run(&done)
|
||||
m.run(&done, hist)
|
||||
}()
|
||||
}
|
||||
// Every return from here on stops the workers before the deferred closes
|
||||
@@ -340,10 +343,9 @@ func run(aName, bName string) (err error) {
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
hist := newHistory(start)
|
||||
// A reset resets at the press, then re-measures; the measure's failures
|
||||
// are suppressed at their sources while it runs, so there is nothing to
|
||||
// hide or revert afterwards.
|
||||
// are dropped at the mask gate while it runs, so there is nothing to hide
|
||||
// or revert afterwards.
|
||||
kickMeasure := func() {
|
||||
if diag.kick(&done) {
|
||||
diag.resetLengths()
|
||||
|
||||
Reference in New Issue
Block a user