gfe-relnote: In QUIC, use 2 burst tokens in bootstrapping experiment, protected by gfe2_reloadable_flag_quic_conservative_bursts.

Also decrease cwnd gain and pacing gain.

PiperOrigin-RevId: 247919205
Change-Id: Ic3a205e6f0ec8e23d3f17db9f8b252fd9638d08c
diff --git a/quic/core/congestion_control/bbr_sender.cc b/quic/core/congestion_control/bbr_sender.cc
index 004ec91..7d7258f 100644
--- a/quic/core/congestion_control/bbr_sender.cc
+++ b/quic/core/congestion_control/bbr_sender.cc
@@ -355,12 +355,14 @@
     if (new_cwnd > congestion_window_) {
       QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_bbr_cwnd_in_bandwidth_resumption, 1,
                                    2);
-      // Decrease cwnd gain when cwnd increases.
-      set_high_cwnd_gain(kDerivedHighCWNDGain);
     } else {
       QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_bbr_cwnd_in_bandwidth_resumption, 2,
                                    2);
     }
+    // Decreases cwnd gain and pacing gain. Please note, if pacing_rate_ has
+    // been calculated, it cannot decrease in STARTUP phase.
+    set_high_gain(kDerivedHighCWNDGain);
+    set_high_cwnd_gain(kDerivedHighCWNDGain);
     congestion_window_ = std::max(new_cwnd, congestion_window_);
   }
 }
diff --git a/quic/core/congestion_control/pacing_sender.cc b/quic/core/congestion_control/pacing_sender.cc
index 53d5096..0968935 100644
--- a/quic/core/congestion_control/pacing_sender.cc
+++ b/quic/core/congestion_control/pacing_sender.cc
@@ -122,6 +122,13 @@
   pacing_limited_ = false;
 }
 
+void PacingSender::SetBurstTokens(uint32_t burst_tokens) {
+  initial_burst_size_ = burst_tokens;
+  burst_tokens_ = std::min(
+      initial_burst_size_,
+      static_cast<uint32_t>(sender_->GetCongestionWindow() / kDefaultTCPMSS));
+}
+
 QuicTime::Delta PacingSender::TimeUntilSend(
     QuicTime now,
     QuicByteCount bytes_in_flight) const {
diff --git a/quic/core/congestion_control/pacing_sender.h b/quic/core/congestion_control/pacing_sender.h
index 8420c7f..781a921 100644
--- a/quic/core/congestion_control/pacing_sender.h
+++ b/quic/core/congestion_control/pacing_sender.h
@@ -66,6 +66,9 @@
   // making up for lost time.
   void OnApplicationLimited();
 
+  // Set burst_tokens_ and initial_burst_size_.
+  void SetBurstTokens(uint32_t burst_tokens);
+
   QuicTime::Delta TimeUntilSend(QuicTime now,
                                 QuicByteCount bytes_in_flight) const;
 
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index 865cf3f..061ebac 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -66,6 +66,11 @@
          transmission_type == RTO_RETRANSMISSION;
 }
 
+// If pacing rate is accurate, > 2 burst token is not likely to help first ACK
+// to arrive earlier, and overly large burst token could cause incast packet
+// losses.
+static const uint32_t kConservativeUnpacedBurst = 2;
+
 }  // namespace
 
 #define ENDPOINT                                                         \
@@ -268,6 +273,10 @@
     SetInitialRtt(rtt);
   }
   const QuicByteCount old_cwnd = send_algorithm_->GetCongestionWindow();
+  if (GetQuicReloadableFlag(quic_conservative_bursts) && using_pacing_) {
+    QUIC_RELOADABLE_FLAG_COUNT(quic_conservative_bursts);
+    pacing_sender_.SetBurstTokens(kConservativeUnpacedBurst);
+  }
   send_algorithm_->AdjustNetworkParameters(bandwidth, rtt);
   if (debug_delegate_ != nullptr) {
     debug_delegate_->OnAdjustNetworkParameters(