Skip to content

Commit bdc8698

Browse files
Tarun BansalCommit Bot
Tarun Bansal
authored and
Commit Bot
committed
Record count of end to end RTT observations
This will be used in a subsequent CL to change the HTTP RTT estimate of the count of end to end RTT observations is more than a certain threshold. Change-Id: I4268568e2c7df0c45651fdecb19ba59925430565 Bug: 834119 Reviewed-on: https://chromium-review.googlesource.com/1117771 Reviewed-by: Ryan Sturm <ryansturm@chromium.org> Commit-Queue: Tarun Bansal <tbansal@chromium.org> Cr-Commit-Position: refs/heads/master@{#575770}
1 parent 2130596 commit bdc8698

5 files changed

+32
-11
lines changed

net/nqe/network_quality_estimator.cc

+15-6
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ NetworkQualityEstimator::NetworkQualityEstimator(
236236
rtt_observations_size_at_last_ect_computation_(0),
237237
throughput_observations_size_at_last_ect_computation_(0),
238238
transport_rtt_observation_count_last_ect_computation_(0),
239+
end_to_end_rtt_observation_count_at_last_ect_computation_(0),
239240
new_rtt_observations_since_last_ect_computation_(0),
240241
new_throughput_observations_since_last_ect_computation_(0),
241242
increase_in_transport_rtt_updater_posted_(false),
@@ -695,6 +696,7 @@ void NetworkQualityEstimator::OnConnectionTypeChanged(
695696
min_signal_strength_since_connection_change_.reset();
696697
max_signal_strength_since_connection_change_.reset();
697698
network_quality_ = nqe::internal::NetworkQuality();
699+
end_to_end_rtt_ = base::nullopt;
698700
effective_connection_type_ = EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
699701
effective_connection_type_at_last_main_frame_ =
700702
EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
@@ -703,6 +705,7 @@ void NetworkQualityEstimator::OnConnectionTypeChanged(
703705
new_rtt_observations_since_last_ect_computation_ = 0;
704706
new_throughput_observations_since_last_ect_computation_ = 0;
705707
transport_rtt_observation_count_last_ect_computation_ = 0;
708+
end_to_end_rtt_observation_count_at_last_ect_computation_ = 0;
706709
last_socket_watcher_rtt_notification_ = base::TimeTicks();
707710
estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality();
708711
cached_estimate_applied_ = false;
@@ -1023,7 +1026,8 @@ void NetworkQualityEstimator::ComputeEffectiveConnectionType() {
10231026
GetRecentEffectiveConnectionTypeAndNetworkQuality(
10241027
base::TimeTicks(), &http_rtt, &transport_rtt, &end_to_end_rtt,
10251028
&downstream_throughput_kbps,
1026-
&transport_rtt_observation_count_last_ect_computation_);
1029+
&transport_rtt_observation_count_last_ect_computation_,
1030+
&end_to_end_rtt_observation_count_at_last_ect_computation_);
10271031

10281032
network_quality_ = nqe::internal::NetworkQuality(http_rtt, transport_rtt,
10291033
downstream_throughput_kbps);
@@ -1045,6 +1049,9 @@ void NetworkQualityEstimator::ComputeEffectiveConnectionType() {
10451049
if (end_to_end_rtt != nqe::internal::InvalidRTT()) {
10461050
UMA_HISTOGRAM_TIMES("NQE.EndToEndRTT.OnECTComputation", end_to_end_rtt);
10471051
}
1052+
end_to_end_rtt_ = base::nullopt;
1053+
if (end_to_end_rtt != nqe::internal::InvalidRTT())
1054+
end_to_end_rtt_ = end_to_end_rtt;
10481055

10491056
if (network_quality_.downstream_throughput_kbps() !=
10501057
nqe::internal::INVALID_RTT_THROUGHPUT) {
@@ -1089,7 +1096,7 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionType(
10891096

10901097
return GetRecentEffectiveConnectionTypeAndNetworkQuality(
10911098
start_time, &http_rtt, &transport_rtt, &end_to_end_rtt,
1092-
&downstream_throughput_kbps, nullptr);
1099+
&downstream_throughput_kbps, nullptr, nullptr);
10931100
}
10941101

10951102
EffectiveConnectionType
@@ -1099,7 +1106,8 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionTypeAndNetworkQuality(
10991106
base::TimeDelta* transport_rtt,
11001107
base::TimeDelta* end_to_end_rtt,
11011108
int32_t* downstream_throughput_kbps,
1102-
size_t* transport_rtt_observation_count) const {
1109+
size_t* transport_rtt_observation_count,
1110+
size_t* end_to_end_rtt_observation_count) const {
11031111
DCHECK(thread_checker_.CalledOnValidThread());
11041112

11051113
return GetRecentEffectiveConnectionTypeUsingMetrics(
@@ -1110,7 +1118,7 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionTypeAndNetworkQuality(
11101118
NetworkQualityEstimator::MetricUsage::
11111119
USE_IF_AVAILABLE /* downstream_throughput_kbps_metric */,
11121120
http_rtt, transport_rtt, end_to_end_rtt, downstream_throughput_kbps,
1113-
transport_rtt_observation_count);
1121+
transport_rtt_observation_count, end_to_end_rtt_observation_count);
11141122
}
11151123

11161124
EffectiveConnectionType
@@ -1123,7 +1131,8 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionTypeUsingMetrics(
11231131
base::TimeDelta* transport_rtt,
11241132
base::TimeDelta* end_to_end_rtt,
11251133
int32_t* downstream_throughput_kbps,
1126-
size_t* transport_rtt_observation_count) const {
1134+
size_t* transport_rtt_observation_count,
1135+
size_t* end_to_end_rtt_observation_count) const {
11271136
DCHECK(thread_checker_.CalledOnValidThread());
11281137

11291138
*http_rtt = nqe::internal::InvalidRTT();
@@ -1161,7 +1170,7 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionTypeUsingMetrics(
11611170
}
11621171

11631172
if (!GetRecentRTT(nqe::internal::OBSERVATION_CATEGORY_END_TO_END, start_time,
1164-
end_to_end_rtt, nullptr)) {
1173+
end_to_end_rtt, end_to_end_rtt_observation_count)) {
11651174
*end_to_end_rtt = nqe::internal::InvalidRTT();
11661175
}
11671176

net/nqe/network_quality_estimator.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ class NET_EXPORT NetworkQualityEstimator
291291
base::TimeDelta* transport_rtt,
292292
base::TimeDelta* end_to_end_rtt,
293293
int32_t* downstream_throughput_kbps,
294-
size_t* transport_rtt_observation_count) const;
294+
size_t* transport_rtt_observation_count,
295+
size_t* end_to_end_rtt_observation_count) const;
295296

296297
// Notifies |this| of a new transport layer RTT. Called by socket watchers.
297298
// Protected for testing.
@@ -397,6 +398,8 @@ class NET_EXPORT NetworkQualityEstimator
397398
TestComputeIncreaseInTransportRTTPartialHostsOverlap);
398399
FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
399400
ObservationDiscardedIfCachedEstimateAvailable);
401+
FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
402+
TestRttThroughputObservers);
400403

