Revert "Remove Probe and Trendline integration from LossbasedBwe"

This reverts commit 9b3eea8b7cce3439f14971cb0311190c16a2d04f.

Reason for revert: might cause upstream breakages

Original change's description:
> Remove Probe and Trendline integration from LossbasedBwe
>
> These features are not in use.
>
> Bug: webrtc:12707
> Change-Id: Ibe9fcae5e3fd7cb7ca289af80dad8480288c9ba3
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323601
> Commit-Queue: Per Kjellander <perkj@webrtc.org>
> Reviewed-by: Diep Bui <diepbp@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#40938}

Bug: webrtc:12707
Change-Id: I040b25ea8b4e4bf4cbc7cc91c1cd19d6fcfb5ebb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323680
Owners-Override: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#40945}
This commit is contained in:
Jeremy Leconte 2023-10-16 19:09:01 +00:00 committed by WebRTC LUCI CQ
parent aa653c0d76
commit be511490b7
5 changed files with 564 additions and 156 deletions

View File

@ -156,6 +156,7 @@ rtc_library("loss_based_bwe_v2") {
deps = [
"../../../api:array_view",
"../../../api:field_trials_view",
"../../../api:network_state_predictor_api",
"../../../api/transport:network_control",
"../../../api/units:data_rate",
"../../../api/units:data_size",

View File

@ -21,6 +21,7 @@
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/field_trials_view.h"
#include "api/network_state_predictor.h"
#include "api/transport/network_types.h"
#include "api/units/data_rate.h"
#include "api/units/data_size.h"
@ -208,9 +209,18 @@ void LossBasedBweV2::SetMinMaxBitrate(DataRate min_bitrate,
}
}
void LossBasedBweV2::SetProbeBitrate(absl::optional<DataRate> probe_bitrate) {
if (probe_bitrate.has_value() && IsValid(probe_bitrate.value())) {
probe_bitrate_ = probe_bitrate.value();
last_probe_timestamp_ = last_send_time_most_recent_observation_;
}
}
void LossBasedBweV2::UpdateBandwidthEstimate(
rtc::ArrayView<const PacketResult> packet_results,
DataRate delay_based_estimate,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate,
bool in_alr) {
delay_based_estimate_ = delay_based_estimate;
if (!IsEnabled()) {
@ -225,10 +235,12 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
return;
}
if (!PushBackObservation(packet_results)) {
if (!PushBackObservation(packet_results, delay_detector_state)) {
return;
}
SetProbeBitrate(probe_bitrate);
if (!IsValid(current_estimate_.loss_limited_bandwidth)) {
if (!IsValid(delay_based_estimate)) {
RTC_LOG(LS_WARNING) << "The delay based estimate must be finite: "
@ -280,8 +292,10 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
bool increasing_when_loss_limited =
IsEstimateIncreasingWhenLossLimited(best_candidate);
// Bound the best candidate by the acked bitrate.
if (increasing_when_loss_limited && IsValid(acknowledged_bitrate_)) {
// Bound the best candidate by the acked bitrate unless there is a recent
// probe result.
if (increasing_when_loss_limited && !IsValid(probe_bitrate_) &&
IsValid(acknowledged_bitrate_)) {
best_candidate.loss_limited_bandwidth =
IsValid(best_candidate.loss_limited_bandwidth)
? std::min(best_candidate.loss_limited_bandwidth,
@ -301,6 +315,16 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
current_state_ = LossBasedState::kDelayBasedEstimate;
}
// Use probe bitrate as the estimate limit when probes are requested.
if (config_->probe_integration_enabled && IsValid(probe_bitrate_) &&
IsRequestingProbe()) {
if (last_probe_timestamp_ + config_->probe_expiration >=
last_send_time_most_recent_observation_) {
best_candidate.loss_limited_bandwidth =
std::min(probe_bitrate_, best_candidate.loss_limited_bandwidth);
}
}
current_estimate_ = best_candidate;
if (IsBandwidthLimitedDueToLoss() &&
@ -375,6 +399,10 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
0.9);
FieldTrialParameter<double> bandwidth_backoff_lower_bound_factor(
"BwBackoffLowerBoundFactor", 1.0);
FieldTrialParameter<bool> trendline_integration_enabled(
"TrendlineIntegrationEnabled", false);
FieldTrialParameter<int> trendline_observations_window_size(
"TrendlineObservationsWindowSize", 20);
FieldTrialParameter<double> max_increase_factor("MaxIncreaseFactor", 1.3);
FieldTrialParameter<TimeDelta> delayed_increase_window(
"DelayedIncreaseWindow", TimeDelta::Millis(300));
@ -389,6 +417,10 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
"BandwidthCapAtHighLossRate", DataRate::KilobitsPerSec(500.0));
FieldTrialParameter<double> slope_of_bwe_high_loss_func(
"SlopeOfBweHighLossFunc", 1000);
FieldTrialParameter<bool> probe_integration_enabled("ProbeIntegrationEnabled",
false);
FieldTrialParameter<TimeDelta> probe_expiration("ProbeExpiration",
TimeDelta::Seconds(10));
FieldTrialParameter<bool> not_use_acked_rate_in_alr("NotUseAckedRateInAlr",
true);
FieldTrialParameter<bool> use_in_start_phase("UseInStartPhase", false);
@ -418,10 +450,14 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
&instant_upper_bound_loss_offset,
&temporal_weight_factor,
&bandwidth_backoff_lower_bound_factor,
&trendline_integration_enabled,
&trendline_observations_window_size,
&max_increase_factor,
&delayed_increase_window,
&use_acked_bitrate_only_when_overusing,
&not_increase_if_inherent_loss_less_than_average_loss,
&probe_integration_enabled,
&probe_expiration,
&high_loss_rate_threshold,
&bandwidth_cap_at_high_loss_rate,
&slope_of_bwe_high_loss_func,
@ -473,6 +509,9 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
config->temporal_weight_factor = temporal_weight_factor.Get();
config->bandwidth_backoff_lower_bound_factor =
bandwidth_backoff_lower_bound_factor.Get();
config->trendline_integration_enabled = trendline_integration_enabled.Get();
config->trendline_observations_window_size =
trendline_observations_window_size.Get();
config->max_increase_factor = max_increase_factor.Get();
config->delayed_increase_window = delayed_increase_window.Get();
config->use_acked_bitrate_only_when_overusing =
@ -483,6 +522,8 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
config->bandwidth_cap_at_high_loss_rate =
bandwidth_cap_at_high_loss_rate.Get();
config->slope_of_bwe_high_loss_func = slope_of_bwe_high_loss_func.Get();
config->probe_integration_enabled = probe_integration_enabled.Get();
config->probe_expiration = probe_expiration.Get();
config->not_use_acked_rate_in_alr = not_use_acked_rate_in_alr.Get();
config->use_in_start_phase = use_in_start_phase.Get();
@ -649,6 +690,11 @@ bool LossBasedBweV2::IsConfigValid() const {
<< config_->bandwidth_backoff_lower_bound_factor;
valid = false;
}
if (config_->trendline_observations_window_size < 1) {
RTC_LOG(LS_WARNING) << "The trendline window size must be at least 1: "
<< config_->trendline_observations_window_size;
valid = false;
}
if (config_->max_increase_factor <= 0.0) {
RTC_LOG(LS_WARNING) << "The maximum increase factor must be positive: "
<< config_->max_increase_factor;
@ -697,6 +743,15 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const {
candidate_bandwidth_upper_bound = bandwidth_limit_in_current_window_;
}
if (config_->trendline_integration_enabled) {
candidate_bandwidth_upper_bound =
std::min(GetInstantUpperBound(), candidate_bandwidth_upper_bound);
if (IsValid(delay_based_estimate_)) {
candidate_bandwidth_upper_bound =
std::min(delay_based_estimate_, candidate_bandwidth_upper_bound);
}
}
if (!acknowledged_bitrate_.has_value())
return candidate_bandwidth_upper_bound;
@ -718,13 +773,18 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const {
std::vector<LossBasedBweV2::ChannelParameters> LossBasedBweV2::GetCandidates(
bool in_alr) const {
std::vector<DataRate> bandwidths;
bool can_increase_bitrate = TrendlineEsimateAllowBitrateIncrease();
for (double candidate_factor : config_->candidate_factors) {
if (!can_increase_bitrate && candidate_factor > 1.0) {
continue;
}
bandwidths.push_back(candidate_factor *
current_estimate_.loss_limited_bandwidth);
}
if (acknowledged_bitrate_.has_value() &&
config_->append_acknowledged_rate_candidate) {
config_->append_acknowledged_rate_candidate &&
TrendlineEsimateAllowEmergencyBackoff()) {
if (!(config_->not_use_acked_rate_in_alr && in_alr)) {
bandwidths.push_back(*acknowledged_bitrate_ *
config_->bandwidth_backoff_lower_bound_factor);
@ -733,7 +793,8 @@ std::vector<LossBasedBweV2::ChannelParameters> LossBasedBweV2::GetCandidates(
if (IsValid(delay_based_estimate_) &&
config_->append_delay_based_estimate_candidate) {
if (delay_based_estimate_ > current_estimate_.loss_limited_bandwidth) {
if (can_increase_bitrate &&
delay_based_estimate_ > current_estimate_.loss_limited_bandwidth) {
bandwidths.push_back(delay_based_estimate_);
}
}
@ -745,9 +806,14 @@ std::vector<LossBasedBweV2::ChannelParameters> LossBasedBweV2::GetCandidates(
candidates.resize(bandwidths.size());
for (size_t i = 0; i < bandwidths.size(); ++i) {
ChannelParameters candidate = current_estimate_;
candidate.loss_limited_bandwidth = std::min(
bandwidths[i], std::max(current_estimate_.loss_limited_bandwidth,
candidate_bandwidth_upper_bound));
if (config_->trendline_integration_enabled) {
candidate.loss_limited_bandwidth =
std::min(bandwidths[i], candidate_bandwidth_upper_bound);
} else {
candidate.loss_limited_bandwidth = std::min(
bandwidths[i], std::max(current_estimate_.loss_limited_bandwidth,
candidate_bandwidth_upper_bound));
}
candidate.inherent_loss = GetFeasibleInherentLoss(candidate);
candidates[i] = candidate;
}
@ -928,8 +994,47 @@ void LossBasedBweV2::NewtonsMethodUpdate(
}
}
bool LossBasedBweV2::TrendlineEsimateAllowBitrateIncrease() const {
if (!config_->trendline_integration_enabled) {
return true;
}
for (const auto& detector_state : delay_detector_states_) {
if (detector_state == BandwidthUsage::kBwOverusing ||
detector_state == BandwidthUsage::kBwUnderusing) {
return false;
}
}
return true;
}
bool LossBasedBweV2::TrendlineEsimateAllowEmergencyBackoff() const {
if (!config_->trendline_integration_enabled) {
return true;
}
if (!config_->use_acked_bitrate_only_when_overusing) {
return true;
}
for (const auto& detector_state : delay_detector_states_) {
if (detector_state == BandwidthUsage::kBwOverusing) {
return true;
}
}
return false;
}
bool LossBasedBweV2::PushBackObservation(
rtc::ArrayView<const PacketResult> packet_results) {
rtc::ArrayView<const PacketResult> packet_results,
BandwidthUsage delay_detector_state) {
delay_detector_states_.push_front(delay_detector_state);
if (static_cast<int>(delay_detector_states_.size()) >
config_->trendline_observations_window_size) {
delay_detector_states_.pop_back();
}
if (packet_results.empty()) {
return false;
}
@ -953,7 +1058,9 @@ bool LossBasedBweV2::PushBackObservation(
last_send_time - last_send_time_most_recent_observation_;
// Too small to be meaningful.
if (observation_duration <= TimeDelta::Zero() ||
observation_duration < config_->observation_duration_lower_bound) {
(observation_duration < config_->observation_duration_lower_bound &&
(delay_detector_state != BandwidthUsage::kBwOverusing ||
!config_->trendline_integration_enabled))) {
return false;
}
@ -980,4 +1087,8 @@ bool LossBasedBweV2::IsBandwidthLimitedDueToLoss() const {
return current_state_ != LossBasedState::kDelayBasedEstimate;
}
bool LossBasedBweV2::IsRequestingProbe() const {
return current_state_ == LossBasedState::kIncreasing;
}
} // namespace webrtc

View File

@ -11,11 +11,13 @@
#ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_LOSS_BASED_BWE_V2_H_
#define MODULES_CONGESTION_CONTROLLER_GOOG_CC_LOSS_BASED_BWE_V2_H_
#include <deque>
#include <vector>
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/field_trials_view.h"
#include "api/network_state_predictor.h"
#include "api/transport/network_types.h"
#include "api/units/data_rate.h"
#include "api/units/data_size.h"
@ -66,6 +68,8 @@ class LossBasedBweV2 {
void UpdateBandwidthEstimate(
rtc::ArrayView<const PacketResult> packet_results,
DataRate delay_based_estimate,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate,
bool in_alr);
// For unit testing only.
@ -103,6 +107,8 @@ class LossBasedBweV2 {
double instant_upper_bound_loss_offset = 0.0;
double temporal_weight_factor = 0.0;
double bandwidth_backoff_lower_bound_factor = 0.0;
bool trendline_integration_enabled = false;
int trendline_observations_window_size = 0;
double max_increase_factor = 0.0;
TimeDelta delayed_increase_window = TimeDelta::Zero();
bool use_acked_bitrate_only_when_overusing = false;
@ -110,6 +116,8 @@ class LossBasedBweV2 {
double high_loss_rate_threshold = 1.0;
DataRate bandwidth_cap_at_high_loss_rate = DataRate::MinusInfinity();
double slope_of_bwe_high_loss_func = 1000.0;
bool probe_integration_enabled = false;
TimeDelta probe_expiration = TimeDelta::Zero();
bool not_use_acked_rate_in_alr = false;
bool use_in_start_phase = false;
};
@ -157,11 +165,25 @@ class LossBasedBweV2 {
void CalculateTemporalWeights();
void NewtonsMethodUpdate(ChannelParameters& channel_parameters) const;
// Returns false if there exists a kBwOverusing or kBwUnderusing in the
// window.
bool TrendlineEsimateAllowBitrateIncrease() const;
// Returns true if there exists an overusing state in the window.
bool TrendlineEsimateAllowEmergencyBackoff() const;
// Returns false if no observation was created.
bool PushBackObservation(rtc::ArrayView<const PacketResult> packet_results);
bool PushBackObservation(rtc::ArrayView<const PacketResult> packet_results,
BandwidthUsage delay_detector_state);
void UpdateTrendlineEstimator(
const std::vector<PacketResult>& packet_feedbacks,
Timestamp at_time);
void UpdateDelayDetector(BandwidthUsage delay_detector_state);
bool IsEstimateIncreasingWhenLossLimited(
const ChannelParameters& best_candidate);
bool IsBandwidthLimitedDueToLoss() const;
void SetProbeBitrate(absl::optional<DataRate> probe_bitrate);
bool IsRequestingProbe() const;
absl::optional<DataRate> acknowledged_bitrate_;
absl::optional<Config> config_;
@ -174,12 +196,15 @@ class LossBasedBweV2 {
absl::optional<DataRate> cached_instant_upper_bound_;
std::vector<double> instant_upper_bound_temporal_weights_;
std::vector<double> temporal_weights_;
std::deque<BandwidthUsage> delay_detector_states_;
Timestamp recovering_after_loss_timestamp_ = Timestamp::MinusInfinity();
DataRate bandwidth_limit_in_current_window_ = DataRate::PlusInfinity();
DataRate min_bitrate_ = DataRate::KilobitsPerSec(1);
DataRate max_bitrate_ = DataRate::PlusInfinity();
LossBasedState current_state_ = LossBasedState::kDelayBasedEstimate;
DataRate probe_bitrate_ = DataRate::PlusInfinity();
DataRate delay_based_estimate_ = DataRate::PlusInfinity();
Timestamp last_probe_timestamp_ = Timestamp::MinusInfinity();
};
} // namespace webrtc

View File

@ -387,7 +387,8 @@ void SendSideBandwidthEstimation::UpdateLossBasedEstimator(
}
if (LossBasedBandwidthEstimatorV2Enabled()) {
loss_based_bandwidth_estimator_v2_.UpdateBandwidthEstimate(
report.packet_feedbacks, delay_based_limit_, in_alr);
report.packet_feedbacks, delay_based_limit_, delay_detector_state,
probe_bitrate, in_alr);
UpdateEstimate(report.feedback_time);
}
}