Move congestion controller channel observer params to config (#1910)
This commit is contained in:
@@ -2,8 +2,8 @@ package streamallocator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
@@ -56,14 +56,8 @@ func (c ChannelCongestionReason) String() string {
|
||||
// ------------------------------------------------
|
||||
|
||||
type ChannelObserverParams struct {
|
||||
Name string
|
||||
EstimateRequiredSamples int
|
||||
EstimateDownwardTrendThreshold float64
|
||||
EstimateCollapseThreshold time.Duration
|
||||
EstimateValidityWindow time.Duration
|
||||
NackWindowMinDuration time.Duration
|
||||
NackWindowMaxDuration time.Duration
|
||||
NackRatioThreshold float64
|
||||
Name string
|
||||
Config config.CongestionControlChannelObserverConfig
|
||||
}
|
||||
|
||||
type ChannelObserver struct {
|
||||
@@ -81,17 +75,17 @@ func NewChannelObserver(params ChannelObserverParams, logger logger.Logger) *Cha
|
||||
estimateTrend: NewTrendDetector(TrendDetectorParams{
|
||||
Name: params.Name + "-estimate",
|
||||
Logger: logger,
|
||||
RequiredSamples: params.EstimateRequiredSamples,
|
||||
DownwardTrendThreshold: params.EstimateDownwardTrendThreshold,
|
||||
CollapseThreshold: params.EstimateCollapseThreshold,
|
||||
ValidityWindow: params.EstimateValidityWindow,
|
||||
RequiredSamples: params.Config.EstimateRequiredSamples,
|
||||
DownwardTrendThreshold: params.Config.EstimateDownwardTrendThreshold,
|
||||
CollapseThreshold: params.Config.EstimateCollapseThreshold,
|
||||
ValidityWindow: params.Config.EstimateValidityWindow,
|
||||
}),
|
||||
nackTracker: NewNackTracker(NackTrackerParams{
|
||||
Name: params.Name + "-nack",
|
||||
Logger: logger,
|
||||
WindowMinDuration: params.NackWindowMinDuration,
|
||||
WindowMaxDuration: params.NackWindowMaxDuration,
|
||||
RatioThreshold: params.NackRatioThreshold,
|
||||
WindowMinDuration: params.Config.NackWindowMinDuration,
|
||||
WindowMaxDuration: params.Config.NackWindowMaxDuration,
|
||||
RatioThreshold: params.Config.NackRatioThreshold,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,32 +39,6 @@ const (
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
var (
|
||||
ChannelObserverParamsProbe = ChannelObserverParams{
|
||||
Name: "probe",
|
||||
EstimateRequiredSamples: 3,
|
||||
EstimateDownwardTrendThreshold: 0.0,
|
||||
EstimateCollapseThreshold: 0,
|
||||
EstimateValidityWindow: 10 * time.Second,
|
||||
NackWindowMinDuration: 500 * time.Millisecond,
|
||||
NackWindowMaxDuration: 1 * time.Second,
|
||||
NackRatioThreshold: 0.04,
|
||||
}
|
||||
|
||||
ChannelObserverParamsNonProbe = ChannelObserverParams{
|
||||
Name: "non-probe",
|
||||
EstimateRequiredSamples: 8,
|
||||
EstimateDownwardTrendThreshold: -0.5,
|
||||
EstimateCollapseThreshold: 500 * time.Millisecond,
|
||||
EstimateValidityWindow: 10 * time.Second,
|
||||
NackWindowMinDuration: 1 * time.Second,
|
||||
NackWindowMaxDuration: 2 * time.Second,
|
||||
NackRatioThreshold: 0.08,
|
||||
}
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type streamAllocatorState int
|
||||
|
||||
const (
|
||||
@@ -1193,11 +1167,23 @@ func (s *StreamAllocator) getNackDelta() (uint32, uint32) {
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) newChannelObserverProbe() *ChannelObserver {
|
||||
return NewChannelObserver(ChannelObserverParamsProbe, s.params.Logger)
|
||||
return NewChannelObserver(
|
||||
ChannelObserverParams{
|
||||
Name: "probe",
|
||||
Config: s.params.Config.ChannelObserverProbeConfig,
|
||||
},
|
||||
s.params.Logger,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) newChannelObserverNonProbe() *ChannelObserver {
|
||||
return NewChannelObserver(ChannelObserverParamsNonProbe, s.params.Logger)
|
||||
return NewChannelObserver(
|
||||
ChannelObserverParams{
|
||||
Name: "non-probe",
|
||||
Config: s.params.Config.ChannelObserverNonProbeConfig,
|
||||
},
|
||||
s.params.Logger,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) initProbe(probeGoalDeltaBps int64) {
|
||||
|
||||
Reference in New Issue
Block a user