Use last received if lower. (#1616)

When detecting congestion based on loss, it is possible that
the loss based signal triggers earlier and the estimate based
signal is lagging. In those cases, check against last received
estimate and if that is lower than loss based throttling, use that.

Without this, it was possible that the current usage high.
Loss based throttling may not dial things back far enough to pause
the stream. Ideally, congestion should hit again and it should be dialled
down further and eventually pause, but there are situations it never
dials back far enough to pause.
This commit is contained in:
Raja Subramanian
2023-04-15 13:07:47 +05:30
committed by GitHub
parent f54a103049
commit e75b73af52
2 changed files with 18 additions and 17 deletions
+10 -17
View File
@@ -148,29 +148,17 @@ func (c *ChannelObserver) GetNackRatio() (uint32, uint32, float64) {
func (c *ChannelObserver) GetTrend() (ChannelTrend, ChannelCongestionReason) {
estimateDirection := c.estimateTrend.GetDirection()
packets, repeatedNacks, nackRatio := c.GetNackRatio()
_, _, nackRatio := c.GetNackRatio()
switch {
case estimateDirection == TrendDirectionDownward:
c.logger.Debugw(
"stream allocator: channel observer: estimate is trending downward",
"name", c.params.Name,
"estimate", c.estimateTrend.ToString(),
"packets", packets,
"repeatedNacks", repeatedNacks,
"ratio", nackRatio,
)
c.logger.Debugw( "stream allocator: channel observer: estimate is trending downward", "channel", c.ToString())
return ChannelTrendCongesting, ChannelCongestionReasonEstimate
case c.params.NackWindowMinDuration != 0 && !c.nackWindowStartTime.IsZero() && time.Since(c.nackWindowStartTime) > c.params.NackWindowMinDuration && nackRatio > c.params.NackRatioThreshold:
c.logger.Debugw(
"stream allocator: channel observer: high rate of repeated NACKs",
"name", c.params.Name,
"estimate", c.estimateTrend.ToString(),
"packets", packets,
"repeatedNacks", repeatedNacks,
"ratio", nackRatio,
)
c.logger.Debugw( "stream allocator: channel observer: high rate of repeated NACKs", "channel", c.ToString())
return ChannelTrendCongesting, ChannelCongestionReasonLoss
case estimateDirection == TrendDirectionUpward:
return ChannelTrendClearing, ChannelCongestionReasonNone
}
@@ -178,4 +166,9 @@ func (c *ChannelObserver) GetTrend() (ChannelTrend, ChannelCongestionReason) {
return ChannelTrendNeutral, ChannelCongestionReasonNone
}
func (c *ChannelObserver) ToString() string {
packets, repeatedNacks, nackRatio := c.GetNackRatio()
return fmt.Sprintf("name: %s, estimate: %s, packets: %d, repeatedNacks: %d, nackRatio: %f", c.params.Name, c.estimateTrend.ToString(), packets, repeatedNacks, nackRatio)
}
// ------------------------------------------------
@@ -785,6 +785,9 @@ func (s *StreamAllocator) handleNewEstimateInNonProbe() {
switch reason {
case ChannelCongestionReasonLoss:
estimateToCommit = int64(float64(expectedBandwidthUsage) * (1.0 - NackRatioAttenuator*nackRatio))
if estimateToCommit > s.lastReceivedEstimate {
estimateToCommit = s.lastReceivedEstimate
}
default:
estimateToCommit = s.lastReceivedEstimate
}
@@ -1156,6 +1159,10 @@ func (s *StreamAllocator) initProbe(probeRateBps int64) {
s.probeEndTime = time.Time{}
channelState := ""
if s.channelObserver != nil {
channelState = s.channelObserver.ToString()
}
s.channelObserver = s.newChannelObserverProbe()
s.channelObserver.SeedEstimate(s.lastReceivedEstimate)
@@ -1172,6 +1179,7 @@ func (s *StreamAllocator) initProbe(probeRateBps int64) {
"current usage", expectedBandwidthUsage,
"committed", s.committedChannelCapacity,
"lastReceived", s.lastReceivedEstimate,
"channel", channelState,
"probeRateBps", probeRateBps,
"goalBps", s.probeGoalBps,
)