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

Unified Diff: net/quic/core/congestion_control/bbr_sender.cc

Issue 2857243002: fix packet conservation to remove packets from recovery window when they are lost. Protected by FL… (Closed)
Patch Set: Updated patchset dependency Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/congestion_control/bbr_sender.h ('k') | net/quic/core/congestion_control/bbr_sender_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/congestion_control/bbr_sender.cc
diff --git a/net/quic/core/congestion_control/bbr_sender.cc b/net/quic/core/congestion_control/bbr_sender.cc
index 123a766aebdc44aa03f92c00de927be179f397b3..0c2104b5bd190c9e415d7d47460a44227d27c47b 100644
--- a/net/quic/core/congestion_control/bbr_sender.cc
+++ b/net/quic/core/congestion_control/bbr_sender.cc
@@ -322,13 +322,19 @@ void BbrSender::OnCongestionEvent(bool /*rtt_updated*/,
// Handle logic specific to PROBE_RTT.
MaybeEnterOrExitProbeRtt(event_time, is_round_start, min_rtt_expired);
- // After the model is updated, recalculate the pacing rate and congestion
- // window.
+ // Calculate number of packets acked and lost.
QuicByteCount bytes_acked =
sampler_.total_bytes_acked() - total_bytes_acked_before;
+ QuicByteCount bytes_lost = 0;
+ for (const auto& packet : lost_packets) {
+ bytes_lost += packet.second;
+ }
+
+ // After the model is updated, recalculate the pacing rate and congestion
+ // window.
CalculatePacingRate();
CalculateCongestionWindow(bytes_acked);
- CalculateRecoveryWindow(bytes_acked);
+ CalculateRecoveryWindow(bytes_acked, bytes_lost);
// Cleanup internal state.
sampler_.RemoveObsoletePackets(unacked_packets_->GetLeastUnacked());
@@ -553,12 +559,15 @@ void BbrSender::UpdateRecoveryState(QuicPacketNumber last_acked_packet,
// Enter conservation on the first loss.
if (has_losses) {
recovery_state_ = CONSERVATION;
- if (FLAGS_quic_reloadable_flag_quic_bbr_fix_conservation) {
+ if (FLAGS_quic_reloadable_flag_quic_bbr_fix_conservation ||
+ FLAGS_quic_reloadable_flag_quic_bbr_fix_conservation2) {
// This will cause the |recovery_window_| to be set to the correct
// value in CalculateRecoveryWindow().
recovery_window_ = 0;
QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_fix_conservation, 1,
3);
+ QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_fix_conservation2, 1,
+ 3);
}
// Since the conservation phase is meant to be lasting for a whole
// round, extend the current round as if it were started right now.
@@ -716,7 +725,43 @@ void BbrSender::CalculateCongestionWindow(QuicByteCount bytes_acked) {
congestion_window_ = std::min(congestion_window_, max_congestion_window_);
}
-void BbrSender::CalculateRecoveryWindow(QuicByteCount bytes_acked) {
+void BbrSender::CalculateRecoveryWindow(QuicByteCount bytes_acked,
+ QuicByteCount bytes_lost) {
+ if (FLAGS_quic_reloadable_flag_quic_bbr_fix_conservation2) {
+ if (recovery_state_ == NOT_IN_RECOVERY) {
+ return;
+ }
+
+ // Set up the initial recovery window.
+ if (recovery_window_ == 0) {
+ QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_fix_conservation2, 2, 3);
+ recovery_window_ = unacked_packets_->bytes_in_flight() + bytes_acked;
+ recovery_window_ = std::max(kMinimumCongestionWindow, recovery_window_);
+ return;
+ }
+
+ QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_fix_conservation2, 3, 3);
+
+ // Remove losses from the recovery window, while accounting for a potential
+ // integer underflow.
+ recovery_window_ = recovery_window_ >= bytes_lost
+ ? recovery_window_ - bytes_lost
+ : kMaxSegmentSize;
+
+ // In CONSERVATION mode, just subtracting losses is sufficient. In GROWTH,
+ // release additional |bytes_acked| to achieve a slow-start-like behavior.
+ if (recovery_state_ == GROWTH) {
+ recovery_window_ += bytes_acked;
+ }
+
+ // Sanity checks. Ensure that we always allow to send at least
+ // |bytes_acked| in response.
+ recovery_window_ = std::max(
+ recovery_window_, unacked_packets_->bytes_in_flight() + bytes_acked);
+ recovery_window_ = std::max(kMinimumCongestionWindow, recovery_window_);
+ return;
+ }
+
switch (recovery_state_) {
case CONSERVATION:
if (FLAGS_quic_reloadable_flag_quic_bbr_fix_conservation) {
« no previous file with comments | « net/quic/core/congestion_control/bbr_sender.h ('k') | net/quic/core/congestion_control/bbr_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698