Define kAlarmGranularity and use it in the non-test QUIC code. gfe-relnote: n/a (Define a constant) PiperOrigin-RevId: 286223502 Change-Id: I71046cd1bcb9f20aadcbab9748697ca1554b34a4
diff --git a/quic/core/congestion_control/general_loss_algorithm.cc b/quic/core/congestion_control/general_loss_algorithm.cc index 786f610..0f1c024 100644 --- a/quic/core/congestion_control/general_loss_algorithm.cc +++ b/quic/core/congestion_control/general_loss_algorithm.cc
@@ -96,7 +96,7 @@ QuicTime::Delta max_rtt = std::max(rtt_stats.previous_srtt(), rtt_stats.latest_rtt()); if (loss_type_ == kIetfLossDetection) { - max_rtt = std::max(QuicTime::Delta::FromMilliseconds(1), max_rtt); + max_rtt = std::max(kAlarmGranularity, max_rtt); } QuicTime::Delta loss_delay = max_rtt + (max_rtt >> reordering_shift_); if (loss_type_ != kIetfLossDetection) {
diff --git a/quic/core/congestion_control/pacing_sender.cc b/quic/core/congestion_control/pacing_sender.cc index dbdc924..2ba07ab 100644 --- a/quic/core/congestion_control/pacing_sender.cc +++ b/quic/core/congestion_control/pacing_sender.cc
@@ -25,7 +25,7 @@ ideal_next_packet_send_time_(QuicTime::Zero()), initial_burst_size_(kInitialUnpacedBurst), lumpy_tokens_(0), - alarm_granularity_(QuicTime::Delta::FromMilliseconds(1)), + alarm_granularity_(kAlarmGranularity), pacing_limited_(false) { if (GetQuicReloadableFlag(quic_donot_reset_ideal_next_packet_send_time)) { QUIC_RELOADABLE_FLAG_COUNT(quic_donot_reset_ideal_next_packet_send_time);
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc index 1d176d7..b5161d4 100644 --- a/quic/core/quic_connection.cc +++ b/quic/core/quic_connection.cc
@@ -23,6 +23,7 @@ #include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" #include "net/third_party/quiche/src/quic/core/quic_config.h" #include "net/third_party/quiche/src/quic/core/quic_connection_id.h" +#include "net/third_party/quiche/src/quic/core/quic_constants.h" #include "net/third_party/quiche/src/quic/core/quic_error_codes.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" @@ -2142,7 +2143,7 @@ return true; } // Cannot send packet now because delay is too far in the future. - send_alarm_->Update(now + delay, QuicTime::Delta::FromMilliseconds(1)); + send_alarm_->Update(now + delay, kAlarmGranularity); QUIC_DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() << "ms"; return false; @@ -3145,7 +3146,7 @@ // Use a shorter timeout if there are open streams, but nothing on the wire. ping_alarm_->Update( clock_->ApproximateNow() + retransmittable_on_wire_timeout, - QuicTime::Delta::FromMilliseconds(1)); + kAlarmGranularity); if (max_aggressive_retransmittable_on_wire_ping_count != 0) { consecutive_retransmittable_on_wire_ping_count_++; } @@ -3153,7 +3154,7 @@ } ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout_, - QuicTime::Delta::FromMilliseconds(1)); + kAlarmGranularity); } void QuicConnection::SetRetransmissionAlarm() { @@ -3169,7 +3170,7 @@ } retransmission_alarm_->Update(sent_packet_manager_.GetRetransmissionTime(), - QuicTime::Delta::FromMilliseconds(1)); + kAlarmGranularity); } void QuicConnection::SetPathDegradingAlarm() { @@ -3178,7 +3179,7 @@ } const QuicTime::Delta delay = sent_packet_manager_.GetPathDegradingDelay(); path_degrading_alarm_->Update(clock_->ApproximateNow() + delay, - QuicTime::Delta::FromMilliseconds(1)); + kAlarmGranularity); } void QuicConnection::MaybeSetMtuAlarm(QuicPacketNumber sent_packet_number) {
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc index efe3544..baa41be 100644 --- a/quic/core/quic_connection_test.cc +++ b/quic/core/quic_connection_test.cc
@@ -5856,8 +5856,7 @@ QuicConnectionPeer::SetFastAckAfterQuiescence(&connection_, true); // The beginning of the connection counts as quiescence. - QuicTime ack_time = - clock_.ApproximateNow() + QuicTime::Delta::FromMilliseconds(1); + QuicTime ack_time = clock_.ApproximateNow() + kAlarmGranularity; EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; @@ -5915,7 +5914,7 @@ EXPECT_FALSE(writer_->ack_frames().empty()); EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); - // Wait 1 second and enesure the ack alarm is set to 1ms in the future. + // Wait 1 second and ensure the ack alarm is set to 1ms in the future. clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); ack_time = clock_.ApproximateNow() + QuicTime::Delta::FromMilliseconds(1); EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
diff --git a/quic/core/quic_constants.h b/quic/core/quic_constants.h index 0b087b4..aad6d3a 100644 --- a/quic/core/quic_constants.h +++ b/quic/core/quic_constants.h
@@ -259,6 +259,9 @@ // rapidly increasing. const QuicPacketCount kMinReceivedBeforeAckDecimation = 100; +// The default alarm granularity assumed by QUIC code. +const QuicTime::Delta kAlarmGranularity = QuicTime::Delta::FromMilliseconds(1); + // Packet number of first sending packet of a connection. Please note, this // cannot be used as first received packet because peer can choose its starting // packet number.
diff --git a/quic/core/quic_received_packet_manager.cc b/quic/core/quic_received_packet_manager.cc index 908d04f..86b060e 100644 --- a/quic/core/quic_received_packet_manager.cc +++ b/quic/core/quic_received_packet_manager.cc
@@ -250,7 +250,7 @@ // Ack the first packet out of queiscence faster, because QUIC does // not pace the first few packets and commonly these may be handshake // or TLP packets, which we'd like to acknowledge quickly. - ack_delay = QuicTime::Delta::FromMilliseconds(1); + ack_delay = kAlarmGranularity; } MaybeUpdateAckTimeoutTo(now + ack_delay); } else { @@ -264,7 +264,7 @@ // Ack the first packet out of queiscence faster, because QUIC does // not pace the first few packets and commonly these may be handshake // or TLP packets, which we'd like to acknowledge quickly. - MaybeUpdateAckTimeoutTo(now + QuicTime::Delta::FromMilliseconds(1)); + MaybeUpdateAckTimeoutTo(now + kAlarmGranularity); } else { MaybeUpdateAckTimeoutTo(now + local_max_ack_delay_); }
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc index fdf4f03..5ee7896 100644 --- a/quic/core/quic_sent_packet_manager.cc +++ b/quic/core/quic_sent_packet_manager.cc
@@ -142,11 +142,11 @@ } if (config.HasClientSentConnectionOption(kMAD2, perspective)) { // Set the minimum to the alarm granularity. - min_tlp_timeout_ = QuicTime::Delta::FromMilliseconds(1); + min_tlp_timeout_ = kAlarmGranularity; } if (config.HasClientSentConnectionOption(kMAD3, perspective)) { // Set the minimum to the alarm granularity. - min_rto_timeout_ = QuicTime::Delta::FromMilliseconds(1); + min_rto_timeout_ = kAlarmGranularity; } if (GetQuicReloadableFlag(quic_enable_pto)) { @@ -1082,7 +1082,7 @@ const QuicTime::Delta pto_delay = rtt_stats_.smoothed_rtt() + std::max(pto_rttvar_multiplier_ * rtt_stats_.mean_deviation(), - QuicTime::Delta::FromMilliseconds(1)) + + kAlarmGranularity) + (ShouldAddMaxAckDelay() ? peer_max_ack_delay_ : QuicTime::Delta::Zero()); return pto_delay * (1 << (consecutive_pto_count_ - std::min(consecutive_pto_count_,
diff --git a/quic/core/uber_received_packet_manager.cc b/quic/core/uber_received_packet_manager.cc index 78cf359..f62e1ea 100644 --- a/quic/core/uber_received_packet_manager.cc +++ b/quic/core/uber_received_packet_manager.cc
@@ -115,9 +115,9 @@ // In IETF QUIC, the peer is expected to acknowledge packets in Initial and // Handshake packets with minimal delay. received_packet_managers_[INITIAL_DATA].set_local_max_ack_delay( - QuicTime::Delta::FromMilliseconds(1)); + kAlarmGranularity); received_packet_managers_[HANDSHAKE_DATA].set_local_max_ack_delay( - QuicTime::Delta::FromMilliseconds(1)); + kAlarmGranularity); supports_multiple_packet_number_spaces_ = true; }