gfe-relnote: (n/a) Pluming work for loss detection tuning using go/smartchoices. No behavior change, not protected.
This adds 4 'broadcast' points to a quic session: SetLossDetectionTuner, OnMinRttAvailable, OnConfigNegotiated and OnConnectionClosed. Currently nothing is done at these points. The next CL will implement a loss detection tuner and use it from uStreamer.
PiperOrigin-RevId: 298729689
Change-Id: I90cabde07e9d4a1ab82b66cd4d416005db5ee7ec
diff --git a/quic/core/congestion_control/general_loss_algorithm.h b/quic/core/congestion_control/general_loss_algorithm.h
index 50c5c05..9f7175f 100644
--- a/quic/core/congestion_control/general_loss_algorithm.h
+++ b/quic/core/congestion_control/general_loss_algorithm.h
@@ -47,6 +47,21 @@
QuicPacketNumber packet_number,
QuicPacketNumber previous_largest_acked) override;
+ void OnConfigNegotiated() override {
+ DCHECK(false)
+ << "Unexpected call to GeneralLossAlgorithm::OnConfigNegotiated";
+ }
+
+ void OnMinRttAvailable() override {
+ DCHECK(false)
+ << "Unexpected call to GeneralLossAlgorithm::OnMinRttAvailable";
+ }
+
+ void OnConnectionClosed() override {
+ DCHECK(false)
+ << "Unexpected call to GeneralLossAlgorithm::OnConnectionClosed";
+ }
+
void SetPacketNumberSpace(PacketNumberSpace packet_number_space);
int reordering_shift() const { return reordering_shift_; }
@@ -55,6 +70,10 @@
reordering_shift_ = reordering_shift;
}
+ void set_reordering_threshold(QuicPacketCount reordering_threshold) {
+ reordering_threshold_ = reordering_threshold;
+ }
+
bool use_adaptive_reordering_threshold() const {
return use_adaptive_reordering_threshold_;
}
diff --git a/quic/core/congestion_control/loss_detection_interface.h b/quic/core/congestion_control/loss_detection_interface.h
index 601f2f7..729cbad 100644
--- a/quic/core/congestion_control/loss_detection_interface.h
+++ b/quic/core/congestion_control/loss_detection_interface.h
@@ -39,6 +39,12 @@
QuicTime ack_receive_time,
QuicPacketNumber packet_number,
QuicPacketNumber previous_largest_acked) = 0;
+
+ virtual void OnConfigNegotiated() = 0;
+
+ virtual void OnMinRttAvailable() = 0;
+
+ virtual void OnConnectionClosed() = 0;
};
} // namespace quic
diff --git a/quic/core/congestion_control/uber_loss_algorithm.cc b/quic/core/congestion_control/uber_loss_algorithm.cc
index ad8ef3f..30d213f 100644
--- a/quic/core/congestion_control/uber_loss_algorithm.cc
+++ b/quic/core/congestion_control/uber_loss_algorithm.cc
@@ -66,12 +66,28 @@
packet_number, previous_largest_acked);
}
+void UberLossAlgorithm::SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> /*tuner*/) {}
+
+void UberLossAlgorithm::OnConfigNegotiated() {}
+
+void UberLossAlgorithm::OnMinRttAvailable() {}
+
+void UberLossAlgorithm::OnConnectionClosed() {}
+
void UberLossAlgorithm::SetReorderingShift(int reordering_shift) {
for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) {
general_loss_algorithms_[i].set_reordering_shift(reordering_shift);
}
}
+void UberLossAlgorithm::SetReorderingThreshold(
+ QuicPacketCount reordering_threshold) {
+ for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) {
+ general_loss_algorithms_[i].set_reordering_threshold(reordering_threshold);
+ }
+}
+
void UberLossAlgorithm::EnableAdaptiveReorderingThreshold() {
for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) {
general_loss_algorithms_[i].set_use_adaptive_reordering_threshold(true);
diff --git a/quic/core/congestion_control/uber_loss_algorithm.h b/quic/core/congestion_control/uber_loss_algorithm.h
index 4248553..397dda7 100644
--- a/quic/core/congestion_control/uber_loss_algorithm.h
+++ b/quic/core/congestion_control/uber_loss_algorithm.h
@@ -6,6 +6,7 @@
#define QUICHE_QUIC_CORE_CONGESTION_CONTROL_UBER_LOSS_ALGORITHM_H_
#include "net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_optional.h"
namespace quic {
@@ -15,6 +16,28 @@
} // namespace test
+struct QUIC_EXPORT_PRIVATE LossDetectionParameters {
+ // See GeneralLossAlgorithm for the meaning of reordering_(shift|threshold).
+ quiche::QuicheOptional<int> reordering_shift;
+ quiche::QuicheOptional<QuicPacketCount> reordering_threshold;
+};
+
+class QUIC_EXPORT_PRIVATE LossDetectionTunerInterface {
+ public:
+ virtual ~LossDetectionTunerInterface() {}
+
+ // Start the tuning by choosing parameters and saving them into |*params|.
+ // Called near the start of a QUIC session, see the .cc file for exactly
+ // where.
+ virtual bool Start(LossDetectionParameters* params) = 0;
+
+ // Finish tuning. The tuner is expected to use the actual loss detection
+ // performance(for its definition of performance) to improve the parameter
+ // selection for future QUIC sessions.
+ // Called when a QUIC session closes.
+ virtual void Finish(const LossDetectionParameters& params) = 0;
+};
+
// This class comprises multiple loss algorithms, each per packet number space.
class QUIC_EXPORT_PRIVATE UberLossAlgorithm : public LossDetectionInterface {
public:
@@ -41,9 +64,18 @@
QuicPacketNumber packet_number,
QuicPacketNumber previous_largest_acked) override;
+ void SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> tuner);
+ void OnConfigNegotiated() override;
+ void OnMinRttAvailable() override;
+ void OnConnectionClosed() override;
+
// Sets reordering_shift for all packet number spaces.
void SetReorderingShift(int reordering_shift);
+ // Sets reordering_threshold for all packet number spaces.
+ void SetReorderingThreshold(QuicPacketCount reordering_threshold);
+
// Enable adaptive reordering threshold of all packet number spaces.
void EnableAdaptiveReorderingThreshold();
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index f9c4da7..8fc858c 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -523,6 +523,15 @@
sent_packet_manager_.AdjustNetworkParameters(params);
}
+void QuicConnection::SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> tuner) {
+ sent_packet_manager_.SetLossDetectionTuner(std::move(tuner));
+}
+
+void QuicConnection::OnConfigNegotiated() {
+ sent_packet_manager_.OnConfigNegotiated();
+}
+
QuicBandwidth QuicConnection::MaxPacingRate() const {
return sent_packet_manager_.MaxPacingRate();
}
@@ -3000,6 +3009,7 @@
FlushPackets();
connected_ = false;
DCHECK(visitor_ != nullptr);
+ sent_packet_manager_.OnConnectionClosed();
visitor_->OnConnectionClosed(frame, source);
if (debug_visitor_ != nullptr) {
debug_visitor_->OnConnectionClosed(frame, source);
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index b4c2f44..cbfa29f 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -388,6 +388,12 @@
QuicTime::Delta rtt,
bool allow_cwnd_to_decrease);
+ // Install a loss detection tuner. Must be called before OnConfigNegotiated.
+ void SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> tuner);
+ // Called by the session when session->is_configured() becomes true.
+ void OnConfigNegotiated();
+
// Returns the max pacing rate for the connection.
virtual QuicBandwidth MaxPacingRate() const;
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index c8fd641..eb59a8e 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -339,6 +339,19 @@
}
}
+void QuicSentPacketManager::SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> tuner) {
+ uber_loss_algorithm_.SetLossDetectionTuner(std::move(tuner));
+}
+
+void QuicSentPacketManager::OnConfigNegotiated() {
+ loss_algorithm_->OnConfigNegotiated();
+}
+
+void QuicSentPacketManager::OnConnectionClosed() {
+ loss_algorithm_->OnConnectionClosed();
+}
+
void QuicSentPacketManager::SetHandshakeConfirmed() {
if (!handshake_finished_) {
handshake_finished_ = true;
@@ -951,8 +964,13 @@
}
QuicTime::Delta send_delta = ack_receive_time - transmission_info.sent_time;
+ const bool min_rtt_available = !rtt_stats_.min_rtt().IsZero();
rtt_stats_.UpdateRtt(send_delta, ack_delay_time, ack_receive_time);
+ if (!min_rtt_available && !rtt_stats_.min_rtt().IsZero()) {
+ loss_algorithm_->OnMinRttAvailable();
+ }
+
return true;
}
diff --git a/quic/core/quic_sent_packet_manager.h b/quic/core/quic_sent_packet_manager.h
index fa0634b..951cdb0 100644
--- a/quic/core/quic_sent_packet_manager.h
+++ b/quic/core/quic_sent_packet_manager.h
@@ -151,6 +151,11 @@
void AdjustNetworkParameters(
const SendAlgorithmInterface::NetworkParams& params);
+ void SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> tuner);
+ void OnConfigNegotiated();
+ void OnConnectionClosed();
+
// Retransmits the oldest pending packet there is still a tail loss probe
// pending. Invoked after OnRetransmissionTimeout.
bool MaybeRetransmitTailLossProbe();
@@ -538,7 +543,7 @@
QuicPacketCount initial_congestion_window_;
RttStats rtt_stats_;
std::unique_ptr<SendAlgorithmInterface> send_algorithm_;
- // Not owned. Always points to |general_loss_algorithm_| outside of tests.
+ // Not owned. Always points to |uber_loss_algorithm_| outside of tests.
LossDetectionInterface* loss_algorithm_;
UberLossAlgorithm uber_loss_algorithm_;
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 4df126f..de61dfe 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -1136,6 +1136,7 @@
config_.ReceivedInitialSessionFlowControlWindowBytes());
}
is_configured_ = true;
+ connection()->OnConfigNegotiated();
// Inform stream ID manager so that it can reevaluate any deferred
// STREAMS_BLOCKED or MAX_STREAMS frames against the config and either send
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h
index 7f8e251..65d2226 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -624,6 +624,11 @@
bool MaybeSetStreamPriority(QuicStreamId stream_id,
const spdy::SpdyStreamPrecedence& precedence);
+ void SetLossDetectionTuner(
+ std::unique_ptr<LossDetectionTunerInterface> tuner) {
+ connection()->SetLossDetectionTuner(std::move(tuner));
+ }
+
private:
friend class test::QuicSessionPeer;
diff --git a/quic/test_tools/quic_test_utils.h b/quic/test_tools/quic_test_utils.h
index b20f90e..6b8403c 100644
--- a/quic/test_tools/quic_test_utils.h
+++ b/quic/test_tools/quic_test_utils.h
@@ -997,6 +997,10 @@
QuicTime,
QuicPacketNumber,
QuicPacketNumber));
+
+ MOCK_METHOD0(OnConfigNegotiated, void());
+ MOCK_METHOD0(OnMinRttAvailable, void());
+ MOCK_METHOD0(OnConnectionClosed, void());
};
class MockAckListener : public QuicAckListenerInterface {