Take the cable zero from the shortest delay seen rather than a flag
This commit is contained in:
@@ -539,7 +539,6 @@ type config struct {
|
||||
streams int
|
||||
batch int
|
||||
probeEther uint16
|
||||
zeroNS float64
|
||||
nsPerM float64
|
||||
}
|
||||
|
||||
@@ -550,13 +549,13 @@ func main() {
|
||||
sizesArg = flag.String("sizes", "64,128,256,512,1024,1280,1514", "frame sizes in bytes, excluding FCS, cycled per packet")
|
||||
streams = flag.Int("streams", 7, "independent streams per direction, capped by rx rings; each gets its own ethertype, steered by a flow rule to its own rx queue")
|
||||
batch = flag.Int("batch", 64, "frames per sendmmsg/recvmmsg call")
|
||||
zeroNS = flag.Float64("zero-ns", 2163.77, "mean of both directions at zero cable length; belongs to the media adapters, recalibrate when they change")
|
||||
nsPerM = flag.Float64("ns-per-m", 5.4545, "mean of both directions, per metre of cable")
|
||||
|
||||
nsPerM = flag.Float64("ns-per-m", 5.3, "mean of both directions, per metre of cable")
|
||||
)
|
||||
flag.Parse()
|
||||
|
||||
if err := run(*aName, *bName, *sizesArg,
|
||||
*streams, *batch, *zeroNS, *nsPerM); err != nil {
|
||||
*streams, *batch, *nsPerM); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -574,7 +573,7 @@ const (
|
||||
)
|
||||
|
||||
func run(aName, bName, sizesArg string,
|
||||
nStreams, batch int, zeroNS, nsPerM float64) error {
|
||||
nStreams, batch int, nsPerM float64) error {
|
||||
|
||||
if aName == "" || bName == "" {
|
||||
return fmt.Errorf("both -a and -b are required")
|
||||
@@ -629,7 +628,6 @@ func run(aName, bName, sizesArg string,
|
||||
streams: nStreams,
|
||||
batch: batch,
|
||||
probeEther: uint16(etherBase + nStreams),
|
||||
zeroNS: zeroNS,
|
||||
nsPerM: nsPerM,
|
||||
}
|
||||
|
||||
@@ -674,7 +672,7 @@ func run(aName, bName, sizesArg string,
|
||||
nStreams, ethertypes[0], ethertypes[len(ethertypes)-1])},
|
||||
{"probe", fmt.Sprintf("ethertype 0x%04x every %s", cfg.probeEther, probeInterval)},
|
||||
{"batch", fmt.Sprintf("%d frames per syscall", batch)},
|
||||
{"calibration", fmt.Sprintf("%g ns at zero length, %g ns/m", zeroNS, nsPerM)},
|
||||
{"calibration", fmt.Sprintf("%g ns/m, zero taken from the shortest delay seen so far", nsPerM)},
|
||||
{"buffers", fmt.Sprintf("sndbuf %s, rcvbuf %s",
|
||||
humanBytes(uint64(sockBufSize(dirs[0].txFDs[0], unix.SO_SNDBUF))),
|
||||
humanBytes(uint64(sockBufSize(dirs[0].rxFDs[0], unix.SO_RCVBUF))))},
|
||||
|
||||
@@ -34,18 +34,20 @@ type cableStats struct {
|
||||
mu sync.Mutex
|
||||
min int64
|
||||
samples uint64
|
||||
floor int64
|
||||
|
||||
txPend map[uint64]int64
|
||||
rxPend map[uint64]int64
|
||||
}
|
||||
|
||||
type cableView struct {
|
||||
min int64
|
||||
samples uint64
|
||||
min int64
|
||||
floor int64
|
||||
ok bool
|
||||
}
|
||||
|
||||
func (v cableView) minText() string {
|
||||
if v.samples == 0 {
|
||||
if !v.ok {
|
||||
return "-"
|
||||
}
|
||||
return commasInt(v.min)
|
||||
@@ -57,15 +59,14 @@ func (c config) cableMetres(views []view) (float64, bool) {
|
||||
if len(views) == 0 {
|
||||
return 0, false
|
||||
}
|
||||
var sum float64
|
||||
var excess float64
|
||||
for _, v := range views {
|
||||
if v.cable.samples == 0 {
|
||||
if !v.cable.ok {
|
||||
return 0, false
|
||||
}
|
||||
sum += float64(v.cable.min)
|
||||
excess += float64(v.cable.min - v.cable.floor)
|
||||
}
|
||||
mean := sum / float64(len(views))
|
||||
return (mean - c.zeroNS) / c.nsPerM, true
|
||||
return excess / float64(len(views)) / c.nsPerM, true
|
||||
}
|
||||
|
||||
func (c config) cableText(views []view) string {
|
||||
@@ -114,13 +115,16 @@ func (c *cableStats) put(seq uint64, ts int64, tx bool) {
|
||||
if c.samples == 0 || delta < c.min {
|
||||
c.min = delta
|
||||
}
|
||||
if c.floor == 0 || delta < c.floor {
|
||||
c.floor = delta
|
||||
}
|
||||
c.samples++
|
||||
}
|
||||
|
||||
func (c *cableStats) view() cableView {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
return cableView{c.min, c.samples}
|
||||
return cableView{c.min, c.floor, c.samples > 0}
|
||||
}
|
||||
|
||||
func (c *cableStats) reset() {
|
||||
|
||||
Reference in New Issue
Block a user