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

Side by Side Diff: webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc

Issue 2306963002: Only log BWE updates if the actual estimate changed or if we have non-zero loss reports. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: . Created 4 years, 3 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 11 matching lines...) Expand all
22 namespace webrtc { 22 namespace webrtc {
23 namespace { 23 namespace {
24 const int64_t kBweIncreaseIntervalMs = 1000; 24 const int64_t kBweIncreaseIntervalMs = 1000;
25 const int64_t kBweDecreaseIntervalMs = 300; 25 const int64_t kBweDecreaseIntervalMs = 300;
26 const int64_t kStartPhaseMs = 2000; 26 const int64_t kStartPhaseMs = 2000;
27 const int64_t kBweConverganceTimeMs = 20000; 27 const int64_t kBweConverganceTimeMs = 20000;
28 const int kLimitNumPackets = 20; 28 const int kLimitNumPackets = 20;
29 const int kDefaultMinBitrateBps = 10000; 29 const int kDefaultMinBitrateBps = 10000;
30 const int kDefaultMaxBitrateBps = 1000000000; 30 const int kDefaultMaxBitrateBps = 1000000000;
31 const int64_t kLowBitrateLogPeriodMs = 10000; 31 const int64_t kLowBitrateLogPeriodMs = 10000;
32 const int64_t kRtcEventLogPeriodMs = 5000;
32 33
33 struct UmaRampUpMetric { 34 struct UmaRampUpMetric {
34 const char* metric_name; 35 const char* metric_name;
35 int bitrate_kbps; 36 int bitrate_kbps;
36 }; 37 };
37 38
38 const UmaRampUpMetric kUmaRampupMetrics[] = { 39 const UmaRampUpMetric kUmaRampupMetrics[] = {
39 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, 40 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500},
40 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, 41 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000},
41 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; 42 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}};
42 const size_t kNumUmaRampupMetrics = 43 const size_t kNumUmaRampupMetrics =
43 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]); 44 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]);
44 45
45 } // namespace 46 } // namespace
46 47
47 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) 48 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
48 : lost_packets_since_last_loss_update_Q8_(0), 49 : lost_packets_since_last_loss_update_Q8_(0),
49 expected_packets_since_last_loss_update_(0), 50 expected_packets_since_last_loss_update_(0),
50 bitrate_(0), 51 bitrate_(0),
51 min_bitrate_configured_(kDefaultMinBitrateBps), 52 min_bitrate_configured_(kDefaultMinBitrateBps),
52 max_bitrate_configured_(kDefaultMaxBitrateBps), 53 max_bitrate_configured_(kDefaultMaxBitrateBps),
53 last_low_bitrate_log_ms_(-1), 54 last_low_bitrate_log_ms_(-1),
54 has_decreased_since_last_fraction_loss_(false), 55 has_decreased_since_last_fraction_loss_(false),
55 time_last_receiver_block_ms_(-1), 56 time_last_receiver_block_ms_(-1),
56 last_fraction_loss_(0), 57 last_fraction_loss_(0),
58 last_logged_fraction_loss_(0),
57 last_round_trip_time_ms_(0), 59 last_round_trip_time_ms_(0),
58 bwe_incoming_(0), 60 bwe_incoming_(0),
59 delay_based_bitrate_bps_(0), 61 delay_based_bitrate_bps_(0),
60 time_last_decrease_ms_(0), 62 time_last_decrease_ms_(0),
61 first_report_time_ms_(-1), 63 first_report_time_ms_(-1),
62 initially_lost_packets_(0), 64 initially_lost_packets_(0),
63 bitrate_at_2_seconds_kbps_(0), 65 bitrate_at_2_seconds_kbps_(0),
64 uma_update_state_(kNoUpdate), 66 uma_update_state_(kNoUpdate),
65 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), 67 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false),
66 event_log_(event_log) { 68 event_log_(event_log),
69 last_rtc_event_log_ms_(-1) {
67 RTC_DCHECK(event_log); 70 RTC_DCHECK(event_log);
68 } 71 }
69 72
70 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} 73 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {}
71 74
72 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate, 75 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate,
73 int min_bitrate, 76 int min_bitrate,
74 int max_bitrate) { 77 int max_bitrate) {
75 if (send_bitrate > 0) 78 if (send_bitrate > 0)
76 SetSendBitrate(send_bitrate); 79 SetSendBitrate(send_bitrate);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // whenever a receiver report is received with lower packet loss. 224 // whenever a receiver report is received with lower packet loss.
222 // If instead one would do: bitrate_ *= 1.08^(delta time), it would 225 // If instead one would do: bitrate_ *= 1.08^(delta time), it would
223 // take over one second since the lower packet loss to achieve 108kbps. 226 // take over one second since the lower packet loss to achieve 108kbps.
224 bitrate_ = static_cast<uint32_t>( 227 bitrate_ = static_cast<uint32_t>(
225 min_bitrate_history_.front().second * 1.08 + 0.5); 228 min_bitrate_history_.front().second * 1.08 + 0.5);
226 229
227 // Add 1 kbps extra, just to make sure that we do not get stuck 230 // Add 1 kbps extra, just to make sure that we do not get stuck
228 // (gives a little extra increase at low rates, negligible at higher 231 // (gives a little extra increase at low rates, negligible at higher
229 // rates). 232 // rates).
230 bitrate_ += 1000; 233 bitrate_ += 1000;
231
232 event_log_->LogBwePacketLossEvent(
233 bitrate_, last_fraction_loss_,
234 expected_packets_since_last_loss_update_);
235 } else if (last_fraction_loss_ <= 26) { 234 } else if (last_fraction_loss_ <= 26) {
236 // Loss between 2% - 10%: Do nothing. 235 // Loss between 2% - 10%: Do nothing.
237 } else { 236 } else {
238 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + 237 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs +
239 // rtt. 238 // rtt.
240 if (!has_decreased_since_last_fraction_loss_ && 239 if (!has_decreased_since_last_fraction_loss_ &&
241 (now_ms - time_last_decrease_ms_) >= 240 (now_ms - time_last_decrease_ms_) >=
242 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { 241 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) {
243 time_last_decrease_ms_ = now_ms; 242 time_last_decrease_ms_ = now_ms;
244 243
245 // Reduce rate: 244 // Reduce rate:
246 // newRate = rate * (1 - 0.5*lossRate); 245 // newRate = rate * (1 - 0.5*lossRate);
247 // where packetLoss = 256*lossRate; 246 // where packetLoss = 256*lossRate;
248 bitrate_ = static_cast<uint32_t>( 247 bitrate_ = static_cast<uint32_t>(
249 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) / 248 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) /
250 512.0); 249 512.0);
251 has_decreased_since_last_fraction_loss_ = true; 250 has_decreased_since_last_fraction_loss_ = true;
252 } 251 }
253 event_log_->LogBwePacketLossEvent(
254 bitrate_, last_fraction_loss_,
255 expected_packets_since_last_loss_update_);
256 } 252 }
257 } 253 }
258 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); 254 uint32_t capped_bitrate = CapBitrateToThresholds(now_ms, bitrate_);
255 if (capped_bitrate != bitrate_ ||
256 last_fraction_loss_ != last_logged_fraction_loss_ ||
257 last_rtc_event_log_ms_ == -1 ||
258 now_ms - last_rtc_event_log_ms_ > kRtcEventLogPeriodMs) {
259 event_log_->LogBwePacketLossEvent(capped_bitrate, last_fraction_loss_,
260 expected_packets_since_last_loss_update_);
261 last_logged_fraction_loss_ = last_fraction_loss_;
262 last_rtc_event_log_ms_ = now_ms;
263 }
264 bitrate_ = capped_bitrate;
259 } 265 }
260 266
261 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { 267 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const {
262 return first_report_time_ms_ == -1 || 268 return first_report_time_ms_ == -1 ||
263 now_ms - first_report_time_ms_ < kStartPhaseMs; 269 now_ms - first_report_time_ms_ < kStartPhaseMs;
264 } 270 }
265 271
266 void SendSideBandwidthEstimation::UpdateMinHistory(int64_t now_ms) { 272 void SendSideBandwidthEstimation::UpdateMinHistory(int64_t now_ms) {
267 // Remove old data points from history. 273 // Remove old data points from history.
268 // Since history precision is in ms, add one so it is able to increase 274 // Since history precision is in ms, add one so it is able to increase
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 306 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000
301 << " kbps is below configured min bitrate " 307 << " kbps is below configured min bitrate "
302 << min_bitrate_configured_ / 1000 << " kbps."; 308 << min_bitrate_configured_ / 1000 << " kbps.";
303 last_low_bitrate_log_ms_ = now_ms; 309 last_low_bitrate_log_ms_ = now_ms;
304 } 310 }
305 bitrate = min_bitrate_configured_; 311 bitrate = min_bitrate_configured_;
306 } 312 }
307 return bitrate; 313 return bitrate;
308 } 314 }
309 } // namespace webrtc 315 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698