Internal QUICHE change

PiperOrigin-RevId: 290129985
Change-Id: I23d112a79b77da8084c078e9ed2b34d7cc07e863
diff --git a/quic/core/congestion_control/bbr2_probe_bw.cc b/quic/core/congestion_control/bbr2_probe_bw.cc
index 781e218..3c8c787 100644
--- a/quic/core/congestion_control/bbr2_probe_bw.cc
+++ b/quic/core/congestion_control/bbr2_probe_bw.cc
@@ -217,8 +217,15 @@
 
 bool Bbr2ProbeBwMode::IsTimeToProbeBandwidth(
     const Bbr2CongestionEvent& congestion_event) const {
-  return HasCycleLasted(cycle_.probe_wait_time, congestion_event) ||
-         IsTimeToProbeForRenoCoexistence(1.0, congestion_event);
+  if (HasCycleLasted(cycle_.probe_wait_time, congestion_event)) {
+    return true;
+  }
+
+  if (IsTimeToProbeForRenoCoexistence(1.0, congestion_event)) {
+    ++sender_->connection_stats_->bbr_num_short_cycles_for_reno_coexistence;
+    return true;
+  }
+  return false;
 }
 
 // QUIC only. Used to prevent a Bbr2 flow from staying in PROBE_DOWN for too
@@ -429,6 +436,7 @@
   cycle_.phase = CyclePhase::PROBE_DOWN;
   cycle_.rounds_in_phase = 0;
   cycle_.phase_start_time = congestion_event.event_time;
+  ++sender_->connection_stats_->bbr_num_cycles;
 
   // Pick probe wait time.
   cycle_.rounds_since_probe =
diff --git a/quic/core/congestion_control/bbr2_startup.cc b/quic/core/congestion_control/bbr2_startup.cc
index 090dd40..c87f715 100644
--- a/quic/core/congestion_control/bbr2_startup.cc
+++ b/quic/core/congestion_control/bbr2_startup.cc
@@ -130,6 +130,7 @@
     model_->set_inflight_hi(bdp);
 
     full_bandwidth_reached_ = true;
+    sender_->connection_stats_->bbr_exit_startup_due_to_loss = true;
   }
 
   loss_events_in_round_ = 0;
diff --git a/quic/core/congestion_control/bbr_sender.cc b/quic/core/congestion_control/bbr_sender.cc
index b4566bd..358006d 100644
--- a/quic/core/congestion_control/bbr_sender.cc
+++ b/quic/core/congestion_control/bbr_sender.cc
@@ -713,6 +713,9 @@
 
   if (should_advance_gain_cycling) {
     cycle_current_offset_ = (cycle_current_offset_ + 1) % kGainCycleLength;
+    if (cycle_current_offset_ == 0) {
+      ++stats_->bbr_num_cycles;
+    }
     last_cycle_start_ = now;
     // Stay in low gain mode until the target BDP is hit.
     // Low gain mode will be exited immediately when the target BDP is achieved.
@@ -785,9 +788,13 @@
   const QuicByteCount inflight_at_send = last_packet_send_state.bytes_in_flight;
 
   if (inflight_at_send > 0 && bytes_lost_in_round_ > 0) {
-    return bytes_lost_in_round_ >
-           inflight_at_send *
-               GetQuicFlag(FLAGS_quic_bbr2_default_loss_threshold);
+    if (bytes_lost_in_round_ >
+        inflight_at_send *
+            GetQuicFlag(FLAGS_quic_bbr2_default_loss_threshold)) {
+      stats_->bbr_exit_startup_due_to_loss = true;
+      return true;
+    }
+    return false;
   }
 
   return false;