Internal QUICHE change PiperOrigin-RevId: 280413308 Change-Id: I8410ce56a42272fc8cfb46048dba36a75d3971fc
diff --git a/quic/core/congestion_control/bbr2_sender.cc b/quic/core/congestion_control/bbr2_sender.cc index f176ff6..c90decd 100644 --- a/quic/core/congestion_control/bbr2_sender.cc +++ b/quic/core/congestion_control/bbr2_sender.cc
@@ -115,14 +115,7 @@ } void Bbr2Sender::AdjustNetworkParameters(const NetworkParams& params) { - AdjustNetworkParameters(params.bandwidth, params.rtt, - params.allow_cwnd_to_decrease); -} - -void Bbr2Sender::AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) { - model_.UpdateNetworkParameters(bandwidth, rtt); + model_.UpdateNetworkParameters(params.bandwidth, params.rtt); if (mode_ == Bbr2Mode::STARTUP) { const QuicByteCount prior_cwnd = cwnd_; @@ -132,7 +125,7 @@ // we are reducing the number of updates needed to arrive at the target. cwnd_ = model_.BDP(model_.BandwidthEstimate()); UpdateCongestionWindow(0); - if (!allow_cwnd_to_decrease) { + if (!params.allow_cwnd_to_decrease) { cwnd_ = std::max(cwnd_, prior_cwnd); } }
diff --git a/quic/core/congestion_control/bbr2_sender.h b/quic/core/congestion_control/bbr2_sender.h index 6d0f338..bff38f6 100644 --- a/quic/core/congestion_control/bbr2_sender.h +++ b/quic/core/congestion_control/bbr2_sender.h
@@ -48,9 +48,6 @@ Perspective perspective) override; void AdjustNetworkParameters(const NetworkParams& params) override; - void AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) override; void SetInitialCongestionWindowInPackets( QuicPacketCount congestion_window) override;
diff --git a/quic/core/congestion_control/bbr_sender.cc b/quic/core/congestion_control/bbr_sender.cc index a734c03..93ee5cb 100644 --- a/quic/core/congestion_control/bbr_sender.cc +++ b/quic/core/congestion_control/bbr_sender.cc
@@ -325,13 +325,9 @@ } void BbrSender::AdjustNetworkParameters(const NetworkParams& params) { - AdjustNetworkParameters(params.bandwidth, params.rtt, - params.allow_cwnd_to_decrease); -} + const QuicBandwidth& bandwidth = params.bandwidth; + const QuicTime::Delta& rtt = params.rtt; -void BbrSender::AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) { if (GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) { QUIC_RELOADABLE_FLAG_COUNT(quic_bbr_donot_inject_bandwidth); } else if (!bandwidth.IsZero()) { @@ -340,12 +336,10 @@ if (!rtt.IsZero() && (min_rtt_ > rtt || min_rtt_.IsZero())) { min_rtt_ = rtt; } - if (GetQuicReloadableFlag(quic_fix_bbr_cwnd_in_bandwidth_resumption) && - mode_ == STARTUP) { + + if (params.quic_fix_bbr_cwnd_in_bandwidth_resumption && mode_ == STARTUP) { if (bandwidth.IsZero()) { // Ignore bad bandwidth samples. - QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_bbr_cwnd_in_bandwidth_resumption, 3, - 3); return; } const QuicByteCount new_cwnd = std::max( @@ -363,14 +357,7 @@ } else { QUIC_CODE_COUNT(quic_default_initial_rtt); } - if (new_cwnd > congestion_window_) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_bbr_cwnd_in_bandwidth_resumption, 1, - 3); - } else { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_bbr_cwnd_in_bandwidth_resumption, 2, - 3); - } - if (new_cwnd < congestion_window_ && !allow_cwnd_to_decrease) { + if (new_cwnd < congestion_window_ && !params.allow_cwnd_to_decrease) { // Only decrease cwnd if allow_cwnd_to_decrease is true. return; } @@ -382,8 +369,7 @@ set_high_cwnd_gain(kDerivedHighCWNDGain); } congestion_window_ = new_cwnd; - if (GetQuicReloadableFlag(quic_bbr_fix_pacing_rate)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_bbr_fix_pacing_rate); + if (params.quic_bbr_fix_pacing_rate) { // Pace at the rate of new_cwnd / RTT. QuicBandwidth new_pacing_rate = QuicBandwidth::FromBytesAndTimeDelta(congestion_window_, GetMinRtt());
diff --git a/quic/core/congestion_control/bbr_sender.h b/quic/core/congestion_control/bbr_sender.h index a128797..8c07a40 100644 --- a/quic/core/congestion_control/bbr_sender.h +++ b/quic/core/congestion_control/bbr_sender.h
@@ -106,9 +106,6 @@ Perspective perspective) override; void AdjustNetworkParameters(const NetworkParams& params) override; - void AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) override; void SetInitialCongestionWindowInPackets( QuicPacketCount congestion_window) override; void OnCongestionEvent(bool rtt_updated,
diff --git a/quic/core/congestion_control/bbr_sender_test.cc b/quic/core/congestion_control/bbr_sender_test.cc index 9120ea8..60b303e 100644 --- a/quic/core/congestion_control/bbr_sender_test.cc +++ b/quic/core/congestion_control/bbr_sender_test.cc
@@ -1249,8 +1249,9 @@ TEST_F(BbrSenderTest, ResumeConnectionState) { CreateDefaultSetup(); - bbr_sender_.connection()->AdjustNetworkParameters(kTestLinkBandwidth, - kTestRtt, false); + bbr_sender_.connection()->AdjustNetworkParameters( + SendAlgorithmInterface::NetworkParams(kTestLinkBandwidth, kTestRtt, + false)); if (!GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) { EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); @@ -1333,7 +1334,8 @@ // Bootstrap cwnd. bbr_sender_.connection()->AdjustNetworkParameters( - kTestLinkBandwidth, QuicTime::Delta::Zero(), false); + SendAlgorithmInterface::NetworkParams(kTestLinkBandwidth, + QuicTime::Delta::Zero(), false)); if (!GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) { EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); @@ -1362,7 +1364,8 @@ // Bootstrap cwnd. bbr_sender_.connection()->AdjustNetworkParameters( - kTestLinkBandwidth, QuicTime::Delta::Zero(), false); + SendAlgorithmInterface::NetworkParams(kTestLinkBandwidth, + QuicTime::Delta::Zero(), false)); if (!GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) { EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate());
diff --git a/quic/core/congestion_control/send_algorithm_interface.h b/quic/core/congestion_control/send_algorithm_interface.h index cde23b1..2c183f1 100644 --- a/quic/core/congestion_control/send_algorithm_interface.h +++ b/quic/core/congestion_control/send_algorithm_interface.h
@@ -34,15 +34,35 @@ // Network Params for AdjustNetworkParameters. struct QUIC_NO_EXPORT NetworkParams { NetworkParams() - : bandwidth(QuicBandwidth::Zero()), - rtt(QuicTime::Delta::Zero()), - allow_cwnd_to_decrease(false) {} - NetworkParams(NetworkParams&& params) = default; - NetworkParams& operator=(NetworkParams&& params) = default; + : NetworkParams(QuicBandwidth::Zero(), QuicTime::Delta::Zero(), false) { + } + NetworkParams(const QuicBandwidth& bandwidth, + const QuicTime::Delta& rtt, + bool allow_cwnd_to_decrease) + : bandwidth(bandwidth), + rtt(rtt), + allow_cwnd_to_decrease(allow_cwnd_to_decrease), + quic_fix_bbr_cwnd_in_bandwidth_resumption( + GetQuicReloadableFlag(quic_fix_bbr_cwnd_in_bandwidth_resumption)), + quic_bbr_fix_pacing_rate( + GetQuicReloadableFlag(quic_bbr_fix_pacing_rate)) {} + + bool operator==(const NetworkParams& other) const { + return bandwidth == other.bandwidth && rtt == other.rtt && + allow_cwnd_to_decrease == other.allow_cwnd_to_decrease && + quic_fix_bbr_cwnd_in_bandwidth_resumption == + other.quic_fix_bbr_cwnd_in_bandwidth_resumption && + quic_bbr_fix_pacing_rate == other.quic_bbr_fix_pacing_rate; + } QuicBandwidth bandwidth; QuicTime::Delta rtt; bool allow_cwnd_to_decrease; + // Code changes that are controlled by flags. + // TODO(b/131899599): Remove when impact of fix is measured. + bool quic_fix_bbr_cwnd_in_bandwidth_resumption; + // TODO(b/143540157): Remove when impact of fix is measured. + bool quic_bbr_fix_pacing_rate; }; static SendAlgorithmInterface* Create( @@ -130,11 +150,6 @@ // measurement or prediction. Either |bandwidth| or |rtt| may be zero if no // sample is available. virtual void AdjustNetworkParameters(const NetworkParams& params) = 0; - // TODO(b/143891040): Replace old interface with the new one that uses - // NetworkParams. - virtual void AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) = 0; // Retrieves debugging information about the current state of the // send algorithm.
diff --git a/quic/core/congestion_control/tcp_cubic_sender_bytes.cc b/quic/core/congestion_control/tcp_cubic_sender_bytes.cc index c26656f..cf400e5 100644 --- a/quic/core/congestion_control/tcp_cubic_sender_bytes.cc +++ b/quic/core/congestion_control/tcp_cubic_sender_bytes.cc
@@ -106,18 +106,10 @@ } void TcpCubicSenderBytes::AdjustNetworkParameters(const NetworkParams& params) { - AdjustNetworkParameters(params.bandwidth, params.rtt, - params.allow_cwnd_to_decrease); -} -void TcpCubicSenderBytes::AdjustNetworkParameters( - QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool /*allow_cwnd_to_decrease*/) { - if (bandwidth.IsZero() || rtt.IsZero()) { + if (params.bandwidth.IsZero() || params.rtt.IsZero()) { return; } - - SetCongestionWindowFromBandwidthAndRtt(bandwidth, rtt); + SetCongestionWindowFromBandwidthAndRtt(params.bandwidth, params.rtt); } float TcpCubicSenderBytes::RenoBeta() const {
diff --git a/quic/core/congestion_control/tcp_cubic_sender_bytes.h b/quic/core/congestion_control/tcp_cubic_sender_bytes.h index c78d5d8..8e89eaa 100644 --- a/quic/core/congestion_control/tcp_cubic_sender_bytes.h +++ b/quic/core/congestion_control/tcp_cubic_sender_bytes.h
@@ -47,9 +47,6 @@ void SetFromConfig(const QuicConfig& config, Perspective perspective) override; void AdjustNetworkParameters(const NetworkParams& params) override; - void AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) override; void SetNumEmulatedConnections(int num_connections); void SetInitialCongestionWindowInPackets( QuicPacketCount congestion_window) override;
diff --git a/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc b/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc index 6a338cb..04c0e8a 100644 --- a/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc +++ b/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc
@@ -677,19 +677,28 @@ const QuicBandwidth kBandwidthEstimate = QuicBandwidth::FromBytesPerSecond(kNumberOfPackets * kDefaultTCPMSS); const QuicTime::Delta kRttEstimate = QuicTime::Delta::FromSeconds(1); - sender_->AdjustNetworkParameters(kBandwidthEstimate, kRttEstimate, false); + + SendAlgorithmInterface::NetworkParams network_param; + network_param.bandwidth = kBandwidthEstimate; + network_param.rtt = kRttEstimate; + sender_->AdjustNetworkParameters(network_param); EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow()); // Resume with an illegal value of 0 and verify the server ignores it. - sender_->AdjustNetworkParameters(QuicBandwidth::Zero(), kRttEstimate, false); + SendAlgorithmInterface::NetworkParams network_param_no_bandwidth; + network_param_no_bandwidth.bandwidth = QuicBandwidth::Zero(); + network_param_no_bandwidth.rtt = kRttEstimate; + sender_->AdjustNetworkParameters(network_param_no_bandwidth); EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow()); // Resumed CWND is limited to be in a sensible range. const QuicBandwidth kUnreasonableBandwidth = QuicBandwidth::FromBytesPerSecond((kMaxResumptionCongestionWindow + 1) * kDefaultTCPMSS); - sender_->AdjustNetworkParameters(kUnreasonableBandwidth, - QuicTime::Delta::FromSeconds(1), false); + SendAlgorithmInterface::NetworkParams network_param_large_bandwidth; + network_param_large_bandwidth.bandwidth = kUnreasonableBandwidth; + network_param_large_bandwidth.rtt = QuicTime::Delta::FromSeconds(1); + sender_->AdjustNetworkParameters(network_param_large_bandwidth); EXPECT_EQ(kMaxResumptionCongestionWindow * kDefaultTCPMSS, sender_->GetCongestionWindow()); }
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc index 5344f4a..55b2274 100644 --- a/quic/core/quic_connection.cc +++ b/quic/core/quic_connection.cc
@@ -509,13 +509,6 @@ sent_packet_manager_.AdjustNetworkParameters(params); } -void QuicConnection::AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) { - sent_packet_manager_.AdjustNetworkParameters(bandwidth, rtt, - allow_cwnd_to_decrease); -} - QuicBandwidth QuicConnection::MaxPacingRate() const { return sent_packet_manager_.MaxPacingRate(); }
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc index cdc5a1c..4ed206a 100644 --- a/quic/core/quic_sent_packet_manager.cc +++ b/quic/core/quic_sent_packet_manager.cc
@@ -308,19 +308,17 @@ : cached_network_params.bandwidth_estimate_bytes_per_second()); QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms()); - AdjustNetworkParameters(bandwidth, rtt, /*allow_cwnd_to_decrease=*/false); + // This calls the old AdjustNetworkParameters interface, and fills certain + // fields in SendAlgorithmInterface::NetworkParams + // (e.g., quic_bbr_fix_pacing_rate) using GFE flags. + AdjustNetworkParameters(SendAlgorithmInterface::NetworkParams( + bandwidth, rtt, /*allow_cwnd_to_decrease = */ false)); } void QuicSentPacketManager::AdjustNetworkParameters( const SendAlgorithmInterface::NetworkParams& params) { - AdjustNetworkParameters(params.bandwidth, params.rtt, - params.allow_cwnd_to_decrease); -} - -void QuicSentPacketManager::AdjustNetworkParameters( - QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease) { + const QuicBandwidth& bandwidth = params.bandwidth; + const QuicTime::Delta& rtt = params.rtt; if (!rtt.IsZero()) { SetInitialRtt(rtt); } @@ -330,8 +328,7 @@ QUIC_RELOADABLE_FLAG_COUNT(quic_conservative_bursts); pacing_sender_.SetBurstTokens(kConservativeUnpacedBurst); } - send_algorithm_->AdjustNetworkParameters(bandwidth, rtt, - allow_cwnd_to_decrease); + send_algorithm_->AdjustNetworkParameters(params); if (debug_delegate_ != nullptr) { debug_delegate_->OnAdjustNetworkParameters( bandwidth, rtt.IsZero() ? rtt_stats_.SmoothedOrInitialRtt() : rtt,
diff --git a/quic/core/quic_sent_packet_manager.h b/quic/core/quic_sent_packet_manager.h index 67ded33..1f2b3d2 100644 --- a/quic/core/quic_sent_packet_manager.h +++ b/quic/core/quic_sent_packet_manager.h
@@ -148,9 +148,6 @@ // Notify the sent packet manager of an external network measurement or // prediction for either |bandwidth| or |rtt|; either can be empty. - void AdjustNetworkParameters(QuicBandwidth bandwidth, - QuicTime::Delta rtt, - bool allow_cwnd_to_decrease); void AdjustNetworkParameters( const SendAlgorithmInterface::NetworkParams& params);
diff --git a/quic/core/quic_sent_packet_manager_test.cc b/quic/core/quic_sent_packet_manager_test.cc index fb5cdce..3ea50fd 100644 --- a/quic/core/quic_sent_packet_manager_test.cc +++ b/quic/core/quic_sent_packet_manager_test.cc
@@ -2205,8 +2205,12 @@ CachedNetworkParameters cached_network_params; cached_network_params.set_min_rtt_ms(kRtt.ToMilliseconds()); - EXPECT_CALL(*send_algorithm_, - AdjustNetworkParameters(QuicBandwidth::Zero(), kRtt, false)); + SendAlgorithmInterface::NetworkParams params; + params.bandwidth = QuicBandwidth::Zero(); + params.allow_cwnd_to_decrease = false; + params.rtt = kRtt; + + EXPECT_CALL(*send_algorithm_, AdjustNetworkParameters(params)); EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) .Times(testing::AnyNumber()); manager_.ResumeConnectionState(cached_network_params, false);