Take the rate epoch from the slowest stream's frontier, since reading a bucket claims every stream has delivered through it
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -135,17 +136,20 @@ func (w *rateWindow) at(i int) counterSet {
|
||||
return w.buf[i%len(w.buf)]
|
||||
}
|
||||
|
||||
// How long the newest epoch may sit still before the wire is taken to have gone
|
||||
// quiet. A stamp only advances when a frame arrives, so a frozen epoch means no
|
||||
// traffic rather than an unchanged rate.
|
||||
// How long the frontier may sit still before the wire is taken to have gone
|
||||
// quiet. It only advances when frames arrive on every stream, so a frozen
|
||||
// frontier means a stream has stopped delivering rather than an unchanged rate.
|
||||
const rateStale = 100 * time.Millisecond
|
||||
|
||||
// The newest epoch is still filling, since frames received in it may not have
|
||||
// been drained yet, so the rate is read from the one before it.
|
||||
// A stamp is only knowable once a worker drains the frame carrying it, so each
|
||||
// stream's newest epoch is a frontier: everything the wire delivered to that
|
||||
// queue before it has been counted. Reading one bucket across the board takes
|
||||
// the one behind the lowest frontier, which every stream has delivered past.
|
||||
// The leader's frontier would claim buckets the stragglers are still filling.
|
||||
func (d *direction) readRateBucket(now time.Time) {
|
||||
var newest int64
|
||||
newest := int64(math.MaxInt64)
|
||||
for _, r := range d.rxStats {
|
||||
if e := r.newest.Load(); e > newest {
|
||||
if e := r.newest.Load(); e < newest {
|
||||
newest = e
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user