Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.cc

Issue 2791743002: Revert of Enable trendline experiment and bayesian bitrate estimator experiment by default. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 24 matching lines...) Expand all
35 kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift; 35 kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift;
36 constexpr double kTimestampToMs = 36 constexpr double kTimestampToMs =
37 1000.0 / static_cast<double>(1 << kInterArrivalShift); 37 1000.0 / static_cast<double>(1 << kInterArrivalShift);
38 // This ssrc is used to fulfill the current API but will be removed 38 // This ssrc is used to fulfill the current API but will be removed
39 // after the API has been changed. 39 // after the API has been changed.
40 constexpr uint32_t kFixedSsrc = 0; 40 constexpr uint32_t kFixedSsrc = 0;
41 constexpr int kInitialRateWindowMs = 500; 41 constexpr int kInitialRateWindowMs = 500;
42 constexpr int kRateWindowMs = 150; 42 constexpr int kRateWindowMs = 150;
43 43
44 // Parameters for linear least squares fit of regression line to noisy data. 44 // Parameters for linear least squares fit of regression line to noisy data.
45 constexpr size_t kDefaultTrendlineWindowSize = 20; 45 constexpr size_t kDefaultTrendlineWindowSize = 15;
46 constexpr double kDefaultTrendlineSmoothingCoeff = 0.9; 46 constexpr double kDefaultTrendlineSmoothingCoeff = 0.9;
47 constexpr double kDefaultTrendlineThresholdGain = 4.0; 47 constexpr double kDefaultTrendlineThresholdGain = 4.0;
48 48
49 // Parameters for Theil-Sen robust fitting of line to noisy data.
50 constexpr size_t kDefaultMedianSlopeWindowSize = 20;
51 constexpr double kDefaultMedianSlopeThresholdGain = 4.0;
52
49 constexpr int kMaxConsecutiveFailedLookups = 5; 53 constexpr int kMaxConsecutiveFailedLookups = 5;
50 54
55 const char kBitrateEstimateExperiment[] = "WebRTC-ImprovedBitrateEstimate";
56 const char kBweTrendlineFilterExperiment[] = "WebRTC-BweTrendlineFilter";
57 const char kBweMedianSlopeFilterExperiment[] = "WebRTC-BweMedianSlopeFilter";
58
59 bool BitrateEstimateExperimentIsEnabled() {
60 return webrtc::field_trial::IsEnabled(kBitrateEstimateExperiment);
61 }
62
63 bool TrendlineFilterExperimentIsEnabled() {
64 std::string experiment_string =
65 webrtc::field_trial::FindFullName(kBweTrendlineFilterExperiment);
66 // The experiment is enabled iff the field trial string begins with "Enabled".
67 return experiment_string.find("Enabled") == 0;
68 }
69
70 bool MedianSlopeFilterExperimentIsEnabled() {
71 std::string experiment_string =
72 webrtc::field_trial::FindFullName(kBweMedianSlopeFilterExperiment);
73 // The experiment is enabled iff the field trial string begins with "Enabled".
74 return experiment_string.find("Enabled") == 0;
75 }
76
77 bool ReadTrendlineFilterExperimentParameters(size_t* window_size,
78 double* smoothing_coef,
79 double* threshold_gain) {
80 RTC_DCHECK(TrendlineFilterExperimentIsEnabled());
81 RTC_DCHECK(!MedianSlopeFilterExperimentIsEnabled());
82 RTC_DCHECK(window_size != nullptr);
83 RTC_DCHECK(smoothing_coef != nullptr);
84 RTC_DCHECK(threshold_gain != nullptr);
85 std::string experiment_string =
86 webrtc::field_trial::FindFullName(kBweTrendlineFilterExperiment);
87 int parsed_values = sscanf(experiment_string.c_str(), "Enabled-%zu,%lf,%lf",
88 window_size, smoothing_coef, threshold_gain);
89 if (parsed_values == 3) {
90 RTC_CHECK_GT(*window_size, 1) << "Need at least 2 points to fit a line.";
91 RTC_CHECK(0 <= *smoothing_coef && *smoothing_coef <= 1)
92 << "Coefficient needs to be between 0 and 1 for weighted average.";
93 RTC_CHECK_GT(*threshold_gain, 0) << "Threshold gain needs to be positive.";
94 return true;
95 }
96 LOG(LS_WARNING) << "Failed to parse parameters for BweTrendlineFilter "
97 "experiment from field trial string. Using default.";
98 *window_size = kDefaultTrendlineWindowSize;
99 *smoothing_coef = kDefaultTrendlineSmoothingCoeff;
100 *threshold_gain = kDefaultTrendlineThresholdGain;
101 return false;
102 }
103
104 bool ReadMedianSlopeFilterExperimentParameters(size_t* window_size,
105 double* threshold_gain) {
106 RTC_DCHECK(!TrendlineFilterExperimentIsEnabled());
107 RTC_DCHECK(MedianSlopeFilterExperimentIsEnabled());
108 RTC_DCHECK(window_size != nullptr);
109 RTC_DCHECK(threshold_gain != nullptr);
110 std::string experiment_string =
111 webrtc::field_trial::FindFullName(kBweMedianSlopeFilterExperiment);
112 int parsed_values = sscanf(experiment_string.c_str(), "Enabled-%zu,%lf",
113 window_size, threshold_gain);
114 if (parsed_values == 2) {
115 RTC_CHECK_GT(*window_size, 1) << "Need at least 2 points to fit a line.";
116 RTC_CHECK_GT(*threshold_gain, 0) << "Threshold gain needs to be positive.";
117 return true;
118 }
119 LOG(LS_WARNING) << "Failed to parse parameters for BweMedianSlopeFilter "
120 "experiment from field trial string. Using default.";
121 *window_size = kDefaultMedianSlopeWindowSize;
122 *threshold_gain = kDefaultMedianSlopeThresholdGain;
123 return false;
124 }
51 125
52 class PacketFeedbackComparator { 126 class PacketFeedbackComparator {
53 public: 127 public:
54 inline bool operator()(const webrtc::PacketFeedback& lhs, 128 inline bool operator()(const webrtc::PacketFeedback& lhs,
55 const webrtc::PacketFeedback& rhs) { 129 const webrtc::PacketFeedback& rhs) {
56 if (lhs.arrival_time_ms != rhs.arrival_time_ms) 130 if (lhs.arrival_time_ms != rhs.arrival_time_ms)
57 return lhs.arrival_time_ms < rhs.arrival_time_ms; 131 return lhs.arrival_time_ms < rhs.arrival_time_ms;
58 if (lhs.send_time_ms != rhs.send_time_ms) 132 if (lhs.send_time_ms != rhs.send_time_ms)
59 return lhs.send_time_ms < rhs.send_time_ms; 133 return lhs.send_time_ms < rhs.send_time_ms;
60 return lhs.sequence_number < rhs.sequence_number; 134 return lhs.sequence_number < rhs.sequence_number;
(...skipping 11 matching lines...) Expand all
72 } 146 }
73 } // namespace 147 } // namespace
74 148
75 namespace webrtc { 149 namespace webrtc {
76 150
77 DelayBasedBwe::BitrateEstimator::BitrateEstimator() 151 DelayBasedBwe::BitrateEstimator::BitrateEstimator()
78 : sum_(0), 152 : sum_(0),
79 current_win_ms_(0), 153 current_win_ms_(0),
80 prev_time_ms_(-1), 154 prev_time_ms_(-1),
81 bitrate_estimate_(-1.0f), 155 bitrate_estimate_(-1.0f),
82 bitrate_estimate_var_(50.0f) {} 156 bitrate_estimate_var_(50.0f),
157 old_estimator_(kBitrateWindowMs, 8000),
158 in_experiment_(BitrateEstimateExperimentIsEnabled()) {}
83 159
84 void DelayBasedBwe::BitrateEstimator::Update(int64_t now_ms, int bytes) { 160 void DelayBasedBwe::BitrateEstimator::Update(int64_t now_ms, int bytes) {
161 if (!in_experiment_) {
162 old_estimator_.Update(bytes, now_ms);
163 rtc::Optional<uint32_t> rate = old_estimator_.Rate(now_ms);
164 bitrate_estimate_ = -1.0f;
165 if (rate)
166 bitrate_estimate_ = *rate / 1000.0f;
167 return;
168 }
85 int rate_window_ms = kRateWindowMs; 169 int rate_window_ms = kRateWindowMs;
86 // We use a larger window at the beginning to get a more stable sample that 170 // We use a larger window at the beginning to get a more stable sample that
87 // we can use to initialize the estimate. 171 // we can use to initialize the estimate.
88 if (bitrate_estimate_ < 0.f) 172 if (bitrate_estimate_ < 0.f)
89 rate_window_ms = kInitialRateWindowMs; 173 rate_window_ms = kInitialRateWindowMs;
90 float bitrate_sample = UpdateWindow(now_ms, bytes, rate_window_ms); 174 float bitrate_sample = UpdateWindow(now_ms, bytes, rate_window_ms);
91 if (bitrate_sample < 0.0f) 175 if (bitrate_sample < 0.0f)
92 return; 176 return;
93 if (bitrate_estimate_ < 0.0f) { 177 if (bitrate_estimate_ < 0.0f) {
94 // This is the very first sample we get. Use it to initialize the estimate. 178 // This is the very first sample we get. Use it to initialize the estimate.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return bitrate_sample; 224 return bitrate_sample;
141 } 225 }
142 226
143 rtc::Optional<uint32_t> DelayBasedBwe::BitrateEstimator::bitrate_bps() const { 227 rtc::Optional<uint32_t> DelayBasedBwe::BitrateEstimator::bitrate_bps() const {
144 if (bitrate_estimate_ < 0.f) 228 if (bitrate_estimate_ < 0.f)
145 return rtc::Optional<uint32_t>(); 229 return rtc::Optional<uint32_t>();
146 return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000); 230 return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000);
147 } 231 }
148 232
149 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, const Clock* clock) 233 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, const Clock* clock)
150 : event_log_(event_log), 234 : in_trendline_experiment_(TrendlineFilterExperimentIsEnabled()),
235 in_median_slope_experiment_(MedianSlopeFilterExperimentIsEnabled()),
236 event_log_(event_log),
151 clock_(clock), 237 clock_(clock),
152 inter_arrival_(), 238 inter_arrival_(),
239 kalman_estimator_(),
153 trendline_estimator_(), 240 trendline_estimator_(),
154 detector_(), 241 detector_(),
155 receiver_incoming_bitrate_(), 242 receiver_incoming_bitrate_(),
156 last_update_ms_(-1), 243 last_update_ms_(-1),
157 last_seen_packet_ms_(-1), 244 last_seen_packet_ms_(-1),
158 uma_recorded_(false), 245 uma_recorded_(false),
159 probe_bitrate_estimator_(event_log), 246 probe_bitrate_estimator_(event_log),
160 trendline_window_size_(kDefaultTrendlineWindowSize), 247 trendline_window_size_(kDefaultTrendlineWindowSize),
161 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), 248 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff),
162 trendline_threshold_gain_(kDefaultTrendlineThresholdGain), 249 trendline_threshold_gain_(kDefaultTrendlineThresholdGain),
163 probing_interval_estimator_(&rate_control_), 250 probing_interval_estimator_(&rate_control_),
251 median_slope_window_size_(kDefaultMedianSlopeWindowSize),
252 median_slope_threshold_gain_(kDefaultMedianSlopeThresholdGain),
164 consecutive_delayed_feedbacks_(0), 253 consecutive_delayed_feedbacks_(0),
165 last_logged_bitrate_(0), 254 last_logged_bitrate_(0),
166 last_logged_state_(kBwNormal) { 255 last_logged_state_(kBwNormal) {
167 LOG(LS_INFO) << "Using Trendline filter for delay change estimation."; 256 if (in_trendline_experiment_) {
257 ReadTrendlineFilterExperimentParameters(&trendline_window_size_,
258 &trendline_smoothing_coeff_,
259 &trendline_threshold_gain_);
260 LOG(LS_INFO) << "Trendline filter experiment enabled with parameters "
261 << trendline_window_size_ << ',' << trendline_smoothing_coeff_
262 << ',' << trendline_threshold_gain_;
263 }
264 if (in_median_slope_experiment_) {
265 ReadMedianSlopeFilterExperimentParameters(&median_slope_window_size_,
266 &median_slope_threshold_gain_);
267 LOG(LS_INFO) << "Median-slope filter experiment enabled with parameters "
268 << median_slope_window_size_ << ','
269 << median_slope_threshold_gain_;
270 }
271 if (!in_trendline_experiment_ && !in_median_slope_experiment_) {
272 LOG(LS_INFO) << "No overuse experiment enabled. Using Kalman filter.";
273 }
168 274
169 network_thread_.DetachFromThread(); 275 network_thread_.DetachFromThread();
170 } 276 }
171 277
172 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( 278 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector(
173 const std::vector<PacketFeedback>& packet_feedback_vector) { 279 const std::vector<PacketFeedback>& packet_feedback_vector) {
174 RTC_DCHECK(network_thread_.CalledOnValidThread()); 280 RTC_DCHECK(network_thread_.CalledOnValidThread());
175 RTC_DCHECK(!packet_feedback_vector.empty()); 281 RTC_DCHECK(!packet_feedback_vector.empty());
176 282
177 std::vector<PacketFeedback> sorted_packet_feedback_vector; 283 std::vector<PacketFeedback> sorted_packet_feedback_vector;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 336
231 receiver_incoming_bitrate_.Update(packet_feedback.arrival_time_ms, 337 receiver_incoming_bitrate_.Update(packet_feedback.arrival_time_ms,
232 packet_feedback.payload_size); 338 packet_feedback.payload_size);
233 Result result; 339 Result result;
234 // Reset if the stream has timed out. 340 // Reset if the stream has timed out.
235 if (last_seen_packet_ms_ == -1 || 341 if (last_seen_packet_ms_ == -1 ||
236 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { 342 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) {
237 inter_arrival_.reset( 343 inter_arrival_.reset(
238 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000, 344 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000,
239 kTimestampToMs, true)); 345 kTimestampToMs, true));
346 kalman_estimator_.reset(new OveruseEstimator(OverUseDetectorOptions()));
240 trendline_estimator_.reset(new TrendlineEstimator( 347 trendline_estimator_.reset(new TrendlineEstimator(
241 trendline_window_size_, trendline_smoothing_coeff_, 348 trendline_window_size_, trendline_smoothing_coeff_,
242 trendline_threshold_gain_)); 349 trendline_threshold_gain_));
350 median_slope_estimator_.reset(new MedianSlopeEstimator(
351 median_slope_window_size_, median_slope_threshold_gain_));
243 } 352 }
244 last_seen_packet_ms_ = now_ms; 353 last_seen_packet_ms_ = now_ms;
245 354
246 uint32_t send_time_24bits = 355 uint32_t send_time_24bits =
247 static_cast<uint32_t>( 356 static_cast<uint32_t>(
248 ((static_cast<uint64_t>(packet_feedback.send_time_ms) 357 ((static_cast<uint64_t>(packet_feedback.send_time_ms)
249 << kAbsSendTimeFraction) + 358 << kAbsSendTimeFraction) +
250 500) / 359 500) /
251 1000) & 360 1000) &
252 0x00FFFFFF; 361 0x00FFFFFF;
253 // Shift up send time to use the full 32 bits that inter_arrival works with, 362 // Shift up send time to use the full 32 bits that inter_arrival works with,
254 // so wrapping works properly. 363 // so wrapping works properly.
255 uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift; 364 uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift;
256 365
257 uint32_t ts_delta = 0; 366 uint32_t ts_delta = 0;
258 int64_t t_delta = 0; 367 int64_t t_delta = 0;
259 int size_delta = 0; 368 int size_delta = 0;
260 if (inter_arrival_->ComputeDeltas(timestamp, packet_feedback.arrival_time_ms, 369 if (inter_arrival_->ComputeDeltas(timestamp, packet_feedback.arrival_time_ms,
261 now_ms, packet_feedback.payload_size, 370 now_ms, packet_feedback.payload_size,
262 &ts_delta, &t_delta, &size_delta)) { 371 &ts_delta, &t_delta, &size_delta)) {
263 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift); 372 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift);
264 trendline_estimator_->Update(t_delta, ts_delta_ms, 373 if (in_trendline_experiment_) {
265 packet_feedback.arrival_time_ms); 374 trendline_estimator_->Update(t_delta, ts_delta_ms,
266 detector_.Detect(trendline_estimator_->trendline_slope(), ts_delta_ms, 375 packet_feedback.arrival_time_ms);
267 trendline_estimator_->num_of_deltas(), 376 detector_.Detect(trendline_estimator_->trendline_slope(), ts_delta_ms,
268 packet_feedback.arrival_time_ms); 377 trendline_estimator_->num_of_deltas(),
378 packet_feedback.arrival_time_ms);
379 } else if (in_median_slope_experiment_) {
380 median_slope_estimator_->Update(t_delta, ts_delta_ms,
381 packet_feedback.arrival_time_ms);
382 detector_.Detect(median_slope_estimator_->trendline_slope(), ts_delta_ms,
383 median_slope_estimator_->num_of_deltas(),
384 packet_feedback.arrival_time_ms);
385 } else {
386 kalman_estimator_->Update(t_delta, ts_delta_ms, size_delta,
387 detector_.State(),
388 packet_feedback.arrival_time_ms);
389 detector_.Detect(kalman_estimator_->offset(), ts_delta_ms,
390 kalman_estimator_->num_of_deltas(),
391 packet_feedback.arrival_time_ms);
392 }
269 } 393 }
270 394
271 int probing_bps = 0; 395 int probing_bps = 0;
272 if (packet_feedback.pacing_info.probe_cluster_id != 396 if (packet_feedback.pacing_info.probe_cluster_id !=
273 PacedPacketInfo::kNotAProbe) { 397 PacedPacketInfo::kNotAProbe) {
274 probing_bps = 398 probing_bps =
275 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback); 399 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback);
276 } 400 }
277 rtc::Optional<uint32_t> acked_bitrate_bps = 401 rtc::Optional<uint32_t> acked_bitrate_bps =
278 receiver_incoming_bitrate_.bitrate_bps(); 402 receiver_incoming_bitrate_.bitrate_bps();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { 479 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) {
356 // Called from both the configuration thread and the network thread. Shouldn't 480 // Called from both the configuration thread and the network thread. Shouldn't
357 // be called from the network thread in the future. 481 // be called from the network thread in the future.
358 rate_control_.SetMinBitrate(min_bitrate_bps); 482 rate_control_.SetMinBitrate(min_bitrate_bps);
359 } 483 }
360 484
361 int64_t DelayBasedBwe::GetProbingIntervalMs() const { 485 int64_t DelayBasedBwe::GetProbingIntervalMs() const {
362 return probing_interval_estimator_.GetIntervalMs(); 486 return probing_interval_estimator_.GetIntervalMs();
363 } 487 }
364 } // namespace webrtc 488 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698