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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/hybrid_slow_start.h" 5 #include "net/quic/congestion_control/hybrid_slow_start.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 using std::max; 9 using std::max;
10 using std::min; 10 using std::min;
(...skipping 16 matching lines...) Expand all
27 hystart_found_(NOT_FOUND), 27 hystart_found_(NOT_FOUND),
28 last_sent_sequence_number_(0), 28 last_sent_sequence_number_(0),
29 round_start_(QuicTime::Zero()), 29 round_start_(QuicTime::Zero()),
30 end_sequence_number_(0), 30 end_sequence_number_(0),
31 last_close_ack_pair_time_(QuicTime::Zero()), 31 last_close_ack_pair_time_(QuicTime::Zero()),
32 rtt_sample_count_(0), 32 rtt_sample_count_(0),
33 current_min_rtt_(QuicTime::Delta::Zero()) { 33 current_min_rtt_(QuicTime::Delta::Zero()) {
34 } 34 }
35 35
36 void HybridSlowStart::OnPacketAcked( 36 void HybridSlowStart::OnPacketAcked(
37 QuicPacketSequenceNumber acked_sequence_number, bool in_slow_start) { 37 QuicPacketSequenceNumber acked_sequence_number,
38 bool in_slow_start) {
38 // OnPacketAcked gets invoked after ShouldExitSlowStart, so it's best to end 39 // OnPacketAcked gets invoked after ShouldExitSlowStart, so it's best to end
39 // the round when the final packet of the burst is received and start it on 40 // the round when the final packet of the burst is received and start it on
40 // the next incoming ack. 41 // the next incoming ack.
41 if (in_slow_start && IsEndOfRound(acked_sequence_number)) { 42 if (in_slow_start && IsEndOfRound(acked_sequence_number)) {
42 started_ = false; 43 started_ = false;
43 } 44 }
44 } 45 }
45 46
46 void HybridSlowStart::OnPacketSent(QuicPacketSequenceNumber sequence_number) { 47 void HybridSlowStart::OnPacketSent(QuicPacketSequenceNumber sequence_number) {
47 last_sent_sequence_number_ = sequence_number; 48 last_sent_sequence_number_ = sequence_number;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // spread out more then half the minimum RTT packets are being spread out 84 // spread out more then half the minimum RTT packets are being spread out
84 // more than the capacity. 85 // more than the capacity.
85 // This first trigger will not come into play until we hit roughly 9.6 Mbps 86 // This first trigger will not come into play until we hit roughly 9.6 Mbps
86 // with delayed acks (or 4.8Mbps without delayed acks) 87 // with delayed acks (or 4.8Mbps without delayed acks)
87 // TODO(ianswett): QUIC always uses delayed acks, even at the beginning, so 88 // TODO(ianswett): QUIC always uses delayed acks, even at the beginning, so
88 // this should likely be at least 4ms. 89 // this should likely be at least 4ms.
89 // TODO(pwestin): we need to make sure our pacing don't trigger this detector. 90 // TODO(pwestin): we need to make sure our pacing don't trigger this detector.
90 // TODO(ianswett): Pacing or other cases could be handled by checking the send 91 // TODO(ianswett): Pacing or other cases could be handled by checking the send
91 // time of the first acked packet in a receive round. 92 // time of the first acked packet in a receive round.
92 if (current_time.Subtract(last_close_ack_pair_time_).ToMicroseconds() <= 93 if (current_time.Subtract(last_close_ack_pair_time_).ToMicroseconds() <=
93 kHybridStartDelayMinThresholdUs) { 94 kHybridStartDelayMinThresholdUs) {
94 last_close_ack_pair_time_ = current_time; 95 last_close_ack_pair_time_ = current_time;
95 if (current_time.Subtract(round_start_).ToMicroseconds() >= 96 if (current_time.Subtract(round_start_).ToMicroseconds() >=
96 min_rtt.ToMicroseconds() >> 1) { 97 min_rtt.ToMicroseconds() >> 1) {
97 hystart_found_ = ACK_TRAIN; 98 hystart_found_ = ACK_TRAIN;
98 } 99 }
99 } else if (last_close_ack_pair_time_ == round_start_) { 100 } else if (last_close_ack_pair_time_ == round_start_) {
100 // If the previous ack wasn't close, then move forward the round start time 101 // If the previous ack wasn't close, then move forward the round start time
101 // to the incoming ack. 102 // to the incoming ack.
102 last_close_ack_pair_time_ = round_start_ = current_time; 103 last_close_ack_pair_time_ = round_start_ = current_time;
103 } 104 }
104 // Second detection parameter - delay increase detection. 105 // Second detection parameter - delay increase detection.
105 // Compare the minimum delay (current_min_rtt_) of the current 106 // Compare the minimum delay (current_min_rtt_) of the current
106 // burst of packets relative to the minimum delay during the session. 107 // burst of packets relative to the minimum delay during the session.
107 // Note: we only look at the first few(8) packets in each burst, since we 108 // Note: we only look at the first few(8) packets in each burst, since we
108 // only want to compare the lowest RTT of the burst relative to previous 109 // only want to compare the lowest RTT of the burst relative to previous
109 // bursts. 110 // bursts.
110 rtt_sample_count_++; 111 rtt_sample_count_++;
111 if (rtt_sample_count_ <= kHybridStartMinSamples) { 112 if (rtt_sample_count_ <= kHybridStartMinSamples) {
112 if (current_min_rtt_.IsZero() || current_min_rtt_ > latest_rtt) { 113 if (current_min_rtt_.IsZero() || current_min_rtt_ > latest_rtt) {
113 current_min_rtt_ = latest_rtt; 114 current_min_rtt_ = latest_rtt;
114 } 115 }
115 } 116 }
116 // We only need to check this once per round. 117 // We only need to check this once per round.
117 if (rtt_sample_count_ == kHybridStartMinSamples) { 118 if (rtt_sample_count_ == kHybridStartMinSamples) {
118 // Divide min_rtt by 16 to get a rtt increase threshold for exiting. 119 // Divide min_rtt by 16 to get a rtt increase threshold for exiting.
119 int min_rtt_increase_threshold_us = min_rtt.ToMicroseconds() >> 120 int min_rtt_increase_threshold_us =
120 kHybridStartDelayFactorExp; 121 min_rtt.ToMicroseconds() >> kHybridStartDelayFactorExp;
121 // Ensure the rtt threshold is never less than 2ms or more than 16ms. 122 // Ensure the rtt threshold is never less than 2ms or more than 16ms.
122 min_rtt_increase_threshold_us = min(min_rtt_increase_threshold_us, 123 min_rtt_increase_threshold_us =
123 kHybridStartDelayMaxThresholdUs); 124 min(min_rtt_increase_threshold_us, kHybridStartDelayMaxThresholdUs);
124 QuicTime::Delta min_rtt_increase_threshold = 125 QuicTime::Delta min_rtt_increase_threshold =
125 QuicTime::Delta::FromMicroseconds(max(min_rtt_increase_threshold_us, 126 QuicTime::Delta::FromMicroseconds(max(min_rtt_increase_threshold_us,
126 kHybridStartDelayMinThresholdUs)); 127 kHybridStartDelayMinThresholdUs));
127 128
128 if (current_min_rtt_ > min_rtt.Add(min_rtt_increase_threshold)) { 129 if (current_min_rtt_ > min_rtt.Add(min_rtt_increase_threshold)) {
129 hystart_found_= DELAY; 130 hystart_found_ = DELAY;
130 } 131 }
131 } 132 }
132 // Exit from slow start if the cwnd is greater than 16 and an ack train or 133 // Exit from slow start if the cwnd is greater than 16 and an ack train or
133 // increasing delay are found. 134 // increasing delay are found.
134 return congestion_window >= kHybridStartLowWindow && 135 return congestion_window >= kHybridStartLowWindow &&
135 hystart_found_ != NOT_FOUND; 136 hystart_found_ != NOT_FOUND;
136 } 137 }
137 138
138 } // namespace net 139 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698