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

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

Issue 2654473002: Remove static locals from histograms. (Closed)
Patch Set: use another HistogramBase constructor for enumerations Created 3 years, 10 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 16 matching lines...) Expand all
27 const int64_t kStartPhaseMs = 2000; 27 const int64_t kStartPhaseMs = 2000;
28 const int64_t kBweConverganceTimeMs = 20000; 28 const int64_t kBweConverganceTimeMs = 20000;
29 const int kLimitNumPackets = 20; 29 const int kLimitNumPackets = 20;
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 const int64_t kRtcEventLogPeriodMs = 5000;
33 // Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals. 33 // Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals.
34 const int64_t kFeedbackIntervalMs = 1500; 34 const int64_t kFeedbackIntervalMs = 1500;
35 const int64_t kFeedbackTimeoutIntervals = 3; 35 const int64_t kFeedbackTimeoutIntervals = 3;
36 const int64_t kTimeoutIntervalMs = 1000; 36 const int64_t kTimeoutIntervalMs = 1000;
37
38 struct UmaRampUpMetric {
39 const char* metric_name;
40 int bitrate_kbps;
41 };
42
43 const UmaRampUpMetric kUmaRampupMetrics[] = {
44 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500},
45 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000},
46 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}};
47 const size_t kNumUmaRampupMetrics =
48 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]);
49
50 } // namespace 37 } // namespace
51 38
52 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) 39 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
53 : lost_packets_since_last_loss_update_Q8_(0), 40 : rampup_histograms_{
41 {rtc::Histogram("WebRTC.BWE.RampUpTimeTo500kbpsInMs", 100000), 500},
42 {rtc::Histogram("WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 100000), 1000},
43 {rtc::Histogram("WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 100000), 2000},
44 },
45 initially_lost_packets_histogram_(
46 rtc::Histogram("WebRTC.BWE.InitiallyLostPackets", 0, 100)),
47 initial_rtt_histogram_(rtc::Histogram("WebRTC.BWE.InitialRtt", 0, 2000)),
48 initial_bwe_histogram_(
49 rtc::Histogram("WebRTC.BWE.InitialBandwidthEstimate", 0, 2000)),
50 initial_vs_converged_diff_histogram_(
51 rtc::Histogram("WebRTC.BWE.InitialVsConvergedDiff", 0, 2000)),
52 lost_packets_since_last_loss_update_Q8_(0),
54 expected_packets_since_last_loss_update_(0), 53 expected_packets_since_last_loss_update_(0),
55 bitrate_(0), 54 bitrate_(0),
56 min_bitrate_configured_(congestion_controller::GetMinBitrateBps()), 55 min_bitrate_configured_(congestion_controller::GetMinBitrateBps()),
57 max_bitrate_configured_(kDefaultMaxBitrateBps), 56 max_bitrate_configured_(kDefaultMaxBitrateBps),
58 last_low_bitrate_log_ms_(-1), 57 last_low_bitrate_log_ms_(-1),
59 has_decreased_since_last_fraction_loss_(false), 58 has_decreased_since_last_fraction_loss_(false),
60 last_feedback_ms_(-1), 59 last_feedback_ms_(-1),
61 last_packet_report_ms_(-1), 60 last_packet_report_ms_(-1),
62 last_timeout_ms_(-1), 61 last_timeout_ms_(-1),
63 last_fraction_loss_(0), 62 last_fraction_loss_(0),
64 last_logged_fraction_loss_(0), 63 last_logged_fraction_loss_(0),
65 last_round_trip_time_ms_(0), 64 last_round_trip_time_ms_(0),
66 bwe_incoming_(0), 65 bwe_incoming_(0),
67 delay_based_bitrate_bps_(0), 66 delay_based_bitrate_bps_(0),
68 time_last_decrease_ms_(0), 67 time_last_decrease_ms_(0),
69 first_report_time_ms_(-1), 68 first_report_time_ms_(-1),
70 initially_lost_packets_(0), 69 initially_lost_packets_(0),
71 bitrate_at_2_seconds_kbps_(0), 70 bitrate_at_2_seconds_kbps_(0),
72 uma_update_state_(kNoUpdate), 71 uma_update_state_(kNoUpdate),
73 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), 72 rampup_uma_stats_updated_(
73 sizeof(rampup_histograms_) / sizeof(*rampup_histograms_),
74 false),
74 event_log_(event_log), 75 event_log_(event_log),
75 last_rtc_event_log_ms_(-1), 76 last_rtc_event_log_ms_(-1),
76 in_timeout_experiment_(webrtc::field_trial::FindFullName( 77 in_timeout_experiment_(webrtc::field_trial::FindFullName(
77 "WebRTC-FeedbackTimeout") == "Enabled") { 78 "WebRTC-FeedbackTimeout") == "Enabled") {
78 RTC_DCHECK(event_log); 79 RTC_DCHECK(event_log);
79 } 80 }
80 81
81 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} 82 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {}
82 83
83 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate, 84 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 last_packet_report_ms_ = now_ms; 169 last_packet_report_ms_ = now_ms;
169 UpdateEstimate(now_ms); 170 UpdateEstimate(now_ms);
170 } 171 }
171 UpdateUmaStats(now_ms, rtt, (fraction_loss * number_of_packets) >> 8); 172 UpdateUmaStats(now_ms, rtt, (fraction_loss * number_of_packets) >> 8);
172 } 173 }
173 174
174 void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms, 175 void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms,
175 int64_t rtt, 176 int64_t rtt,
176 int lost_packets) { 177 int lost_packets) {
177 int bitrate_kbps = static_cast<int>((bitrate_ + 500) / 1000); 178 int bitrate_kbps = static_cast<int>((bitrate_ + 500) / 1000);
178 for (size_t i = 0; i < kNumUmaRampupMetrics; ++i) { 179 for (size_t i = 0; i < rampup_uma_stats_updated_.size(); ++i) {
179 if (!rampup_uma_stats_updated_[i] && 180 if (!rampup_uma_stats_updated_[i] &&
180 bitrate_kbps >= kUmaRampupMetrics[i].bitrate_kbps) { 181 bitrate_kbps >= rampup_histograms_[i].bitrate_kbps) {
181 RTC_HISTOGRAMS_COUNTS_100000(i, kUmaRampupMetrics[i].metric_name, 182 rampup_histograms_[i].histogram.AddSample(now_ms - first_report_time_ms_);
182 now_ms - first_report_time_ms_);
183 rampup_uma_stats_updated_[i] = true; 183 rampup_uma_stats_updated_[i] = true;
184 } 184 }
185 } 185 }
186 if (IsInStartPhase(now_ms)) { 186 if (IsInStartPhase(now_ms)) {
187 initially_lost_packets_ += lost_packets; 187 initially_lost_packets_ += lost_packets;
188 } else if (uma_update_state_ == kNoUpdate) { 188 } else if (uma_update_state_ == kNoUpdate) {
189 uma_update_state_ = kFirstDone; 189 uma_update_state_ = kFirstDone;
190 bitrate_at_2_seconds_kbps_ = bitrate_kbps; 190 bitrate_at_2_seconds_kbps_ = bitrate_kbps;
191 RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitiallyLostPackets", 191 initially_lost_packets_histogram_.AddSample(initially_lost_packets_);
192 initially_lost_packets_, 0, 100, 50); 192 initial_rtt_histogram_.AddSample(static_cast<int>(rtt));
193 RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialRtt", static_cast<int>(rtt), 0, 193 initial_bwe_histogram_.AddSample(bitrate_at_2_seconds_kbps_);
194 2000, 50);
195 RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialBandwidthEstimate",
196 bitrate_at_2_seconds_kbps_, 0, 2000, 50);
197 } else if (uma_update_state_ == kFirstDone && 194 } else if (uma_update_state_ == kFirstDone &&
198 now_ms - first_report_time_ms_ >= kBweConverganceTimeMs) { 195 now_ms - first_report_time_ms_ >= kBweConverganceTimeMs) {
199 uma_update_state_ = kDone; 196 uma_update_state_ = kDone;
200 int bitrate_diff_kbps = 197 int bitrate_diff_kbps =
201 std::max(bitrate_at_2_seconds_kbps_ - bitrate_kbps, 0); 198 std::max(bitrate_at_2_seconds_kbps_ - bitrate_kbps, 0);
202 RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialVsConvergedDiff", bitrate_diff_kbps, 199 initial_vs_converged_diff_histogram_.AddSample(bitrate_diff_kbps);
203 0, 2000, 50);
204 } 200 }
205 } 201 }
206 202
207 void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { 203 void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) {
208 // We trust the REMB and/or delay-based estimate during the first 2 seconds if 204 // We trust the REMB and/or delay-based estimate during the first 2 seconds if
209 // we haven't had any packet loss reported, to allow startup bitrate probing. 205 // we haven't had any packet loss reported, to allow startup bitrate probing.
210 if (last_fraction_loss_ == 0 && IsInStartPhase(now_ms)) { 206 if (last_fraction_loss_ == 0 && IsInStartPhase(now_ms)) {
211 uint32_t prev_bitrate = bitrate_; 207 uint32_t prev_bitrate = bitrate_;
212 if (bwe_incoming_ > bitrate_) 208 if (bwe_incoming_ > bitrate_)
213 bitrate_ = CapBitrateToThresholds(now_ms, bwe_incoming_); 209 bitrate_ = CapBitrateToThresholds(now_ms, bwe_incoming_);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 332 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000
337 << " kbps is below configured min bitrate " 333 << " kbps is below configured min bitrate "
338 << min_bitrate_configured_ / 1000 << " kbps."; 334 << min_bitrate_configured_ / 1000 << " kbps.";
339 last_low_bitrate_log_ms_ = now_ms; 335 last_low_bitrate_log_ms_ = now_ms;
340 } 336 }
341 bitrate = min_bitrate_configured_; 337 bitrate = min_bitrate_configured_;
342 } 338 }
343 return bitrate; 339 return bitrate;
344 } 340 }
345 } // namespace webrtc 341 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h ('k') | webrtc/system_wrappers/source/metrics_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698