Remote BWE tweaks (#3251)

This commit is contained in:
Raja Subramanian
2024-12-14 15:39:19 +05:30
committed by GitHub
parent 8cfea87ad0
commit 34ccc2a578
3 changed files with 32 additions and 38 deletions
+4 -4
View File
@@ -29,15 +29,15 @@ import (
type channelTrend int type channelTrend int
const ( const (
channelTrendNeutral channelTrend = iota channelTrendInconclusive channelTrend = iota
channelTrendClearing channelTrendClearing
channelTrendCongesting channelTrendCongesting
) )
func (c channelTrend) String() string { func (c channelTrend) String() string {
switch c { switch c {
case channelTrendNeutral: case channelTrendInconclusive:
return "NEUTRAL" return "INCONCLUSIVE"
case channelTrendClearing: case channelTrendClearing:
return "CLEARING" return "CLEARING"
case channelTrendCongesting: case channelTrendCongesting:
@@ -181,7 +181,7 @@ func (c *channelObserver) GetTrend() (channelTrend, channelCongestionReason) {
return channelTrendClearing, channelCongestionReasonNone return channelTrendClearing, channelCongestionReasonNone
} }
return channelTrendNeutral, channelCongestionReasonNone return channelTrendInconclusive, channelCongestionReasonNone
} }
func (c *channelObserver) MarshalLogObject(e zapcore.ObjectEncoder) error { func (c *channelObserver) MarshalLogObject(e zapcore.ObjectEncoder) error {
+18 -24
View File
@@ -127,7 +127,8 @@ func (r *RemoteBWE) HandleREMB(
r.lastExpectedBandwidthUsage = expectedBandwidthUsage r.lastExpectedBandwidthUsage = expectedBandwidthUsage
// in probe, freeze channel observer state if probe causes congestion till the probe is done, // in probe, freeze channel observer state if probe causes congestion till the probe is done,
// this is to ensure that probe result is not a success and an unsuccessful probe will not up allocate any tracks // this is to ensure that probe result is not marked a success,
// an unsuccessful probe will not up allocate any tracks
if r.congestionState != bwe.CongestionStateNone && r.probeController.IsInProbe() { if r.congestionState != bwe.CongestionStateNone && r.probeController.IsInProbe() {
r.lock.Unlock() r.lock.Unlock()
return return
@@ -157,15 +158,17 @@ func (r *RemoteBWE) congestionDetectionStateMachine() (bool, bwe.CongestionState
newState := r.congestionState newState := r.congestionState
update := false update := false
trend, reason := r.channelObserver.GetTrend() trend, reason := r.channelObserver.GetTrend()
if trend == channelTrendCongesting { if trend == channelTrendCongesting && r.congestionState == bwe.CongestionStateNone {
r.params.Logger.Debugw("remote bwe, channel congesting", "channel", r.channelObserver) r.params.Logger.Debugw("remote bwe, channel congesting", "channel", r.channelObserver)
} else if trend == channelTrendClearing && r.congestionState != bwe.CongestionStateNone {
r.params.Logger.Debugw("remote bwe, channel congestion relieving", "channel", r.channelObserver)
} }
switch r.congestionState { switch r.congestionState {
case bwe.CongestionStateNone: case bwe.CongestionStateNone:
if trend == channelTrendCongesting { if trend == channelTrendCongesting {
if r.probeController.IsInProbe() || r.estimateAvailableChannelCapacity(reason) { if r.probeController.IsInProbe() || r.estimateAvailableChannelCapacity(reason) {
// when in probe, if congested, stays there will probe is done, // when in probe, if congested, stays there till probe is done,
// the estimate stays at pre-probe level // the estimate stays at pre-probe level
newState = bwe.CongestionStateCongested newState = bwe.CongestionStateCongested
} }
@@ -213,8 +216,12 @@ func (r *RemoteBWE) estimateAvailableChannelCapacity(reason channelCongestionRea
} }
commitThreshold := int64(r.params.Config.ExpectedUsageThreshold * float64(r.lastExpectedBandwidthUsage)) commitThreshold := int64(r.params.Config.ExpectedUsageThreshold * float64(r.lastExpectedBandwidthUsage))
if estimateToCommit > commitThreshold || r.committedChannelCapacity == estimateToCommit {
return false
}
ulgr := r.params.Logger.WithUnlikelyValues( r.params.Logger.Infow(
"remote bwe: channel congestion detected, applying channel capacity update",
"reason", reason, "reason", reason,
"old(bps)", r.committedChannelCapacity, "old(bps)", r.committedChannelCapacity,
"new(bps)", estimateToCommit, "new(bps)", estimateToCommit,
@@ -223,16 +230,7 @@ func (r *RemoteBWE) estimateAvailableChannelCapacity(reason channelCongestionRea
"commitThreshold(bps)", commitThreshold, "commitThreshold(bps)", commitThreshold,
"channel", r.channelObserver, "channel", r.channelObserver,
) )
if estimateToCommit > commitThreshold {
ulgr.Debugw("remote bwe: channel congestion detected, skipping above commit threshold channel capacity update")
return false
}
ulgr.Infow("remote bwe: channel congestion detected, applying channel capacity update")
r.committedChannelCapacity = estimateToCommit r.committedChannelCapacity = estimateToCommit
// reset to get new set of samples for next trend
r.newChannelObserver()
return true return true
} }
@@ -330,22 +328,18 @@ func (r *RemoteBWE) ProbeClusterFinalize() (ccutils.ProbeSignal, int64, bool) {
} }
func (r *RemoteBWE) newChannelObserver() { func (r *RemoteBWE) newChannelObserver() {
var params channelObserverParams
if r.probeController.IsInProbe() { if r.probeController.IsInProbe() {
r.channelObserver = newChannelObserver( params = channelObserverParams{
channelObserverParams{
Name: "probe", Name: "probe",
Config: r.params.Config.ChannelObserverProbe, Config: r.params.Config.ChannelObserverProbe,
}, }
r.params.Logger,
)
r.channelObserver.SeedEstimate(r.committedChannelCapacity)
} else { } else {
r.channelObserver = newChannelObserver( params = channelObserverParams{
channelObserverParams{
Name: "non-probe", Name: "non-probe",
Config: r.params.Config.ChannelObserverNonProbe, Config: r.params.Config.ChannelObserverNonProbe,
},
r.params.Logger,
)
} }
}
r.channelObserver = newChannelObserver(params, r.params.Logger)
} }
+6 -6
View File
@@ -27,15 +27,15 @@ import (
type TrendDirection int type TrendDirection int
const ( const (
TrendDirectionNeutral TrendDirection = iota TrendDirectionInconclusive TrendDirection = iota
TrendDirectionUpward TrendDirectionUpward
TrendDirectionDownward TrendDirectionDownward
) )
func (t TrendDirection) String() string { func (t TrendDirection) String() string {
switch t { switch t {
case TrendDirectionNeutral: case TrendDirectionInconclusive:
return "NEUTRAL" return "INCONCLUSIVE"
case TrendDirectionUpward: case TrendDirectionUpward:
return "UPWARD" return "UPWARD"
case TrendDirectionDownward: case TrendDirectionDownward:
@@ -104,7 +104,7 @@ func NewTrendDetector[T trendDetectorNumber](params TrendDetectorParams) *TrendD
return &TrendDetector[T]{ return &TrendDetector[T]{
params: params, params: params,
startTime: time.Now(), startTime: time.Now(),
direction: TrendDirectionNeutral, direction: TrendDirectionInconclusive,
} }
} }
@@ -236,14 +236,14 @@ func (t *TrendDetector[T]) prune() {
func (t *TrendDetector[T]) updateDirection() { func (t *TrendDetector[T]) updateDirection() {
if len(t.samples) < t.params.Config.RequiredSamplesMin { if len(t.samples) < t.params.Config.RequiredSamplesMin {
t.direction = TrendDirectionNeutral t.direction = TrendDirectionInconclusive
return return
} }
// using Kendall's Tau to find trend // using Kendall's Tau to find trend
kt := t.kendallsTau() kt := t.kendallsTau()
t.direction = TrendDirectionNeutral t.direction = TrendDirectionInconclusive
switch { switch {
case kt > 0 && len(t.samples) >= t.params.Config.RequiredSamples: case kt > 0 && len(t.samples) >= t.params.Config.RequiredSamples:
t.direction = TrendDirectionUpward t.direction = TrendDirectionUpward