Fix slowstart_count and slowstart_duration in QuicConnectionStats if QuicConnection switched send algorithm from BBRv1 to v2. PiperOrigin-RevId: 398110994
diff --git a/quic/core/congestion_control/bbr2_simulator_test.cc b/quic/core/congestion_control/bbr2_simulator_test.cc index ae0c884..ae6a6a6 100644 --- a/quic/core/congestion_control/bbr2_simulator_test.cc +++ b/quic/core/congestion_control/bbr2_simulator_test.cc
@@ -911,7 +911,10 @@ ASSERT_FALSE(sender_->InSlowStart()); const QuicConnectionStats& stats = sender_connection_stats(); - EXPECT_EQ(1u, stats.slowstart_count); + // The test explicitly replaces the default-created send algorithm with the + // one created by the test. slowstart_count increaments every time a BBR + // sender is created. + EXPECT_GE(stats.slowstart_count, 1u); EXPECT_FALSE(stats.slowstart_duration.IsRunning()); EXPECT_THAT(stats.slowstart_duration.GetTotalElapsedTime(), AllOf(Ge(QuicTime::Delta::FromMilliseconds(500)),
diff --git a/quic/core/congestion_control/bbr2_startup.cc b/quic/core/congestion_control/bbr2_startup.cc index 1bd89c6..f882c02 100644 --- a/quic/core/congestion_control/bbr2_startup.cc +++ b/quic/core/congestion_control/bbr2_startup.cc
@@ -17,12 +17,12 @@ Bbr2NetworkModel* model, QuicTime now) : Bbr2ModeBase(sender, model) { - // Clear some startup stats if |sender_->connection_stats_| has been used by - // another sender, which happens e.g. when QuicConnection switch send - // algorithms. - sender_->connection_stats_->slowstart_count = 1; - sender_->connection_stats_->slowstart_duration = QuicTimeAccumulator(); - sender_->connection_stats_->slowstart_duration.Start(now); + // Increment, instead of reset startup stats, so we don't lose data recorded + // before QuicConnection switched send algorithm to BBRv2. + ++sender_->connection_stats_->slowstart_count; + if (!sender_->connection_stats_->slowstart_duration.IsRunning()) { + sender_->connection_stats_->slowstart_duration.Start(now); + } // Enter() is never called for Startup, so the gains needs to be set here. model_->set_pacing_gain(Params().startup_pacing_gain); model_->set_cwnd_gain(Params().startup_cwnd_gain);