gfe-relnote: (n/a) In QUIC BBRv2, only update max bandwidth filter per ack event. Protected by existing flag --gfe2_reloadable_flag_quic_default_to_bbr_v2.

PiperOrigin-RevId: 259612475
Change-Id: I7684d92d2af3e9407f93bc52181219be38802c26
diff --git a/quic/core/congestion_control/bbr2_misc.cc b/quic/core/congestion_control/bbr2_misc.cc
index 507290b..f5e3d18 100644
--- a/quic/core/congestion_control/bbr2_misc.cc
+++ b/quic/core/congestion_control/bbr2_misc.cc
@@ -143,8 +143,6 @@
                             : round_trip_counter_.OnPacketsAcked(
                                   acked_packets.rbegin()->packet_number);
 
-  // TODO(wub): Get the max bandwidth sample from all acked_packets, then use it
-  // to update max_bandwidth_filter_ once after the loop.
   for (const auto& packet : acked_packets) {
     const BandwidthSample bandwidth_sample =
         bandwidth_sampler_.OnPacketAcknowledged(event_time,
@@ -163,7 +161,8 @@
     }
     if (!bandwidth_sample.state_at_send.is_app_limited ||
         bandwidth_sample.bandwidth > MaxBandwidth()) {
-      max_bandwidth_filter_.Update(bandwidth_sample.bandwidth);
+      congestion_event->sample_max_bandwidth = std::max(
+          congestion_event->sample_max_bandwidth, bandwidth_sample.bandwidth);
     }
 
     if (bandwidth_sample.bandwidth > bandwidth_latest_) {
@@ -182,6 +181,9 @@
   }
 
   min_rtt_filter_.Update(congestion_event->sample_min_rtt, event_time);
+  if (!congestion_event->sample_max_bandwidth.IsZero()) {
+    max_bandwidth_filter_.Update(congestion_event->sample_max_bandwidth);
+  }
 
   for (const LostPacket& packet : lost_packets) {
     const SendTimeState send_time_state =
diff --git a/quic/core/congestion_control/bbr2_misc.h b/quic/core/congestion_control/bbr2_misc.h
index 08717a2..1b695e3 100644
--- a/quic/core/congestion_control/bbr2_misc.h
+++ b/quic/core/congestion_control/bbr2_misc.h
@@ -246,6 +246,9 @@
   // QuicTime::Delta::Infinite() if acked_packets is empty.
   QuicTime::Delta sample_min_rtt = QuicTime::Delta::Infinite();
 
+  // Maximum bandwidth of all bandwidth samples from acked_packets.
+  QuicBandwidth sample_max_bandwidth = QuicBandwidth::Zero();
+
   // Send time state of the largest-numbered packet in this event.
   // SendTimeState send_time_state;
   struct {