Move congestion controller channel observer params to config (#1910)
This commit is contained in:
+36
-6
@@ -123,13 +123,25 @@ type CongestionControlProbeConfig struct {
|
|||||||
DurationIncreaseFactor float64 `yaml:"duration_increase_factor,omitempty"`
|
DurationIncreaseFactor float64 `yaml:"duration_increase_factor,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CongestionControlChannelObserverConfig struct {
|
||||||
|
EstimateRequiredSamples int `yaml:"estimate_required_samples,omitmpety"`
|
||||||
|
EstimateDownwardTrendThreshold float64 `yaml:"estimate_downward_trend_threshold,omitempty"`
|
||||||
|
EstimateCollapseThreshold time.Duration `yaml:"estimate_collapse_threshold,omitempty"`
|
||||||
|
EstimateValidityWindow time.Duration `yaml:"estimate_validity_window,omitempty"`
|
||||||
|
NackWindowMinDuration time.Duration `yaml:"nack_window_min_duration,omitempty"`
|
||||||
|
NackWindowMaxDuration time.Duration `yaml:"nack_window_max_duration,omitempty"`
|
||||||
|
NackRatioThreshold float64 `yaml:"nack_ratio_threshold,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type CongestionControlConfig struct {
|
type CongestionControlConfig struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
AllowPause bool `yaml:"allow_pause"`
|
AllowPause bool `yaml:"allow_pause"`
|
||||||
UseSendSideBWE bool `yaml:"send_side_bandwidth_estimation,omitempty"`
|
UseSendSideBWE bool `yaml:"send_side_bandwidth_estimation,omitempty"`
|
||||||
ProbeMode CongestionControlProbeMode `yaml:"padding_mode,omitempty"`
|
ProbeMode CongestionControlProbeMode `yaml:"padding_mode,omitempty"`
|
||||||
MinChannelCapacity int64 `yaml:"min_channel_capacity,omitempty"`
|
MinChannelCapacity int64 `yaml:"min_channel_capacity,omitempty"`
|
||||||
ProbeConfig CongestionControlProbeConfig `yaml:"probe_config,omitempty"`
|
ProbeConfig CongestionControlProbeConfig `yaml:"probe_config,omitempty"`
|
||||||
|
ChannelObserverProbeConfig CongestionControlChannelObserverConfig `yaml:"channel_observer_probe_config,omitempty"`
|
||||||
|
ChannelObserverNonProbeConfig CongestionControlChannelObserverConfig `yaml:"channel_observer_non_probe_config,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AudioConfig struct {
|
type AudioConfig struct {
|
||||||
@@ -303,6 +315,24 @@ var DefaultConfig = Config{
|
|||||||
DurationOverflowFactor: 1.25,
|
DurationOverflowFactor: 1.25,
|
||||||
DurationIncreaseFactor: 1.5,
|
DurationIncreaseFactor: 1.5,
|
||||||
},
|
},
|
||||||
|
ChannelObserverProbeConfig: CongestionControlChannelObserverConfig{
|
||||||
|
EstimateRequiredSamples: 3,
|
||||||
|
EstimateDownwardTrendThreshold: 0.0,
|
||||||
|
EstimateCollapseThreshold: 0,
|
||||||
|
EstimateValidityWindow: 10 * time.Second,
|
||||||
|
NackWindowMinDuration: 500 * time.Millisecond,
|
||||||
|
NackWindowMaxDuration: 1 * time.Second,
|
||||||
|
NackRatioThreshold: 0.04,
|
||||||
|
},
|
||||||
|
ChannelObserverNonProbeConfig: CongestionControlChannelObserverConfig{
|
||||||
|
EstimateRequiredSamples: 8,
|
||||||
|
EstimateDownwardTrendThreshold: -0.5,
|
||||||
|
EstimateCollapseThreshold: 500 * time.Millisecond,
|
||||||
|
EstimateValidityWindow: 10 * time.Second,
|
||||||
|
NackWindowMinDuration: 1 * time.Second,
|
||||||
|
NackWindowMaxDuration: 2 * time.Second,
|
||||||
|
NackRatioThreshold: 0.08,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Audio: AudioConfig{
|
Audio: AudioConfig{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package streamallocator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
|
"github.com/livekit/livekit-server/pkg/config"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,14 +56,8 @@ func (c ChannelCongestionReason) String() string {
|
|||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
|
|
||||||
type ChannelObserverParams struct {
|
type ChannelObserverParams struct {
|
||||||
Name string
|
Name string
|
||||||
EstimateRequiredSamples int
|
Config config.CongestionControlChannelObserverConfig
|
||||||
EstimateDownwardTrendThreshold float64
|
|
||||||
EstimateCollapseThreshold time.Duration
|
|
||||||
EstimateValidityWindow time.Duration
|
|
||||||
NackWindowMinDuration time.Duration
|
|
||||||
NackWindowMaxDuration time.Duration
|
|
||||||
NackRatioThreshold float64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChannelObserver struct {
|
type ChannelObserver struct {
|
||||||
@@ -81,17 +75,17 @@ func NewChannelObserver(params ChannelObserverParams, logger logger.Logger) *Cha
|
|||||||
estimateTrend: NewTrendDetector(TrendDetectorParams{
|
estimateTrend: NewTrendDetector(TrendDetectorParams{
|
||||||
Name: params.Name + "-estimate",
|
Name: params.Name + "-estimate",
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
RequiredSamples: params.EstimateRequiredSamples,
|
RequiredSamples: params.Config.EstimateRequiredSamples,
|
||||||
DownwardTrendThreshold: params.EstimateDownwardTrendThreshold,
|
DownwardTrendThreshold: params.Config.EstimateDownwardTrendThreshold,
|
||||||
CollapseThreshold: params.EstimateCollapseThreshold,
|
CollapseThreshold: params.Config.EstimateCollapseThreshold,
|
||||||
ValidityWindow: params.EstimateValidityWindow,
|
ValidityWindow: params.Config.EstimateValidityWindow,
|
||||||
}),
|
}),
|
||||||
nackTracker: NewNackTracker(NackTrackerParams{
|
nackTracker: NewNackTracker(NackTrackerParams{
|
||||||
Name: params.Name + "-nack",
|
Name: params.Name + "-nack",
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
WindowMinDuration: params.NackWindowMinDuration,
|
WindowMinDuration: params.Config.NackWindowMinDuration,
|
||||||
WindowMaxDuration: params.NackWindowMaxDuration,
|
WindowMaxDuration: params.Config.NackWindowMaxDuration,
|
||||||
RatioThreshold: params.NackRatioThreshold,
|
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
|
type streamAllocatorState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -1193,11 +1167,23 @@ func (s *StreamAllocator) getNackDelta() (uint32, uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StreamAllocator) newChannelObserverProbe() *ChannelObserver {
|
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 {
|
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) {
|
func (s *StreamAllocator) initProbe(probeGoalDeltaBps int64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user