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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 1061853002: Emit session-level WINDOW_UPDATEs less frequently. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« net/spdy/spdy_session.h ('K') | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 last_compressed_frame_len_(0), 653 last_compressed_frame_len_(0),
654 check_ping_status_pending_(false), 654 check_ping_status_pending_(false),
655 send_connection_header_prefix_(false), 655 send_connection_header_prefix_(false),
656 flow_control_state_(FLOW_CONTROL_NONE), 656 flow_control_state_(FLOW_CONTROL_NONE),
657 stream_initial_send_window_size_(GetInitialWindowSize(default_protocol)), 657 stream_initial_send_window_size_(GetInitialWindowSize(default_protocol)),
658 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 658 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0
659 ? kDefaultInitialRecvWindowSize 659 ? kDefaultInitialRecvWindowSize
660 : stream_initial_recv_window_size), 660 : stream_initial_recv_window_size),
661 session_send_window_size_(0), 661 session_send_window_size_(0),
662 session_recv_window_size_(0), 662 session_recv_window_size_(0),
663 session_max_recv_window_size_(0),
663 session_unacked_recv_window_bytes_(0), 664 session_unacked_recv_window_bytes_(0),
664 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP2_SESSION)), 665 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP2_SESSION)),
665 verify_domain_authentication_(verify_domain_authentication), 666 verify_domain_authentication_(verify_domain_authentication),
666 enable_sending_initial_data_(enable_sending_initial_data), 667 enable_sending_initial_data_(enable_sending_initial_data),
667 enable_compression_(enable_compression), 668 enable_compression_(enable_compression),
668 enable_ping_based_connection_checking_( 669 enable_ping_based_connection_checking_(
669 enable_ping_based_connection_checking), 670 enable_ping_based_connection_checking),
670 protocol_(default_protocol), 671 protocol_(default_protocol),
671 connection_at_risk_of_loss_time_( 672 connection_at_risk_of_loss_time_(
672 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), 673 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); 732 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion);
732 733
733 if ((protocol_ >= kProtoSPDY4MinimumVersion) && 734 if ((protocol_ >= kProtoSPDY4MinimumVersion) &&
734 (protocol_ <= kProtoSPDY4MaximumVersion)) 735 (protocol_ <= kProtoSPDY4MaximumVersion))
735 send_connection_header_prefix_ = true; 736 send_connection_header_prefix_ = true;
736 737
737 if (protocol_ >= kProtoSPDY31) { 738 if (protocol_ >= kProtoSPDY31) {
738 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; 739 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION;
739 session_send_window_size_ = GetInitialWindowSize(protocol_); 740 session_send_window_size_ = GetInitialWindowSize(protocol_);
740 session_recv_window_size_ = GetInitialWindowSize(protocol_); 741 session_recv_window_size_ = GetInitialWindowSize(protocol_);
742 session_max_recv_window_size_ = GetInitialWindowSize(protocol_);
741 } else if (protocol_ >= kProtoSPDY3) { 743 } else if (protocol_ >= kProtoSPDY3) {
742 flow_control_state_ = FLOW_CONTROL_STREAM; 744 flow_control_state_ = FLOW_CONTROL_STREAM;
743 } else { 745 } else {
744 flow_control_state_ = FLOW_CONTROL_NONE; 746 flow_control_state_ = FLOW_CONTROL_NONE;
745 } 747 }
746 748
747 buffered_spdy_framer_.reset( 749 buffered_spdy_framer_.reset(
748 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), 750 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_),
749 enable_compression_)); 751 enable_compression_));
750 buffered_spdy_framer_->set_visitor(this); 752 buffered_spdy_framer_->set_visitor(this);
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 2788
2787 // Next, notify the server about our initial recv window size. 2789 // Next, notify the server about our initial recv window size.
2788 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { 2790 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) {
2789 // Bump up the receive window size to the real initial value. This 2791 // Bump up the receive window size to the real initial value. This
2790 // has to go here since the WINDOW_UPDATE frame sent by 2792 // has to go here since the WINDOW_UPDATE frame sent by
2791 // IncreaseRecvWindowSize() call uses |buffered_spdy_framer_|. 2793 // IncreaseRecvWindowSize() call uses |buffered_spdy_framer_|.
2792 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_); 2794 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_);
2793 // This condition implies that |kDefaultInitialRecvWindowSize| - 2795 // This condition implies that |kDefaultInitialRecvWindowSize| -
2794 // |session_recv_window_size_| doesn't overflow. 2796 // |session_recv_window_size_| doesn't overflow.
2795 DCHECK_GT(session_recv_window_size_, 0); 2797 DCHECK_GT(session_recv_window_size_, 0);
2796 IncreaseRecvWindowSize( 2798 session_max_recv_window_size_ = kDefaultInitialRecvWindowSize;
2797 kDefaultInitialRecvWindowSize - session_recv_window_size_); 2799 IncreaseRecvWindowSize(session_max_recv_window_size_ -
2800 session_recv_window_size_);
2798 } 2801 }
2799 2802
2800 if (protocol_ <= kProtoSPDY31) { 2803 if (protocol_ <= kProtoSPDY31) {
2801 // Finally, notify the server about the settings they have 2804 // Finally, notify the server about the settings they have
2802 // previously told us to use when communicating with them (after 2805 // previously told us to use when communicating with them (after
2803 // applying them). 2806 // applying them).
2804 const SettingsMap& server_settings_map = 2807 const SettingsMap& server_settings_map =
2805 http_server_properties_->GetSpdySettings(host_port_pair()); 2808 http_server_properties_->GetSpdySettings(host_port_pair());
2806 if (server_settings_map.empty()) 2809 if (server_settings_map.empty())
2807 return; 2810 return;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 DCHECK_GE(delta_window_size, 1); 3186 DCHECK_GE(delta_window_size, 1);
3184 // Check for overflow. 3187 // Check for overflow.
3185 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); 3188 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_);
3186 3189
3187 session_recv_window_size_ += delta_window_size; 3190 session_recv_window_size_ += delta_window_size;
3188 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, 3191 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW,
3189 base::Bind(&NetLogSpdySessionWindowUpdateCallback, 3192 base::Bind(&NetLogSpdySessionWindowUpdateCallback,
3190 delta_window_size, session_recv_window_size_)); 3193 delta_window_size, session_recv_window_size_));
3191 3194
3192 session_unacked_recv_window_bytes_ += delta_window_size; 3195 session_unacked_recv_window_bytes_ += delta_window_size;
3193 if (session_unacked_recv_window_bytes_ > 3196 if (session_unacked_recv_window_bytes_ > session_max_recv_window_size_ / 2) {
3194 GetInitialWindowSize(protocol_) / 2) {
Ryan Hamilton 2015/04/06 16:27:05 I'm curious why this didn't work. It *looks* like
Bence 2015/04/07 12:32:16 Good question. So GetInitialWindowSize is 64 kB,
Ryan Hamilton 2015/04/07 14:56:39 Oh, that method was return the protocol default, n
3195 SendWindowUpdateFrame(kSessionFlowControlStreamId, 3197 SendWindowUpdateFrame(kSessionFlowControlStreamId,
3196 session_unacked_recv_window_bytes_, 3198 session_unacked_recv_window_bytes_,
3197 HIGHEST); 3199 HIGHEST);
3198 session_unacked_recv_window_bytes_ = 0; 3200 session_unacked_recv_window_bytes_ = 0;
3199 } 3201 }
3200 } 3202 }
3201 3203
3202 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { 3204 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) {
3203 CHECK(in_io_loop_); 3205 CHECK(in_io_loop_);
3204 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); 3206 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 if (!queue->empty()) { 3269 if (!queue->empty()) {
3268 SpdyStreamId stream_id = queue->front(); 3270 SpdyStreamId stream_id = queue->front();
3269 queue->pop_front(); 3271 queue->pop_front();
3270 return stream_id; 3272 return stream_id;
3271 } 3273 }
3272 } 3274 }
3273 return 0; 3275 return 0;
3274 } 3276 }
3275 3277
3276 } // namespace net 3278 } // namespace net
OLDNEW
« net/spdy/spdy_session.h ('K') | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698