webrtc_m130/modules/pacing/pacing_controller.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

692 lines
24 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/pacing/pacing_controller.h"
#include <algorithm>
Use std::make_unique instead of absl::make_unique. WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 17:06:18 +02:00
#include <memory>
#include <utility>
#include <vector>
#include "absl/strings/match.h"
#include "modules/pacing/bitrate_prober.h"
#include "modules/pacing/interval_budget.h"
#include "modules/pacing/round_robin_packet_queue.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/logging.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
namespace {
// Time limit in milliseconds between packet bursts.
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
constexpr TimeDelta kDefaultMinPacketLimit = TimeDelta::Millis(5);
constexpr TimeDelta kCongestedPacketInterval = TimeDelta::Millis(500);
// TODO(sprang): Consider dropping this limit.
// The maximum debt level, in terms of time, capped when sending packets.
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
constexpr TimeDelta kMaxDebtInTime = TimeDelta::Millis(500);
constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds(2);
// Upper cap on process interval, in case process has not been called in a long
// time. Applies only to periodic mode.
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
constexpr TimeDelta kMaxProcessingInterval = TimeDelta::Millis(30);
bool IsDisabled(const FieldTrialsView& field_trials, absl::string_view key) {
return absl::StartsWith(field_trials.Lookup(key), "Disabled");
}
bool IsEnabled(const FieldTrialsView& field_trials, absl::string_view key) {
return absl::StartsWith(field_trials.Lookup(key), "Enabled");
}
TimeDelta GetDynamicPaddingTarget(const FieldTrialsView& field_trials) {
FieldTrialParameter<TimeDelta> padding_target("timedelta",
TimeDelta::Millis(5));
ParseFieldTrial({&padding_target},
field_trials.Lookup("WebRTC-Pacer-DynamicPaddingTarget"));
return padding_target.Get();
}
} // namespace
const TimeDelta PacingController::kMaxExpectedQueueLength =
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
TimeDelta::Millis(2000);
const float PacingController::kDefaultPaceMultiplier = 2.5f;
const TimeDelta PacingController::kPausedProcessInterval =
kCongestedPacketInterval;
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
const TimeDelta PacingController::kMinSleepTime = TimeDelta::Millis(1);
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
const TimeDelta PacingController::kMaxEarlyProbeProcessing =
TimeDelta::Millis(1);
PacingController::PacingController(Clock* clock,
PacketSender* packet_sender,
const FieldTrialsView& field_trials,
ProcessMode mode)
: mode_(mode),
clock_(clock),
packet_sender_(packet_sender),
field_trials_(field_trials),
drain_large_queues_(
!IsDisabled(field_trials_, "WebRTC-Pacer-DrainQueue")),
send_padding_if_silent_(
IsEnabled(field_trials_, "WebRTC-Pacer-PadInSilence")),
pace_audio_(IsEnabled(field_trials_, "WebRTC-Pacer-BlockAudio")),
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
ignore_transport_overhead_(
IsEnabled(field_trials_, "WebRTC-Pacer-IgnoreTransportOverhead")),
padding_target_duration_(GetDynamicPaddingTarget(field_trials_)),
min_packet_limit_(kDefaultMinPacketLimit),
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
transport_overhead_per_packet_(DataSize::Zero()),
last_timestamp_(clock_->CurrentTime()),
paused_(false),
media_budget_(0),
padding_budget_(0),
media_debt_(DataSize::Zero()),
padding_debt_(DataSize::Zero()),
media_rate_(DataRate::Zero()),
padding_rate_(DataRate::Zero()),
prober_(field_trials_),
probing_send_failure_(false),
pacing_bitrate_(DataRate::Zero()),
last_process_time_(clock->CurrentTime()),
last_send_time_(last_process_time_),
seen_first_packet_(false),
packet_queue_(
std::make_unique<RoundRobinPacketQueue>(last_process_time_)),
congested_(false),
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
queue_time_limit_(kMaxExpectedQueueLength),
Reland "Reland "Only include overhead if using send side bandwidth estimation."" This is a reland of 086055d0fd9b9b9efe8bcf85884324a019e9bd33 ANA was accitendly disabled even when transport sequence numbers were negotiated due to a bug in how the audio send stream is configured. To solve this we simply continue to always allow enabling ANA and leave it up to the application to ensure that it's not used together with receive side estimation. Original change's description: > Reland "Only include overhead if using send side bandwidth estimation." > > This is a reland of 8c79c6e1af354c526497082c79ccbe12af03a33e > > Original change's description: > > Only include overhead if using send side bandwidth estimation. > > > > Bug: webrtc:11298 > > Change-Id: Ia2daf690461b55d394c1b964d6a7977a98be8be2 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166820 > > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > > Reviewed-by: Ali Tofigh <alito@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30382} > > Bug: webrtc:11298 > Change-Id: I33205e869a8ae27c15ffe991f6d985973ed6d15a > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167524 > Reviewed-by: Ali Tofigh <alito@webrtc.org> > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30390} Bug: webrtc:11298 Change-Id: If2ad91e17ebfc85dc51edcd9607996e18c5d1f13 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167883 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30413}
2020-01-29 17:42:52 +01:00
account_for_audio_(false),
include_overhead_(false) {
if (!drain_large_queues_) {
RTC_LOG(LS_WARNING) << "Pacer queues will not be drained,"
"pushback experiment must be enabled.";
}
FieldTrialParameter<int> min_packet_limit_ms("", min_packet_limit_.ms());
ParseFieldTrial({&min_packet_limit_ms},
field_trials_.Lookup("WebRTC-Pacer-MinPacketLimitMs"));
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
min_packet_limit_ = TimeDelta::Millis(min_packet_limit_ms.Get());
UpdateBudgetWithElapsedTime(min_packet_limit_);
}
PacingController::~PacingController() = default;
void PacingController::CreateProbeCluster(DataRate bitrate, int cluster_id) {
prober_.CreateProbeCluster(bitrate, CurrentTime(), cluster_id);
}
void PacingController::Pause() {
if (!paused_)
RTC_LOG(LS_INFO) << "PacedSender paused.";
paused_ = true;
packet_queue_->SetPauseState(true, CurrentTime());
}
void PacingController::Resume() {
if (paused_)
RTC_LOG(LS_INFO) << "PacedSender resumed.";
paused_ = false;
packet_queue_->SetPauseState(false, CurrentTime());
}
bool PacingController::IsPaused() const {
return paused_;
}
void PacingController::SetCongested(bool congested) {
if (congested_ && !congested) {
UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(CurrentTime()));
}
congested_ = congested;
}
bool PacingController::IsProbing() const {
return prober_.is_probing();
}
Timestamp PacingController::CurrentTime() const {
Timestamp time = clock_->CurrentTime();
if (time < last_timestamp_) {
RTC_LOG(LS_WARNING)
<< "Non-monotonic clock behavior observed. Previous timestamp: "
<< last_timestamp_.ms() << ", new timestamp: " << time.ms();
RTC_DCHECK_GE(time, last_timestamp_);
time = last_timestamp_;
}
last_timestamp_ = time;
return time;
}
void PacingController::SetProbingEnabled(bool enabled) {
RTC_CHECK(!seen_first_packet_);
prober_.SetEnabled(enabled);
}
void PacingController::SetPacingRates(DataRate pacing_rate,
DataRate padding_rate) {
static constexpr DataRate kMaxRate = DataRate::KilobitsPerSec(100'000);
RTC_CHECK_GT(pacing_rate, DataRate::Zero());
RTC_CHECK_GE(padding_rate, DataRate::Zero());
if (pacing_rate > kMaxRate || padding_rate > kMaxRate) {
RTC_LOG(LS_WARNING) << "Very high pacing rates ( > " << kMaxRate.kbps()
<< " kbps) configured: pacing = " << pacing_rate.kbps()
<< " kbps, padding = " << padding_rate.kbps()
<< " kbps.";
}
media_rate_ = pacing_rate;
padding_rate_ = padding_rate;
pacing_bitrate_ = pacing_rate;
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
media_budget_.set_target_rate_kbps(pacing_rate.kbps());
padding_budget_.set_target_rate_kbps(padding_rate.kbps());
RTC_LOG(LS_VERBOSE) << "bwe:pacer_updated pacing_kbps="
<< pacing_bitrate_.kbps()
<< " padding_budget_kbps=" << padding_rate.kbps();
}
void PacingController::EnqueuePacket(std::unique_ptr<RtpPacketToSend> packet) {
RTC_DCHECK(pacing_bitrate_ > DataRate::Zero())
<< "SetPacingRate must be called before InsertPacket.";
RTC_CHECK(packet->packet_type());
prober_.OnIncomingPacket(DataSize::Bytes(packet->payload_size()));
Timestamp now = CurrentTime();
if (mode_ == ProcessMode::kDynamic && packet_queue_->Empty()) {
// If queue is empty, we need to "fast-forward" the last process time,
// so that we don't use passed time as budget for sending the first new
// packet.
Timestamp target_process_time = now;
Timestamp next_send_time = NextSendTime();
if (next_send_time.IsFinite()) {
// There was already a valid planned send time, such as a keep-alive.
// Use that as last process time only if it's prior to now.
target_process_time = std::min(now, next_send_time);
}
UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_process_time));
}
packet_queue_->Push(now, std::move(packet));
seen_first_packet_ = true;
}
void PacingController::SetAccountForAudioPackets(bool account_for_audio) {
account_for_audio_ = account_for_audio;
}
Reland "Reland "Only include overhead if using send side bandwidth estimation."" This is a reland of 086055d0fd9b9b9efe8bcf85884324a019e9bd33 ANA was accitendly disabled even when transport sequence numbers were negotiated due to a bug in how the audio send stream is configured. To solve this we simply continue to always allow enabling ANA and leave it up to the application to ensure that it's not used together with receive side estimation. Original change's description: > Reland "Only include overhead if using send side bandwidth estimation." > > This is a reland of 8c79c6e1af354c526497082c79ccbe12af03a33e > > Original change's description: > > Only include overhead if using send side bandwidth estimation. > > > > Bug: webrtc:11298 > > Change-Id: Ia2daf690461b55d394c1b964d6a7977a98be8be2 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166820 > > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > > Reviewed-by: Ali Tofigh <alito@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30382} > > Bug: webrtc:11298 > Change-Id: I33205e869a8ae27c15ffe991f6d985973ed6d15a > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167524 > Reviewed-by: Ali Tofigh <alito@webrtc.org> > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30390} Bug: webrtc:11298 Change-Id: If2ad91e17ebfc85dc51edcd9607996e18c5d1f13 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167883 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30413}
2020-01-29 17:42:52 +01:00
void PacingController::SetIncludeOverhead() {
include_overhead_ = true;
}
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
void PacingController::SetTransportOverhead(DataSize overhead_per_packet) {
if (ignore_transport_overhead_)
return;
transport_overhead_per_packet_ = overhead_per_packet;
}
TimeDelta PacingController::ExpectedQueueTime() const {
RTC_DCHECK_GT(pacing_bitrate_, DataRate::Zero());
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
return TimeDelta::Millis(
(QueueSizeData().bytes() * 8 * rtc::kNumMillisecsPerSec) /
pacing_bitrate_.bps());
}
size_t PacingController::QueueSizePackets() const {
return packet_queue_->SizeInPackets();
}
DataSize PacingController::QueueSizeData() const {
DataSize size = packet_queue_->SizeInPayloadBytes();
if (include_overhead_) {
size += static_cast<int64_t>(packet_queue_->SizeInPackets()) *
transport_overhead_per_packet_;
}
return size;
}
DataSize PacingController::CurrentBufferLevel() const {
return std::max(media_debt_, padding_debt_);
}
absl::optional<Timestamp> PacingController::FirstSentPacketTime() const {
return first_sent_packet_time_;
}
Timestamp PacingController::OldestPacketEnqueueTime() const {
return packet_queue_->OldestEnqueueTime();
}
TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) {
// If no previous processing, or last process was "in the future" because of
// early probe processing, then there is no elapsed time to add budget for.
if (last_process_time_.IsMinusInfinity() || now < last_process_time_) {
return TimeDelta::Zero();
}
TimeDelta elapsed_time = now - last_process_time_;
last_process_time_ = now;
if (elapsed_time > kMaxElapsedTime) {
RTC_LOG(LS_WARNING) << "Elapsed time (" << elapsed_time.ms()
<< " ms) longer than expected, limiting to "
<< kMaxElapsedTime.ms();
elapsed_time = kMaxElapsedTime;
}
return elapsed_time;
}
bool PacingController::ShouldSendKeepalive(Timestamp now) const {
if (send_padding_if_silent_ || paused_ || congested_ || !seen_first_packet_) {
// We send a padding packet every 500 ms to ensure we won't get stuck in
// congested state due to no feedback being received.
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (now - last_send_time_ >= kCongestedPacketInterval) {
return true;
}
}
return false;
}
Timestamp PacingController::NextSendTime() const {
const Timestamp now = CurrentTime();
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
Timestamp next_send_time = Timestamp::PlusInfinity();
if (paused_) {
return last_send_time_ + kPausedProcessInterval;
}
// If probing is active, that always takes priority.
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (prober_.is_probing() && !probing_send_failure_) {
Timestamp probe_time = prober_.NextProbeTime(now);
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (!probe_time.IsPlusInfinity()) {
return probe_time.IsMinusInfinity() ? now : probe_time;
}
}
if (mode_ == ProcessMode::kPeriodic) {
// In periodic non-probing mode, we just have a fixed interval.
return last_process_time_ + min_packet_limit_;
}
// In dynamic mode, figure out when the next packet should be sent,
// given the current conditions.
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
// Not pacing audio, if leading packet is audio its target send
// time is the time at which it was enqueued.
Timestamp unpaced_audio_time =
pace_audio_ ? Timestamp::PlusInfinity()
: packet_queue_->LeadingAudioPacketEnqueueTime();
if (unpaced_audio_time.IsFinite()) {
return unpaced_audio_time;
}
if (congested_ || !seen_first_packet_) {
Revert "Pacer: Reduce TQ wake up and improve packet size estimation" This reverts commit 37195cf2e577cc09ad1362d046b5c8a9b65d4f99. Reason for revert: Breaks downstream tests (more investigations and testing is necessary). Original change's description: > Pacer: Reduce TQ wake up and improve packet size estimation > > The TQ Pacer schedules delayed task according to target time of > PacingController. It drains all valid ProcessPackets() in single loop, > denies retired scheduled tasks, and round up the timeout to 1ms. > > This CL also improves packet size estimation in TQ Pacer by removing > zero initialization, and introduces `include_overhead_` configuration. > > Tests: > 1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > > 2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > > 3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > > Bug: webrtc:13417, webrtc:13437 > Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#36179} No-Try: True Bug: webrtc:13417, webrtc:13437 Change-Id: I5418d26d3978f21765ef38acfb002398e671e036 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255301 Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#36185}
2022-03-14 09:13:41 +00:00
// We need to at least send keep-alive packets with some interval.
return last_send_time_ + kCongestedPacketInterval;
}
if (media_rate_ > DataRate::Zero() && !packet_queue_->Empty()) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
// Check how long until we can send the next media packet.
next_send_time = last_process_time_ + media_debt_ / media_rate_;
} else if (padding_rate_ > DataRate::Zero() && packet_queue_->Empty()) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
// If we _don't_ have pending packets, check how long until we have
// bandwidth for padding packets. Both media and padding debts must
// have been drained to do this.
RTC_DCHECK_GT(media_rate_, DataRate::Zero());
TimeDelta drain_time =
std::max(media_debt_ / media_rate_, padding_debt_ / padding_rate_);
if (drain_time.IsZero() &&
(!media_debt_.IsZero() || !padding_debt_.IsZero())) {
// We have a non-zero debt, but drain time is smaller than tick size of
// TimeDelta, round it up to the smallest possible non-zero delta.
drain_time = TimeDelta::Micros(1);
}
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
next_send_time = last_process_time_ + drain_time;
} else {
// Nothing to do.
next_send_time = last_process_time_ + kPausedProcessInterval;
}
Reland "Fixes dynamic mode pacing issues." This is a reland of 72e6cb0b3f548900fd3b548b4b6966e3f5ee854f Was not the cause of perf alert, relanding. TBR=ilnik@webrtc.org Original change's description: > Fixes dynamic mode pacing issues. > > This CL fixes a few issues in the (default-disabled) dynamic pacing > mode: > * Slight update to sleep timing to avoid short spin loops > * Removed support for early execution as that lead to time-travel > contradictions that were difficult to solve. > * Makes sure we schedule a process call when a packet is due to be > drained even if the queue is empty, so that padding will start at > the correct time. > * While paused or empty, sleep relative last send time if we send > padding while silent - otherwise just relative to last process > time. > * If target send time shifts so far back that packet should have > been sent prior to the last process, make sure we don't let the > buffer level remain. > * Update the PacedSender test to _actually_ use dynamic processing > when the param says so. > > Bug: webrtc:10809 > Change-Id: Iebfde9769647d2390fd192a40bbe2d5bf1f6cc62 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160407 > Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29911} Bug: webrtc:10809 Change-Id: Ie7b307e574c2057bb05af87b6718a132d639a416 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160786 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29928}
2019-11-25 18:22:09 +01:00
if (send_padding_if_silent_) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
next_send_time =
std::min(next_send_time, last_send_time_ + kPausedProcessInterval);
Reland "Fixes dynamic mode pacing issues." This is a reland of 72e6cb0b3f548900fd3b548b4b6966e3f5ee854f Was not the cause of perf alert, relanding. TBR=ilnik@webrtc.org Original change's description: > Fixes dynamic mode pacing issues. > > This CL fixes a few issues in the (default-disabled) dynamic pacing > mode: > * Slight update to sleep timing to avoid short spin loops > * Removed support for early execution as that lead to time-travel > contradictions that were difficult to solve. > * Makes sure we schedule a process call when a packet is due to be > drained even if the queue is empty, so that padding will start at > the correct time. > * While paused or empty, sleep relative last send time if we send > padding while silent - otherwise just relative to last process > time. > * If target send time shifts so far back that packet should have > been sent prior to the last process, make sure we don't let the > buffer level remain. > * Update the PacedSender test to _actually_ use dynamic processing > when the param says so. > > Bug: webrtc:10809 > Change-Id: Iebfde9769647d2390fd192a40bbe2d5bf1f6cc62 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160407 > Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29911} Bug: webrtc:10809 Change-Id: Ie7b307e574c2057bb05af87b6718a132d639a416 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160786 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29928}
2019-11-25 18:22:09 +01:00
}
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
return next_send_time;
}
void PacingController::ProcessPackets() {
Timestamp now = CurrentTime();
Timestamp target_send_time = now;
if (ShouldSendKeepalive(now)) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
DataSize keepalive_data_sent = DataSize::Zero();
// We can not send padding unless a normal packet has first been sent. If
// we do, timestamps get messed up.
if (seen_first_packet_) {
std::vector<std::unique_ptr<RtpPacketToSend>> keepalive_packets =
packet_sender_->GeneratePadding(DataSize::Bytes(1));
for (auto& packet : keepalive_packets) {
keepalive_data_sent +=
DataSize::Bytes(packet->payload_size() + packet->padding_size());
Reland "Lets PacingController call PacketRouter directly." This reverts commit 980cadd02c7384397a41c0e334e9f329f3cc5c65. Reason for revert: Problematic code now fix. Original change's description: > Revert "Lets PacingController call PacketRouter directly." > > This reverts commit 848ea9f0d3678118cb8926a2898454e5a4df58ae. > > Reason for revert: Part of changes that may cause deadlock > > Original change's description: > > Lets PacingController call PacketRouter directly. > > > > Since locking model has been cleaned up, PacingController can now call > > PacketRouter directly - without having to go via PacedSender or > > TaskQueuePacedSender. > > > > Bug: webrtc:10809 > > Change-Id: I181f04167d677c35395286f8b246aefb4c3e7ec7 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175909 > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#31342} > > TBR=sprang@webrtc.org,srte@webrtc.org > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: webrtc:10809 > Change-Id: I1d7d5217a03a51555b130ec5c2dd6a992b6e489e > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178021 > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31563} TBR=sprang@webrtc.org,srte@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:10809 Change-Id: I8bea1a5b1b1f618b697e4b09d83c9aac08099593 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178389 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31600}
2020-06-30 11:53:37 +00:00
packet_sender_->SendPacket(std::move(packet), PacedPacketInfo());
Reland "Reland "Allows FEC generation after pacer step."" This is a reland of 19df870d924662e3b6efb86078d31a8e086b38b5 Patchset 1 is the original. Subsequent patchset changes threadchecker that crashed with downstream code. Original change's description: > Reland "Allows FEC generation after pacer step." > > This is a reland of 75fd127640bdf1729af6b4a25875e6d01f1570e0 > > Patchset 2 contains a fix. Old code can in factor call > RtpRtcpImpl::FetchFec(). It should only be a noop since deferred fec > is not supported there - we shouldn't crash. > > Original change's description: > > Allows FEC generation after pacer step. > > > > Split out from https://webrtc-review.googlesource.com/c/src/+/173708 > > This CL enables FEC packets to be generated as media packets are sent, > > rather than generated, i.e. media packets are inserted into the fec > > generator after the pacing stage rather than at packetization time. > > > > This may have some small impact of performance. FEC packets are > > typically only generated when a new packet with a marker bit is added, > > which means FEC packets protecting a frame will now be sent after all > > of the media packets, rather than (potentially) interleaved with them. > > Therefore this feature is currently behind a flag so we can examine the > > impact. Once we are comfortable with the behavior we'll make it default > > and remove the old code. > > > > Note that this change does not include the "protect all header > > extensions" part of the original CL - that will be a follow-up. > > > > Bug: webrtc:11340 > > Change-Id: I3fe139c5d53968579b75b91e2612075451ff0f5d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177760 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#31558} > > Bug: webrtc:11340 > Change-Id: I2ea49ee87ee9ff409044e34a777a7dd0ae0a077f > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177984 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31613} Bug: webrtc:11340 Change-Id: Ib741c8c284f523c959f8aca454088d9eee7b17f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178600 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31619}
2020-07-02 17:41:32 +02:00
for (auto& packet : packet_sender_->FetchFec()) {
EnqueuePacket(std::move(packet));
}
}
}
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
OnPacketSent(RtpPacketMediaType::kPadding, keepalive_data_sent, now);
}
if (paused_) {
return;
}
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (mode_ == ProcessMode::kDynamic) {
TimeDelta early_execute_margin =
prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero();
target_send_time = NextSendTime();
if (now + early_execute_margin < target_send_time) {
// We are too early, but if queue is empty still allow draining some debt.
// Probing is allowed to be sent up to kMinSleepTime early.
UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(now));
return;
}
}
TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_send_time);
if (elapsed_time > TimeDelta::Zero()) {
DataRate target_rate = pacing_bitrate_;
DataSize queue_size_data = QueueSizeData();
if (queue_size_data > DataSize::Zero()) {
// Assuming equal size packets and input/output rate, the average packet
// has avg_time_left_ms left to get queue_size_bytes out of the queue, if
// time constraint shall be met. Determine bitrate needed for that.
packet_queue_->UpdateAverageQueueTime(now);
if (drain_large_queues_) {
TimeDelta avg_time_left =
Use newer version of TimeDelta and TimeStamp factories in modules/ This change generated with following commands: find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g" find modules -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g" git cl format Bug: None Change-Id: I117d64a54950be040d996035c54bc0043310943a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168340 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30489}
2020-02-07 14:53:52 +01:00
std::max(TimeDelta::Millis(1),
queue_time_limit_ - packet_queue_->AverageQueueTime());
DataRate min_rate_needed = queue_size_data / avg_time_left;
if (min_rate_needed > target_rate) {
target_rate = min_rate_needed;
RTC_LOG(LS_VERBOSE) << "bwe:large_pacing_queue pacing_rate_kbps="
<< target_rate.kbps();
}
}
}
if (mode_ == ProcessMode::kPeriodic) {
// In periodic processing mode, the IntevalBudget allows positive budget
// up to (process interval duration) * (target rate), so we only need to
// update it once before the packet sending loop.
media_budget_.set_target_rate_kbps(target_rate.kbps());
} else {
media_rate_ = target_rate;
}
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
UpdateBudgetWithElapsedTime(elapsed_time);
}
PacedPacketInfo pacing_info;
DataSize recommended_probe_size = DataSize::Zero();
bool is_probing = prober_.is_probing();
if (is_probing) {
// Probe timing is sensitive, and handled explicitly by BitrateProber, so
// use actual send time rather than target.
pacing_info = prober_.CurrentCluster(now).value_or(PacedPacketInfo());
if (pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe) {
recommended_probe_size = prober_.RecommendedMinProbeSize();
RTC_DCHECK_GT(recommended_probe_size, DataSize::Zero());
} else {
// No valid probe cluster returned, probe might have timed out.
is_probing = false;
}
}
Revert "Reland "Send first probe packet directly instead of enqueuing it."" This reverts commit fc5871cb98481937351bee2f46b2a2e3987d177a. Reason for revert: I rage quit. Original change's description: > Reland "Send first probe packet directly instead of enqueuing it." > > This is a reland of commit 8088aad5ac0154d8fdc252de9e8ab4e0172d7da2 > > Patchset 1 is original CL, patchset 2 contains a fix to make behavior > exactly identical to original. It fixes a difference when the first > small probe packet comprises the entire probe. > > Original change's description: > > Send first probe packet directly instead of enqueuing it. > > > > This avoids potentially creating needless containers in the packet > > queue and removes usage of the packet prio, allowing it to be moved in > > an upcoming CL. > > > > Bug: webrtc:11340 > > Change-Id: Iddd9e7e4e73c97ab25a85e42bcc0094d61fd60d3 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259524 > > Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#36602} > > Bug: webrtc:11340 > Change-Id: I7d2f476a7043edd03f44a4a3de31f13c3c946a8d > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259776 > Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#36626} Bug: webrtc:11340 Change-Id: Ife22cff8f5fbf9b70dc24926b84caad82d2738b8 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259778 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36628}
2022-04-22 15:59:06 +00:00
DataSize data_sent = DataSize::Zero();
// Circuit breaker, making sure main loop isn't forever.
static constexpr int kMaxIterations = 1 << 16;
int iteration = 0;
int packets_sent = 0;
int padding_packets_generated = 0;
for (; iteration < kMaxIterations; ++iteration) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
// Fetch packet, so long as queue is not empty or budget is not
// exhausted.
std::unique_ptr<RtpPacketToSend> rtp_packet =
GetPendingPacket(pacing_info, target_send_time, now);
if (rtp_packet == nullptr) {
// No packet available to send, check if we should send padding.
DataSize padding_to_add = PaddingToAdd(recommended_probe_size, data_sent);
if (padding_to_add > DataSize::Zero()) {
std::vector<std::unique_ptr<RtpPacketToSend>> padding_packets =
packet_sender_->GeneratePadding(padding_to_add);
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (!padding_packets.empty()) {
padding_packets_generated += padding_packets.size();
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
for (auto& packet : padding_packets) {
EnqueuePacket(std::move(packet));
}
// Continue loop to send the padding that was just added.
continue;
} else {
// Can't generate padding, still update padding budget for next send
// time.
UpdatePaddingBudgetWithSentData(padding_to_add);
}
}
// Can't fetch new packet and no padding to send, exit send loop.
break;
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
} else {
Revert "Reland "Send first probe packet directly instead of enqueuing it."" This reverts commit fc5871cb98481937351bee2f46b2a2e3987d177a. Reason for revert: I rage quit. Original change's description: > Reland "Send first probe packet directly instead of enqueuing it." > > This is a reland of commit 8088aad5ac0154d8fdc252de9e8ab4e0172d7da2 > > Patchset 1 is original CL, patchset 2 contains a fix to make behavior > exactly identical to original. It fixes a difference when the first > small probe packet comprises the entire probe. > > Original change's description: > > Send first probe packet directly instead of enqueuing it. > > > > This avoids potentially creating needless containers in the packet > > queue and removes usage of the packet prio, allowing it to be moved in > > an upcoming CL. > > > > Bug: webrtc:11340 > > Change-Id: Iddd9e7e4e73c97ab25a85e42bcc0094d61fd60d3 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259524 > > Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#36602} > > Bug: webrtc:11340 > Change-Id: I7d2f476a7043edd03f44a4a3de31f13c3c946a8d > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259776 > Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#36626} Bug: webrtc:11340 Change-Id: Ife22cff8f5fbf9b70dc24926b84caad82d2738b8 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259778 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36628}
2022-04-22 15:59:06 +00:00
RTC_DCHECK(rtp_packet);
RTC_DCHECK(rtp_packet->packet_type().has_value());
const RtpPacketMediaType packet_type = *rtp_packet->packet_type();
DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() +
rtp_packet->padding_size());
if (include_overhead_) {
packet_size += DataSize::Bytes(rtp_packet->headers_size()) +
transport_overhead_per_packet_;
}
packet_sender_->SendPacket(std::move(rtp_packet), pacing_info);
for (auto& packet : packet_sender_->FetchFec()) {
EnqueuePacket(std::move(packet));
}
data_sent += packet_size;
++packets_sent;
Revert "Pacer: Reduce TQ wake up and improve packet size estimation" This reverts commit 37195cf2e577cc09ad1362d046b5c8a9b65d4f99. Reason for revert: Breaks downstream tests (more investigations and testing is necessary). Original change's description: > Pacer: Reduce TQ wake up and improve packet size estimation > > The TQ Pacer schedules delayed task according to target time of > PacingController. It drains all valid ProcessPackets() in single loop, > denies retired scheduled tasks, and round up the timeout to 1ms. > > This CL also improves packet size estimation in TQ Pacer by removing > zero initialization, and introduces `include_overhead_` configuration. > > Tests: > 1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > > 2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > > 3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > > Bug: webrtc:13417, webrtc:13437 > Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#36179} No-Try: True Bug: webrtc:13417, webrtc:13437 Change-Id: I5418d26d3978f21765ef38acfb002398e671e036 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255301 Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#36185}
2022-03-14 09:13:41 +00:00
Revert "Reland "Send first probe packet directly instead of enqueuing it."" This reverts commit fc5871cb98481937351bee2f46b2a2e3987d177a. Reason for revert: I rage quit. Original change's description: > Reland "Send first probe packet directly instead of enqueuing it." > > This is a reland of commit 8088aad5ac0154d8fdc252de9e8ab4e0172d7da2 > > Patchset 1 is original CL, patchset 2 contains a fix to make behavior > exactly identical to original. It fixes a difference when the first > small probe packet comprises the entire probe. > > Original change's description: > > Send first probe packet directly instead of enqueuing it. > > > > This avoids potentially creating needless containers in the packet > > queue and removes usage of the packet prio, allowing it to be moved in > > an upcoming CL. > > > > Bug: webrtc:11340 > > Change-Id: Iddd9e7e4e73c97ab25a85e42bcc0094d61fd60d3 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259524 > > Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#36602} > > Bug: webrtc:11340 > Change-Id: I7d2f476a7043edd03f44a4a3de31f13c3c946a8d > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259776 > Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#36626} Bug: webrtc:11340 Change-Id: Ife22cff8f5fbf9b70dc24926b84caad82d2738b8 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259778 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36628}
2022-04-22 15:59:06 +00:00
// Send done, update send time.
OnPacketSent(packet_type, packet_size, now);
if (is_probing) {
pacing_info.probe_cluster_bytes_sent += packet_size.bytes();
// If we are currently probing, we need to stop the send loop when we
// have reached the send target.
if (data_sent >= recommended_probe_size) {
break;
}
}
// Update target send time in case that are more packets that we are late
// in processing.
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (mode_ == ProcessMode::kDynamic) {
target_send_time = NextSendTime();
if (target_send_time > now) {
// Exit loop if not probing.
if (!is_probing) {
break;
}
target_send_time = now;
}
UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_send_time));
}
}
}
if (iteration >= kMaxIterations) {
// Circuit break activated. Log warning, adjust send time and return.
// TODO(sprang): Consider completely clearing state.
RTC_LOG(LS_ERROR) << "PacingController exceeded max iterations in "
"send-loop: packets sent = "
<< packets_sent << ", padding packets generated = "
<< padding_packets_generated
<< ", bytes sent = " << data_sent.bytes();
last_send_time_ = now;
last_process_time_ = now;
return;
}
if (is_probing) {
probing_send_failure_ = data_sent == DataSize::Zero();
if (!probing_send_failure_) {
prober_.ProbeSent(CurrentTime(), data_sent);
}
}
}
DataSize PacingController::PaddingToAdd(DataSize recommended_probe_size,
DataSize data_sent) const {
if (!packet_queue_->Empty()) {
// Actual payload available, no need to add padding.
return DataSize::Zero();
}
if (congested_) {
// Don't add padding if congested, even if requested for probing.
return DataSize::Zero();
}
if (!seen_first_packet_) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
// We can not send padding unless a normal packet has first been sent. If
// we do, timestamps get messed up.
return DataSize::Zero();
}
if (!recommended_probe_size.IsZero()) {
if (recommended_probe_size > data_sent) {
return recommended_probe_size - data_sent;
}
return DataSize::Zero();
}
if (mode_ == ProcessMode::kPeriodic) {
return DataSize::Bytes(padding_budget_.bytes_remaining());
} else if (padding_rate_ > DataRate::Zero() &&
padding_debt_ == DataSize::Zero()) {
return padding_target_duration_ * padding_rate_;
}
return DataSize::Zero();
}
std::unique_ptr<RtpPacketToSend> PacingController::GetPendingPacket(
const PacedPacketInfo& pacing_info,
Timestamp target_send_time,
Timestamp now) {
const bool is_probe =
pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe;
// If first packet in probe, insert a small padding packet so we have a
// more reliable start window for the rate estimation.
if (is_probe && pacing_info.probe_cluster_bytes_sent == 0) {
auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1));
// If no RTP modules sending media are registered, we may not get a
// padding packet back.
if (!padding.empty()) {
// We should never get more than one padding packets with a requested
// size of 1 byte.
RTC_DCHECK_EQ(padding.size(), 1u);
return std::move(padding[0]);
}
}
if (packet_queue_->Empty()) {
return nullptr;
}
// First, check if there is any reason _not_ to send the next queued packet.
// Unpaced audio packets and probes are exempted from send checks.
bool unpaced_audio_packet =
!pace_audio_ && packet_queue_->LeadingAudioPacketEnqueueTime().IsFinite();
if (!unpaced_audio_packet && !is_probe) {
if (congested_) {
// Don't send anything if congested.
return nullptr;
}
if (mode_ == ProcessMode::kPeriodic) {
if (media_budget_.bytes_remaining() <= 0) {
// Not enough budget.
return nullptr;
}
} else {
Reland "Fixes dynamic mode pacing issues." This is a reland of 72e6cb0b3f548900fd3b548b4b6966e3f5ee854f Was not the cause of perf alert, relanding. TBR=ilnik@webrtc.org Original change's description: > Fixes dynamic mode pacing issues. > > This CL fixes a few issues in the (default-disabled) dynamic pacing > mode: > * Slight update to sleep timing to avoid short spin loops > * Removed support for early execution as that lead to time-travel > contradictions that were difficult to solve. > * Makes sure we schedule a process call when a packet is due to be > drained even if the queue is empty, so that padding will start at > the correct time. > * While paused or empty, sleep relative last send time if we send > padding while silent - otherwise just relative to last process > time. > * If target send time shifts so far back that packet should have > been sent prior to the last process, make sure we don't let the > buffer level remain. > * Update the PacedSender test to _actually_ use dynamic processing > when the param says so. > > Bug: webrtc:10809 > Change-Id: Iebfde9769647d2390fd192a40bbe2d5bf1f6cc62 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160407 > Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29911} Bug: webrtc:10809 Change-Id: Ie7b307e574c2057bb05af87b6718a132d639a416 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160786 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29928}
2019-11-25 18:22:09 +01:00
// Dynamic processing mode.
if (now <= target_send_time) {
// We allow sending slightly early if we think that we would actually
// had been able to, had we been right on time - i.e. the current debt
// is not more than would be reduced to zero at the target sent time.
TimeDelta flush_time = media_debt_ / media_rate_;
if (now + flush_time > target_send_time) {
return nullptr;
}
}
}
}
return packet_queue_->Pop();
}
void PacingController::OnPacketSent(RtpPacketMediaType packet_type,
DataSize packet_size,
Timestamp send_time) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if (!first_sent_packet_time_ && packet_type != RtpPacketMediaType::kPadding) {
first_sent_packet_time_ = send_time;
}
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
bool audio_packet = packet_type == RtpPacketMediaType::kAudio;
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
if ((!audio_packet || account_for_audio_) && packet_size > DataSize::Zero()) {
UpdateBudgetWithSentData(packet_size);
}
Revert "Pacer: Reduce TQ wake up and improve packet size estimation" This reverts commit 37195cf2e577cc09ad1362d046b5c8a9b65d4f99. Reason for revert: Breaks downstream tests (more investigations and testing is necessary). Original change's description: > Pacer: Reduce TQ wake up and improve packet size estimation > > The TQ Pacer schedules delayed task according to target time of > PacingController. It drains all valid ProcessPackets() in single loop, > denies retired scheduled tasks, and round up the timeout to 1ms. > > This CL also improves packet size estimation in TQ Pacer by removing > zero initialization, and introduces `include_overhead_` configuration. > > Tests: > 1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > > 2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > > 3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > > Bug: webrtc:13417, webrtc:13437 > Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#36179} No-Try: True Bug: webrtc:13417, webrtc:13437 Change-Id: I5418d26d3978f21765ef38acfb002398e671e036 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255301 Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#36185}
2022-03-14 09:13:41 +00:00
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
last_send_time_ = send_time;
}
void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) {
if (mode_ == ProcessMode::kPeriodic) {
delta = std::min(kMaxProcessingInterval, delta);
media_budget_.IncreaseBudget(delta.ms());
padding_budget_.IncreaseBudget(delta.ms());
} else {
media_debt_ -= std::min(media_debt_, media_rate_ * delta);
padding_debt_ -= std::min(padding_debt_, padding_rate_ * delta);
}
}
void PacingController::UpdateBudgetWithSentData(DataSize size) {
if (mode_ == ProcessMode::kPeriodic) {
media_budget_.UseBudget(size.bytes());
} else {
media_debt_ += size;
media_debt_ = std::min(media_debt_, media_rate_ * kMaxDebtInTime);
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
}
UpdatePaddingBudgetWithSentData(size);
}
void PacingController::UpdatePaddingBudgetWithSentData(DataSize size) {
if (mode_ == ProcessMode::kPeriodic) {
padding_budget_.UseBudget(size.bytes());
} else {
padding_debt_ += size;
padding_debt_ = std::min(padding_debt_, padding_rate_ * kMaxDebtInTime);
}
}
void PacingController::SetQueueTimeLimit(TimeDelta limit) {
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
queue_time_limit_ = limit;
}
} // namespace webrtc