Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: net/quic/congestion_control/rtt_stats.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/congestion_control/rtt_stats.h ('k') | net/quic/congestion_control/rtt_stats_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/congestion_control/rtt_stats.h" 5 #include "net/quic/congestion_control/rtt_stats.h"
6 6
7 #include <complex> // std::abs 7 #include <complex> // std::abs
8 8
9 using std::max; 9 using std::max;
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 RttStats::RttStats() 26 RttStats::RttStats()
27 : latest_rtt_(QuicTime::Delta::Zero()), 27 : latest_rtt_(QuicTime::Delta::Zero()),
28 min_rtt_(QuicTime::Delta::Zero()), 28 min_rtt_(QuicTime::Delta::Zero()),
29 smoothed_rtt_(QuicTime::Delta::Zero()), 29 smoothed_rtt_(QuicTime::Delta::Zero()),
30 mean_deviation_(QuicTime::Delta::Zero()), 30 mean_deviation_(QuicTime::Delta::Zero()),
31 initial_rtt_us_(kInitialRttMs * base::Time::kMicrosecondsPerMillisecond), 31 initial_rtt_us_(kInitialRttMs * base::Time::kMicrosecondsPerMillisecond),
32 num_min_rtt_samples_remaining_(0), 32 num_min_rtt_samples_remaining_(0),
33 recent_min_rtt_window_(QuicTime::Delta::Infinite()) {} 33 recent_min_rtt_window_(QuicTime::Delta::Infinite()) {}
34 34
35 bool RttStats::HasUpdates() const {
36 return !smoothed_rtt_.IsZero();
37 }
38
39 void RttStats::SampleNewRecentMinRtt(uint32 num_samples) { 35 void RttStats::SampleNewRecentMinRtt(uint32 num_samples) {
40 num_min_rtt_samples_remaining_ = num_samples; 36 num_min_rtt_samples_remaining_ = num_samples;
41 new_min_rtt_ = RttSample(); 37 new_min_rtt_ = RttSample();
42 } 38 }
43 39
44 void RttStats::ExpireSmoothedMetrics() { 40 void RttStats::ExpireSmoothedMetrics() {
45 mean_deviation_ = 41 mean_deviation_ =
46 max(mean_deviation_, 42 max(mean_deviation_,
47 QuicTime::Delta::FromMicroseconds( 43 QuicTime::Delta::FromMicroseconds(
48 std::abs(smoothed_rtt_.Subtract(latest_rtt_).ToMicroseconds()))); 44 std::abs(smoothed_rtt_.Subtract(latest_rtt_).ToMicroseconds())));
(...skipping 22 matching lines...) Expand all
71 67
72 // Correct for ack_delay if information received from the peer results in a 68 // Correct for ack_delay if information received from the peer results in a
73 // positive RTT sample. Otherwise, we use the send_delta as a reasonable 69 // positive RTT sample. Otherwise, we use the send_delta as a reasonable
74 // measure for smoothed_rtt. 70 // measure for smoothed_rtt.
75 QuicTime::Delta rtt_sample(send_delta); 71 QuicTime::Delta rtt_sample(send_delta);
76 if (rtt_sample > ack_delay) { 72 if (rtt_sample > ack_delay) {
77 rtt_sample = rtt_sample.Subtract(ack_delay); 73 rtt_sample = rtt_sample.Subtract(ack_delay);
78 } 74 }
79 latest_rtt_ = rtt_sample; 75 latest_rtt_ = rtt_sample;
80 // First time call. 76 // First time call.
81 if (!HasUpdates()) { 77 if (smoothed_rtt_.IsZero()) {
82 smoothed_rtt_ = rtt_sample; 78 smoothed_rtt_ = rtt_sample;
83 mean_deviation_ = QuicTime::Delta::FromMicroseconds( 79 mean_deviation_ = QuicTime::Delta::FromMicroseconds(
84 rtt_sample.ToMicroseconds() / 2); 80 rtt_sample.ToMicroseconds() / 2);
85 } else { 81 } else {
86 mean_deviation_ = QuicTime::Delta::FromMicroseconds( 82 mean_deviation_ = QuicTime::Delta::FromMicroseconds(
87 kOneMinusBeta * mean_deviation_.ToMicroseconds() + 83 kOneMinusBeta * mean_deviation_.ToMicroseconds() +
88 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds())); 84 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds()));
89 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add( 85 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add(
90 rtt_sample.Multiply(kAlpha)); 86 rtt_sample.Multiply(kAlpha));
91 DVLOG(1) << " smoothed_rtt(us):" << smoothed_rtt_.ToMicroseconds() 87 DVLOG(1) << " smoothed_rtt(us):" << smoothed_rtt_.ToMicroseconds()
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } else if (half_window_rtt_.time < 120 } else if (half_window_rtt_.time <
125 now.Subtract(recent_min_rtt_window_.Multiply(kHalfWindow))) { 121 now.Subtract(recent_min_rtt_window_.Multiply(kHalfWindow))) {
126 half_window_rtt_ = quarter_window_rtt_; 122 half_window_rtt_ = quarter_window_rtt_;
127 quarter_window_rtt_ = RttSample(rtt_sample, now); 123 quarter_window_rtt_ = RttSample(rtt_sample, now);
128 } else if (quarter_window_rtt_.time < 124 } else if (quarter_window_rtt_.time <
129 now.Subtract(recent_min_rtt_window_.Multiply(kQuarterWindow))) { 125 now.Subtract(recent_min_rtt_window_.Multiply(kQuarterWindow))) {
130 quarter_window_rtt_ = RttSample(rtt_sample, now); 126 quarter_window_rtt_ = RttSample(rtt_sample, now);
131 } 127 }
132 } 128 }
133 129
134 QuicTime::Delta RttStats::SmoothedRtt() const {
135 if (!HasUpdates()) {
136 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_);
137 }
138 return smoothed_rtt_;
139 }
140
141 QuicTime::Delta RttStats::MinRtt() const {
142 if (!HasUpdates()) {
143 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_);
144 }
145 return min_rtt_;
146 }
147
148 } // namespace net 130 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/rtt_stats.h ('k') | net/quic/congestion_control/rtt_stats_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698