401404
// Defines how a metric (e.g, transport RTT) should be used when computing
402405
// the effective connection type.
@@ -484,7 +487,8 @@ class NET_EXPORT NetworkQualityEstimator
484487
base::TimeDelta* transport_rtt,
485488
base::TimeDelta* end_to_end_rtt,
486489
int32_t* downstream_throughput_kbps,
487-
size_t* transport_rtt_observation_count) const;
490+
size_t* transport_rtt_observation_count,
491+
size_t* end_to_end_rtt_observation_count) const;
488492

489493
// Returns true if the cached network quality estimate was successfully read.
490494
bool ReadCachedNetworkQualityEstimate();
@@ -598,6 +602,7 @@ class NET_EXPORT NetworkQualityEstimator
598602

599603
// Number of transport RTT samples available when the ECT was last computed.
600604
size_t transport_rtt_observation_count_last_ect_computation_;
605+
size_t end_to_end_rtt_observation_count_at_last_ect_computation_;
601606

602607
// Number of RTT observations received since the effective connection type was
603608
// last computed.
@@ -609,6 +614,7 @@ class NET_EXPORT NetworkQualityEstimator
609614

610615
// Current estimate of the network quality.
611616
nqe::internal::NetworkQuality network_quality_;
617+
base::Optional<base::TimeDelta> end_to_end_rtt_;
612618

613619
// Current estimate of the bandwidth delay product (BDP) in kilobits.
614620
base::Optional<int32_t> bandwidth_delay_product_kbits_;

net/nqe/network_quality_estimator_test_util.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ TestNetworkQualityEstimator::GetRecentEffectiveConnectionTypeAndNetworkQuality(
137137
base::TimeDelta* transport_rtt,
138138
base::TimeDelta* end_to_end_rtt,
139139
int32_t* downstream_throughput_kbps,
140-
size_t* observations_count) const {
140+
size_t* observations_count,
141+
size_t* end_to_end_rtt_observation_count) const {
141142
if (recent_effective_connection_type_) {
142143
GetRecentRTT(nqe::internal::OBSERVATION_CATEGORY_HTTP, start_time, http_rtt,
143144
nullptr);
@@ -149,7 +150,8 @@ TestNetworkQualityEstimator::GetRecentEffectiveConnectionTypeAndNetworkQuality(
149150
return NetworkQualityEstimator::
150151
GetRecentEffectiveConnectionTypeAndNetworkQuality(
151152
start_time, http_rtt, transport_rtt, end_to_end_rtt,
152-
downstream_throughput_kbps, observations_count);
153+
downstream_throughput_kbps, observations_count,
154+
end_to_end_rtt_observation_count);
153155
}
154156

155157
bool TestNetworkQualityEstimator::GetRecentRTT(

net/nqe/network_quality_estimator_test_util.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator {
107107
base::TimeDelta* transport_rtt,
108108
base::TimeDelta* end_to_end_rtt,
109109
int32_t* downstream_throughput_kbps,
110-
size_t* observations_count) const override;
110+
size_t* observations_count,
111+
size_t* end_to_end_rtt_observation_count) const override;
111112

112113
void NotifyObserversOfRTTOrThroughputComputed() const override;
113114

net/nqe/network_quality_estimator_unittest.cc

+3
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,9 @@ TEST_F(NetworkQualityEstimatorTest, TestRttThroughputObservers) {
17671767
estimator.GetRecentRTT(nqe::internal::OBSERVATION_CATEGORY_TRANSPORT,
17681768
base::TimeTicks(), &rtt, nullptr));
17691769

1770+
EXPECT_EQ(quic_rtt, estimator.end_to_end_rtt_.value());
1771+
EXPECT_LT(
1772+
0u, estimator.end_to_end_rtt_observation_count_at_last_ect_computation_);
17701773
const std::vector<base::Bucket> end_to_end_rtt_samples =
17711774
histogram_tester.GetAllSamples("NQE.EndToEndRTT.OnECTComputation");
17721775
EXPECT_FALSE(end_to_end_rtt_samples.empty());

0 commit comments

Comments
 (0)