mirror of
https://github.com/livekit/livekit.git
synced 2026-11-23 02:29:22 +00:00
sfu: measure probe timing against mono.Now() (#5247)
The probe controller, the probe packet group and the probe cluster store mono.Now() timestamps, but measure the time since them with time.Since. Since livekit/protocol#1439, mono.Now() has no monotonic reading, so time.Since takes the difference from the wall clock. After the wall clock steps, for example on an NTP correction, the settle wait and the probe pacing are off by the step for the rest of the process's life. Use mono.Now().Sub instead.
This commit is contained in:
1 parent
8634099070
commit
246639c5fe
3 files changed
+4
-4
No files matched your search
@@ -164,7 +164,7 @@ func (p *probeController) MaybeFinalizeProbe() (ccutils.ProbeClusterInfo, bool)
|
||||
if settleWait > p.params.Config.SettleWaitMax {
|
||||
settleWait = p.params.Config.SettleWaitMax
|
||||
}
|
||||
if time.Since(p.stateSwitchedAt) < settleWait {
|
||||
if mono.Now().Sub(p.stateSwitchedAt) < settleWait {
|
||||
return ccutils.ProbeClusterInfoInvalid, false
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ func (p *probePacketGroup) MaybeFinalizeProbe(maxSequenceNumber uint64, rtt floa
|
||||
if settleWait > p.params.Config.SettleWaitMax {
|
||||
settleWait = p.params.Config.SettleWaitMax
|
||||
}
|
||||
if time.Since(p.doneAt) < settleWait {
|
||||
if mono.Now().Sub(p.doneAt) < settleWait {
|
||||
return ccutils.ProbeClusterInfoInvalid, false
|
||||
}
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ func (c *Cluster) Process() time.Duration {
|
||||
c.startTime = mono.Now()
|
||||
bytesToSend = cBytesPerProbe
|
||||
} else {
|
||||
sinceStart := time.Since(c.startTime)
|
||||
sinceStart := mono.Now().Sub(c.startTime)
|
||||
if sinceStart > c.buckets[c.bucketIdx].expectedElapsedDuration {
|
||||
c.bucketIdx++
|
||||
overflow := false
|
||||
@@ -587,7 +587,7 @@ func (c *Cluster) MarshalLogObject(e zapcore.ObjectEncoder) error {
|
||||
e.AddInt("bucketIdx", c.bucketIdx)
|
||||
e.AddInt("probeBytesSent", c.probeBytesSent)
|
||||
e.AddTime("startTime", c.startTime)
|
||||
e.AddDuration("elapsed", time.Since(c.startTime))
|
||||
e.AddDuration("elapsed", mono.Now().Sub(c.startTime))
|
||||
e.AddBool("isComplete", c.isComplete)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user