Internal QUICHE change PiperOrigin-RevId: 282443752 Change-Id: Ifd6e39c3080ef3f6c477d9ae5b9750b4b2588166
diff --git a/quic/core/congestion_control/bandwidth_sampler.cc b/quic/core/congestion_control/bandwidth_sampler.cc index 2555e0f..cc90cb0 100644 --- a/quic/core/congestion_control/bandwidth_sampler.cc +++ b/quic/core/congestion_control/bandwidth_sampler.cc
@@ -21,6 +21,7 @@ if (aggregation_epoch_start_time_ == QuicTime::Zero()) { aggregation_epoch_bytes_ = bytes_acked; aggregation_epoch_start_time_ = ack_time; + ++num_ack_aggregation_epochs_; return 0; } @@ -36,6 +37,7 @@ // Reset to start measuring a new aggregation epoch. aggregation_epoch_bytes_ = bytes_acked; aggregation_epoch_start_time_ = ack_time; + ++num_ack_aggregation_epochs_; return 0; }
diff --git a/quic/core/congestion_control/bandwidth_sampler.h b/quic/core/congestion_control/bandwidth_sampler.h index b27e3a1..51f5e87 100644 --- a/quic/core/congestion_control/bandwidth_sampler.h +++ b/quic/core/congestion_control/bandwidth_sampler.h
@@ -100,6 +100,10 @@ max_ack_height_filter_.Reset(new_height, new_time); } + uint64_t num_ack_aggregation_epochs() const { + return num_ack_aggregation_epochs_; + } + private: // Tracks the maximum number of bytes acked faster than the estimated // bandwidth. @@ -113,6 +117,9 @@ // The time this aggregation started and the number of bytes acked during it. QuicTime aggregation_epoch_start_time_ = QuicTime::Zero(); QuicByteCount aggregation_epoch_bytes_ = 0; + // The number of ack aggregation epochs ever started, including the ongoing + // one. Stats only. + uint64_t num_ack_aggregation_epochs_ = 0; }; // An interface common to any class that can provide bandwidth samples from the @@ -273,6 +280,10 @@ QuicByteCount max_ack_height() const { return max_ack_height_tracker_.Get(); } + uint64_t num_ack_aggregation_epochs() const { + return max_ack_height_tracker_.num_ack_aggregation_epochs(); + } + void SetMaxAckHeightTrackerWindowLength(QuicRoundTripCount length) { max_ack_height_tracker_.SetFilterWindowLength(length); }
diff --git a/quic/core/congestion_control/bandwidth_sampler_test.cc b/quic/core/congestion_control/bandwidth_sampler_test.cc index 558971a..59318a9 100644 --- a/quic/core/congestion_control/bandwidth_sampler_test.cc +++ b/quic/core/congestion_control/bandwidth_sampler_test.cc
@@ -551,6 +551,7 @@ AggregationEpisode(bandwidth_ * 20, QuicTime::Delta::FromMilliseconds(6), 1200, false); + EXPECT_EQ(2u, tracker_.num_ack_aggregation_epochs()); } TEST_F(MaxAckHeightTrackerTest, VeryAggregatedSmallAcks) { @@ -562,6 +563,7 @@ AggregationEpisode(bandwidth_ * 20, QuicTime::Delta::FromMilliseconds(6), 300, false); + EXPECT_EQ(2u, tracker_.num_ack_aggregation_epochs()); } TEST_F(MaxAckHeightTrackerTest, SomewhatAggregatedLargeAck) { @@ -573,6 +575,7 @@ AggregationEpisode(bandwidth_ * 2, QuicTime::Delta::FromMilliseconds(50), 1000, false); + EXPECT_EQ(2u, tracker_.num_ack_aggregation_epochs()); } TEST_F(MaxAckHeightTrackerTest, SomewhatAggregatedSmallAcks) { @@ -584,11 +587,13 @@ AggregationEpisode(bandwidth_ * 2, QuicTime::Delta::FromMilliseconds(50), 100, false); + EXPECT_EQ(2u, tracker_.num_ack_aggregation_epochs()); } TEST_F(MaxAckHeightTrackerTest, NotAggregated) { AggregationEpisode(bandwidth_, QuicTime::Delta::FromMilliseconds(100), 100, true); + EXPECT_LT(2u, tracker_.num_ack_aggregation_epochs()); } } // namespace test
diff --git a/quic/core/congestion_control/bbr2_misc.h b/quic/core/congestion_control/bbr2_misc.h index 139b120..8f08a58 100644 --- a/quic/core/congestion_control/bbr2_misc.h +++ b/quic/core/congestion_control/bbr2_misc.h
@@ -331,6 +331,10 @@ return bandwidth_sampler_.max_ack_height(); } + uint64_t num_ack_aggregation_epochs() const { + return bandwidth_sampler_.num_ack_aggregation_epochs(); + } + bool MaybeExpireMinRtt(const Bbr2CongestionEvent& congestion_event); QuicBandwidth BandwidthEstimate() const {
diff --git a/quic/core/congestion_control/bbr2_sender.cc b/quic/core/congestion_control/bbr2_sender.cc index 73787a2..31bf299 100644 --- a/quic/core/congestion_control/bbr2_sender.cc +++ b/quic/core/congestion_control/bbr2_sender.cc
@@ -311,6 +311,10 @@ << ", CWND: " << GetCongestionWindow(); } +void Bbr2Sender::PopulateConnectionStats(QuicConnectionStats* stats) const { + stats->num_ack_aggregation_epochs = model_.num_ack_aggregation_epochs(); +} + bool Bbr2Sender::ShouldSendProbingPacket() const { // TODO(wub): Implement ShouldSendProbingPacket properly. if (!BBR2_MODE_DISPATCH(IsProbingForBandwidth())) {
diff --git a/quic/core/congestion_control/bbr2_sender.h b/quic/core/congestion_control/bbr2_sender.h index f0a3b5f..4cfd34c 100644 --- a/quic/core/congestion_control/bbr2_sender.h +++ b/quic/core/congestion_control/bbr2_sender.h
@@ -87,6 +87,8 @@ std::string GetDebugState() const override; void OnApplicationLimited(QuicByteCount bytes_in_flight) override; + + void PopulateConnectionStats(QuicConnectionStats* stats) const override; // End implementation of SendAlgorithmInterface. const Bbr2Params& Params() const { return params_; }
diff --git a/quic/core/congestion_control/bbr_sender.cc b/quic/core/congestion_control/bbr_sender.cc index 4217048..0096ca5 100644 --- a/quic/core/congestion_control/bbr_sender.cc +++ b/quic/core/congestion_control/bbr_sender.cc
@@ -905,6 +905,10 @@ << last_sent_packet_ << ", CWND: " << GetCongestionWindow(); } +void BbrSender::PopulateConnectionStats(QuicConnectionStats* stats) const { + stats->num_ack_aggregation_epochs = sampler_.num_ack_aggregation_epochs(); +} + BbrSender::DebugState BbrSender::ExportDebugState() const { return DebugState(*this); }
diff --git a/quic/core/congestion_control/bbr_sender.h b/quic/core/congestion_control/bbr_sender.h index 8c07a40..dc512cf 100644 --- a/quic/core/congestion_control/bbr_sender.h +++ b/quic/core/congestion_control/bbr_sender.h
@@ -128,6 +128,7 @@ CongestionControlType GetCongestionControlType() const override; std::string GetDebugState() const override; void OnApplicationLimited(QuicByteCount bytes_in_flight) override; + void PopulateConnectionStats(QuicConnectionStats* stats) const override; // End implementation of SendAlgorithmInterface. // Gets the number of RTTs BBR remains in STARTUP phase.
diff --git a/quic/core/congestion_control/send_algorithm_interface.h b/quic/core/congestion_control/send_algorithm_interface.h index 2c183f1..628e0d6 100644 --- a/quic/core/congestion_control/send_algorithm_interface.h +++ b/quic/core/congestion_control/send_algorithm_interface.h
@@ -168,6 +168,9 @@ // such cases, it should use the internal state it uses for congestion control // for that. virtual void OnApplicationLimited(QuicByteCount bytes_in_flight) = 0; + + // Called before connection close to collect stats. + virtual void PopulateConnectionStats(QuicConnectionStats* stats) const = 0; }; } // namespace quic
diff --git a/quic/core/congestion_control/tcp_cubic_sender_bytes.h b/quic/core/congestion_control/tcp_cubic_sender_bytes.h index 8e89eaa..9144b8a 100644 --- a/quic/core/congestion_control/tcp_cubic_sender_bytes.h +++ b/quic/core/congestion_control/tcp_cubic_sender_bytes.h
@@ -73,6 +73,7 @@ bool ShouldSendProbingPacket() const override; std::string GetDebugState() const override; void OnApplicationLimited(QuicByteCount bytes_in_flight) override; + void PopulateConnectionStats(QuicConnectionStats* /*stats*/) const override {} // End implementation of SendAlgorithmInterface. QuicByteCount min_congestion_window() const { return min_congestion_window_; }
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc index a4efa01..43e7b85 100644 --- a/quic/core/quic_connection.cc +++ b/quic/core/quic_connection.cc
@@ -1720,6 +1720,10 @@ stats_.srtt_us = srtt.ToMicroseconds(); stats_.estimated_bandwidth = sent_packet_manager_.BandwidthEstimate(); + if (GetQuicReloadableFlag(quic_log_ack_aggregation_stats)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_log_ack_aggregation_stats); + sent_packet_manager_.GetSendAlgorithm()->PopulateConnectionStats(&stats_); + } stats_.max_packet_size = packet_creator_.max_packet_length(); stats_.max_received_packet_size = largest_received_packet_size_; return stats_;
diff --git a/quic/core/quic_connection_stats.cc b/quic/core/quic_connection_stats.cc index ff067bd..43f6095 100644 --- a/quic/core/quic_connection_stats.cc +++ b/quic/core/quic_connection_stats.cc
@@ -48,7 +48,8 @@ num_connectivity_probing_received(0), retry_packet_processed(false), num_coalesced_packets_received(0), - num_coalesced_packets_processed(0) {} + num_coalesced_packets_processed(0), + num_ack_aggregation_epochs(0) {} QuicConnectionStats::QuicConnectionStats(const QuicConnectionStats& other) = default; @@ -101,6 +102,7 @@ os << " num_coalesced_packets_received: " << s.num_coalesced_packets_received; os << " num_coalesced_packets_processed: " << s.num_coalesced_packets_processed; + os << " num_ack_aggregation_epochs: " << s.num_ack_aggregation_epochs; os << " }"; return os;
diff --git a/quic/core/quic_connection_stats.h b/quic/core/quic_connection_stats.h index 552e8a6..35bf6cc 100644 --- a/quic/core/quic_connection_stats.h +++ b/quic/core/quic_connection_stats.h
@@ -113,6 +113,9 @@ uint64_t num_coalesced_packets_received; // Number of successfully processed coalesced packets. uint64_t num_coalesced_packets_processed; + // Number of ack aggregation epochs. For the same number of bytes acked, the + // smaller this value, the more ack aggregation is going on. + uint64_t num_ack_aggregation_epochs; }; } // namespace quic
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc index 111f94f..f9de358 100644 --- a/quic/core/quic_connection_test.cc +++ b/quic/core/quic_connection_test.cc
@@ -1035,6 +1035,8 @@ EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) .Times(AnyNumber()) .WillRepeatedly(Return(QuicBandwidth::Zero())); + EXPECT_CALL(*send_algorithm_, PopulateConnectionStats(_)) + .Times(AnyNumber()); EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber());
diff --git a/quic/test_tools/quic_test_utils.h b/quic/test_tools/quic_test_utils.h index 27ffee3..c3c29fa 100644 --- a/quic/test_tools/quic_test_utils.h +++ b/quic/test_tools/quic_test_utils.h
@@ -951,6 +951,7 @@ void(QuicBandwidth, QuicTime::Delta, bool)); MOCK_METHOD1(AdjustNetworkParameters, void(const NetworkParams&)); MOCK_METHOD1(OnApplicationLimited, void(QuicByteCount)); + MOCK_CONST_METHOD1(PopulateConnectionStats, void(QuicConnectionStats*)); }; class MockLossAlgorithm : public LossDetectionInterface {