Field trial to initialize throughput estimate faster.

The current acknowledged bitrate (i.e. throughput) estimator takes 500ms
to initialize. This CL creates a field trial to experiment with this
arbitrary initialization time.

Bug: webrtc:9492, webrtc:7746
Change-Id: I8a803f7bc0ee78856e808e289f37bab57d763efa
Reviewed-on: https://webrtc-review.googlesource.com/87145
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23852}
This commit is contained in:
Bjorn Terelius
2018-07-04 17:03:55 +02:00
committed by Commit Bot
parent 783c6e3a72
commit d97b862593
2 changed files with 44 additions and 9 deletions

View File

@ -11,23 +11,57 @@
#include "modules/congestion_controller/goog_cc/bitrate_estimator.h"
#include <cmath>
#include <string>
#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
constexpr int kInitialRateWindowMs = 500;
constexpr int kRateWindowMs = 150;
const char kBweInitialThroughputWindowExperiment[] =
"WebRTC-BweInitialThroughputWindowExperiment";
int ReadInitialThroughputWindowSizeMs() {
std::string experiment_string =
webrtc::field_trial::FindFullName(kBweInitialThroughputWindowExperiment);
int initial_window_ms = kInitialRateWindowMs;
int parsed_values =
sscanf(experiment_string.c_str(), "Enabled-%d", &initial_window_ms);
if (parsed_values != 1) {
RTC_LOG(LS_ERROR) << "Incorrectly formatted field trial string for "
<< kBweInitialThroughputWindowExperiment;
return kInitialRateWindowMs;
}
if (kRateWindowMs <= initial_window_ms && initial_window_ms <= 1000) {
RTC_LOG(LS_INFO) << kBweInitialThroughputWindowExperiment
<< " enabled with " << initial_window_ms << " ms window.";
return initial_window_ms;
}
RTC_LOG(LS_ERROR)
<< "Initial window for throughput estimation must be between "
<< kRateWindowMs << " and 1000 ms.";
return kInitialRateWindowMs;
}
} // namespace
BitrateEstimator::BitrateEstimator()
: sum_(0),
current_win_ms_(0),
initial_window_ms_(kInitialRateWindowMs),
current_window_ms_(0),
prev_time_ms_(-1),
bitrate_estimate_(-1.0f),
bitrate_estimate_var_(50.0f) {}
bitrate_estimate_var_(50.0f) {
if (field_trial::IsEnabled(kBweInitialThroughputWindowExperiment)) {
initial_window_ms_ = ReadInitialThroughputWindowSizeMs();
}
}
BitrateEstimator::~BitrateEstimator() = default;
@ -36,7 +70,7 @@ void BitrateEstimator::Update(int64_t now_ms, int bytes) {
// We use a larger window at the beginning to get a more stable sample that
// we can use to initialize the estimate.
if (bitrate_estimate_ < 0.f)
rate_window_ms = kInitialRateWindowMs;
rate_window_ms = initial_window_ms_;
float bitrate_sample = UpdateWindow(now_ms, bytes, rate_window_ms);
if (bitrate_sample < 0.0f)
return;
@ -71,21 +105,21 @@ float BitrateEstimator::UpdateWindow(int64_t now_ms,
if (now_ms < prev_time_ms_) {
prev_time_ms_ = -1;
sum_ = 0;
current_win_ms_ = 0;
current_window_ms_ = 0;
}
if (prev_time_ms_ >= 0) {
current_win_ms_ += now_ms - prev_time_ms_;
current_window_ms_ += now_ms - prev_time_ms_;
// Reset if nothing has been received for more than a full window.
if (now_ms - prev_time_ms_ > rate_window_ms) {
sum_ = 0;
current_win_ms_ %= rate_window_ms;
current_window_ms_ %= rate_window_ms;
}
}
prev_time_ms_ = now_ms;
float bitrate_sample = -1.0f;
if (current_win_ms_ >= rate_window_ms) {
if (current_window_ms_ >= rate_window_ms) {
bitrate_sample = 8.0f * sum_ / static_cast<float>(rate_window_ms);
current_win_ms_ -= rate_window_ms;
current_window_ms_ -= rate_window_ms;
sum_ = 0;
}
sum_ += bytes;

View File

@ -35,7 +35,8 @@ class BitrateEstimator {
private:
float UpdateWindow(int64_t now_ms, int bytes, int rate_window_ms);
int sum_;
int64_t current_win_ms_;
int64_t initial_window_ms_;
int64_t current_window_ms_;
int64_t prev_time_ms_;
float bitrate_estimate_;
float bitrate_estimate_var_;