From 4805dec1f01dff8608b6b0d42d1567a21e3f93e5 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Sat, 10 Jun 2023 10:54:55 +0530 Subject: [PATCH] Create channel observer on probe reset. (#1783) On a state change, it was possible an aborted probe was pending finalize. When probe controller is reset, the probe channel observer was not reset. Create a new non-probe channel observer on state change to get a fresh start. Also limit probe finalize wait to 10 seconds max. It is possible that the estimate is very low and we have sent a bunch of probes. Calculating wait based on that could lead to finalize waiting for a long time (could be minutes). --- pkg/sfu/streamallocator/probe_controller.go | 4 ++++ pkg/sfu/streamallocator/streamallocator.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pkg/sfu/streamallocator/probe_controller.go b/pkg/sfu/streamallocator/probe_controller.go index 519d31832..6b476b6d5 100644 --- a/pkg/sfu/streamallocator/probe_controller.go +++ b/pkg/sfu/streamallocator/probe_controller.go @@ -12,6 +12,7 @@ const ( ProbeBackoffFactor = 1.5 ProbeWaitMax = 30 * time.Second ProbeSettleWait = 250 + ProbeSettleWaitMax = 10 * time.Second ProbeTrendWait = 2 * time.Second ProbePct = 120 @@ -82,6 +83,9 @@ func (p *ProbeController) ProbeClusterDone(info ProbeClusterInfo, lowestEstimate queueTime = 0.0 } queueWait := time.Duration(queueTime+float64(ProbeSettleWait)) * time.Millisecond + if queueWait > ProbeSettleWaitMax { + queueWait = ProbeSettleWaitMax + } p.probeEndTime = p.lastProbeStartTime.Add(queueWait) p.params.Logger.Infow( "setting probe end time", diff --git a/pkg/sfu/streamallocator/streamallocator.go b/pkg/sfu/streamallocator/streamallocator.go index d13141e7d..76bdddb50 100644 --- a/pkg/sfu/streamallocator/streamallocator.go +++ b/pkg/sfu/streamallocator/streamallocator.go @@ -743,6 +743,8 @@ func (s *StreamAllocator) setState(state streamAllocatorState) { // reset probe to enforce a delay after state change before probing s.probeController.Reset() + // a fresh channel observer after state transition to get clean data + s.channelObserver = s.newChannelObserverNonProbe() } func (s *StreamAllocator) adjustState() {