Cut the comments back to the genuinely subtle ones
This commit is contained in:
@@ -79,9 +79,8 @@ func (h *heldValue) get(now time.Time, cur uint64) uint64 {
|
||||
return h.v
|
||||
}
|
||||
|
||||
// Everything the display reads, taken at one instant: the worker counters plus
|
||||
// the two that are read rather than counted, so a pair of these describes both
|
||||
// the rates and the errors over the span between them.
|
||||
// Everything the display reads, taken at one instant, so a pair of these
|
||||
// describes both the rates and the errors over the span between them.
|
||||
type counterSet struct {
|
||||
t time.Time
|
||||
s sample
|
||||
@@ -95,9 +94,7 @@ func (d *direction) capture(t time.Time) counterSet {
|
||||
}
|
||||
|
||||
// What someone testing a cable is asking, rather than how each failure happened
|
||||
// to be noticed. Corruption arrives as three different symptoms and the kernel
|
||||
// drops frames for reasons that are ours rather than the cable's, but none of
|
||||
// that is a distinction worth reading off a panel.
|
||||
// to be noticed.
|
||||
type errs struct {
|
||||
lost uint64
|
||||
corrupt uint64
|
||||
@@ -318,8 +315,8 @@ var intervalCols = []colSpec{
|
||||
{title: "LEN m", width: 6, right: true},
|
||||
}
|
||||
|
||||
// One interval's numbers, shared by the console table and the framebuffer so
|
||||
// both always show the same figures.
|
||||
// Shared by the console table and the framebuffer so both show the same
|
||||
// figures.
|
||||
type view struct {
|
||||
txPPS, rxPPS float64
|
||||
txGbps, rxGbps float64
|
||||
@@ -349,8 +346,6 @@ func errsBetween(b, n counterSet) errs {
|
||||
}
|
||||
}
|
||||
|
||||
// Cumulative fields, which need no rate window and are identical for both the
|
||||
// console and the display.
|
||||
func (d *direction) counters(now counterSet) view {
|
||||
return view{
|
||||
rxFrames: now.s.rxFrames - d.base.s.rxFrames,
|
||||
@@ -395,17 +390,14 @@ func (d *direction) view(t time.Time) view {
|
||||
return v
|
||||
}
|
||||
|
||||
// The one place the counters are read for the ring. Runs on its own ticker, so
|
||||
// what the buckets measure does not move when the drawing does.
|
||||
func (d *direction) sample(t time.Time) {
|
||||
d.mu.Lock()
|
||||
d.win.push(d.capture(t))
|
||||
d.mu.Unlock()
|
||||
}
|
||||
|
||||
// Draws whatever the sampler last put in the ring rather than reading the
|
||||
// counters again, so the display is a consumer of the measurement and never a
|
||||
// participant in it.
|
||||
// Draws what the sampler last put in the ring rather than reading the counters
|
||||
// again, so the display never participates in the measurement.
|
||||
func (d *direction) displayView(t time.Time) view {
|
||||
d.mu.Lock()
|
||||
n := d.win.count()
|
||||
@@ -604,21 +596,17 @@ func main() {
|
||||
|
||||
const (
|
||||
reportInterval = time.Second
|
||||
// What a bucket covers. Nothing to do with how often the panel is redrawn:
|
||||
// how often the counters are read is a property of the measurement, and
|
||||
// letting the refresh set it would let a slow or blocked draw stretch the
|
||||
// window it reports. Short enough that a step lands promptly, long enough
|
||||
// that a bucket holds tens of thousands of frames at line rate and is not
|
||||
// itself noise.
|
||||
// Deliberately not tied to the refresh: letting a slow or blocked draw set
|
||||
// the sampling clock would stretch the window it reports.
|
||||
sampleInterval = 16 * time.Millisecond
|
||||
// Both how far back the shown errors reach and how many buckets the median
|
||||
// runs over, so a step in the rate lands half this late.
|
||||
// How far back the shown errors reach and how many buckets the median runs
|
||||
// over, so a step in the rate lands half this late.
|
||||
rateWindowSpan = time.Second
|
||||
totalsHold = 50 * time.Millisecond
|
||||
)
|
||||
|
||||
// One sampler for both directions, so their buckets share an instant and the
|
||||
// cable length, which needs a figure from each, is never mixing two moments.
|
||||
// cable length, which needs a figure from each, never mixes two moments.
|
||||
type sampler struct {
|
||||
dirs []*direction
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user