Fix a bug in QUIC BBRv2 with min_bytes_in_flight_in_round_ where it would reset if it was 0, which is a valid value.  Also set it when sending a packet, to fix potential issues exiting quiescence.

PiperOrigin-RevId: 466917178
diff --git a/quiche/quic/core/congestion_control/bbr2_misc.cc b/quiche/quic/core/congestion_control/bbr2_misc.cc
index bd0851a..6cc2852 100644
--- a/quiche/quic/core/congestion_control/bbr2_misc.cc
+++ b/quiche/quic/core/congestion_control/bbr2_misc.cc
@@ -76,6 +76,11 @@
                                     QuicPacketNumber packet_number,
                                     QuicByteCount bytes,
                                     HasRetransmittableData is_retransmittable) {
+  // Updating the min here ensures a more realistic (0) value when flows exit
+  // quiescence.
+  if (bytes_in_flight < min_bytes_in_flight_in_round_) {
+    min_bytes_in_flight_in_round_ = bytes_in_flight;
+  }
   round_trip_counter_.OnPacketSent(packet_number);
 
   bandwidth_sampler_.OnPacketSent(sent_time, packet_number, bytes,
@@ -160,12 +165,11 @@
         congestion_event->last_packet_send_state.total_bytes_acked;
     max_bytes_delivered_in_round_ =
         std::max(max_bytes_delivered_in_round_, bytes_delivered);
-    // TODO(ianswett) Consider treating any bytes lost as decreasing inflight,
-    // because it's a sign of overutilization, not underutilization.
-    if (min_bytes_in_flight_in_round_ == 0 ||
-        congestion_event->bytes_in_flight < min_bytes_in_flight_in_round_) {
-      min_bytes_in_flight_in_round_ = congestion_event->bytes_in_flight;
-    }
+  }
+  // TODO(ianswett) Consider treating any bytes lost as decreasing inflight,
+  // because it's a sign of overutilization, not underutilization.
+  if (congestion_event->bytes_in_flight < min_bytes_in_flight_in_round_) {
+    min_bytes_in_flight_in_round_ = congestion_event->bytes_in_flight;
   }
 
   // |bandwidth_latest_| and |inflight_latest_| only increased within a round.
@@ -378,7 +382,7 @@
   bytes_lost_in_round_ = 0;
   loss_events_in_round_ = 0;
   max_bytes_delivered_in_round_ = 0;
-  min_bytes_in_flight_in_round_ = 0;
+  min_bytes_in_flight_in_round_ = std::numeric_limits<uint64_t>::max();
 }
 
 void Bbr2NetworkModel::cap_inflight_lo(QuicByteCount cap) {
@@ -432,6 +436,8 @@
 bool Bbr2NetworkModel::CheckPersistentQueue(
     const Bbr2CongestionEvent& congestion_event, float bdp_gain) {
   QUICHE_DCHECK(congestion_event.end_of_round_trip);
+  QUICHE_DCHECK_NE(min_bytes_in_flight_in_round_,
+                   std::numeric_limits<uint64_t>::max());
   QuicByteCount target = bdp_gain * BDP();
   if (bdp_gain >= 2) {
     // Use a more conservative threshold for STARTUP because CWND gain is 2.
diff --git a/quiche/quic/core/congestion_control/bbr2_misc.h b/quiche/quic/core/congestion_control/bbr2_misc.h
index 66b5764..3c85e85 100644
--- a/quiche/quic/core/congestion_control/bbr2_misc.h
+++ b/quiche/quic/core/congestion_control/bbr2_misc.h
@@ -560,7 +560,8 @@
   QuicByteCount max_bytes_delivered_in_round_ = 0;
 
   // The minimum bytes in flight during this round.
-  QuicByteCount min_bytes_in_flight_in_round_ = 0;
+  QuicByteCount min_bytes_in_flight_in_round_ =
+      std::numeric_limits<uint64_t>::max();
 
   // Max bandwidth in the current round. Updated once per congestion event.
   QuicBandwidth bandwidth_latest_ = QuicBandwidth::Zero();