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

Side by Side Diff: net/tools/flip_server/flip_in_mem_edsm_server.cc

Issue 5966003: Reduce the Spdy data frame sizes used. Attempt to make them fit within SSL... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <dirent.h> 5 #include <dirent.h>
6 #include <netinet/tcp.h> // For TCP_NODELAY 6 #include <netinet/tcp.h> // For TCP_NODELAY
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <openssl/err.h> 10 #include <openssl/err.h>
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 PrintSslError(); 263 PrintSslError();
264 264
265 SSL_set_accept_state(ssl); 265 SSL_set_accept_state(ssl);
266 PrintSslError(); 266 PrintSslError();
267 267
268 return ssl; 268 return ssl;
269 } 269 }
270 270
271 //////////////////////////////////////////////////////////////////////////////// 271 ////////////////////////////////////////////////////////////////////////////////
272 272
273 const int kMSS = 1460; 273 const int kMSS = 1400; // Linux default
274 const int kInitialDataSendersThreshold = (2 * kMSS) - SpdyFrame::size(); 274 const int kSSLOverhead = 33;
275 const int kNormalSegmentSize = (2 * kMSS) - SpdyFrame::size(); 275 const int kSpdyOverhead = SpdyFrame::size();
276 const int kInitialDataSendersThreshold = (2 * kMSS) - kSpdyOverhead;
277 const int kSSLSegmentSize = (1 * kMSS) - kSSLOverhead;
278 const int kSpdySegmentSize = kSSLSegmentSize - kSpdyOverhead;
276 279
277 //////////////////////////////////////////////////////////////////////////////// 280 ////////////////////////////////////////////////////////////////////////////////
278 281
279 class DataFrame { 282 class DataFrame {
280 public: 283 public:
281 const char* data; 284 const char* data;
282 size_t size; 285 size_t size;
283 bool delete_when_done; 286 bool delete_when_done;
284 size_t index; 287 size_t index;
285 DataFrame() : data(NULL), size(0), delete_when_done(false), index(0) {} 288 DataFrame() : data(NULL), size(0), delete_when_done(false), index(0) {}
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 while (!priority_map_.empty()) { 1551 while (!priority_map_.empty()) {
1549 PriorityRing& first_ring = priority_map_.begin()->second; 1552 PriorityRing& first_ring = priority_map_.begin()->second;
1550 if (first_ring.empty()) { 1553 if (first_ring.empty()) {
1551 priority_map_.erase(priority_map_.begin()); 1554 priority_map_.erase(priority_map_.begin());
1552 continue; 1555 continue;
1553 } 1556 }
1554 MemCacheIter& mci = first_ring.front(); 1557 MemCacheIter& mci = first_ring.front();
1555 first_ring.splice(first_ring.end(), 1558 first_ring.splice(first_ring.end(),
1556 first_ring, 1559 first_ring,
1557 first_ring.begin()); 1560 first_ring.begin());
1558 mci.max_segment_size = kNormalSegmentSize; 1561 mci.max_segment_size = kSpdySegmentSize;
1559 return &mci; 1562 return &mci;
1560 } 1563 }
1561 return NULL; 1564 return NULL;
1562 } 1565 }
1563 1566
1564 void RemoveStreamId(uint32 stream_id) { 1567 void RemoveStreamId(uint32 stream_id) {
1565 StreamIdToPriorityMap::iterator sitpmi = stream_ids_.find(stream_id); 1568 StreamIdToPriorityMap::iterator sitpmi = stream_ids_.find(stream_id);
1566 if (sitpmi == stream_ids_.end()) 1569 if (sitpmi == stream_ids_.end())
1567 return; 1570 return;
1568 PriorityMapPointer& pmp = sitpmi->second; 1571 PriorityMapPointer& pmp = sitpmi->second;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 2067
2065 void SendDataFrameImpl(uint32 stream_id, const char* data, int64 len, 2068 void SendDataFrameImpl(uint32 stream_id, const char* data, int64 len,
2066 SpdyDataFlags flags, bool compress) { 2069 SpdyDataFlags flags, bool compress) {
2067 // Force compression off if disabled via command line. 2070 // Force compression off if disabled via command line.
2068 if (!FLAGS_use_compression) 2071 if (!FLAGS_use_compression)
2069 flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_COMPRESSED); 2072 flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_COMPRESSED);
2070 2073
2071 // TODO(mbelshe): We can't compress here - before going into the 2074 // TODO(mbelshe): We can't compress here - before going into the
2072 // priority queue. Compression needs to be done 2075 // priority queue. Compression needs to be done
2073 // with late binding. 2076 // with late binding.
2074 SpdyDataFrame* fdf = spdy_framer_->CreateDataFrame(stream_id, data, len,
2075 flags);
2076 DataFrame df;
2077 df.size = fdf->length() + SpdyFrame::size();
2078 df.data = fdf->data();
2079 df.delete_when_done = true;
2080 EnqueueDataFrame(df);
2081 2077
2082 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: Sending data frame " 2078 if (len == 0) {
2083 << stream_id << " [" << len << "] shrunk to " << fdf->length(); 2079 SpdyDataFrame* fdf = spdy_framer_->CreateDataFrame(stream_id, data, len,
2080 flags);
2081 DataFrame df;
2082 df.size = fdf->length() + SpdyFrame::size();
2083 df.data = fdf->data();
2084 df.delete_when_done = true;
2085 EnqueueDataFrame(df);
2086 return;
2087 }
2088
2089 // Chop data frames into chunks so that one stream can't monopolize the
2090 // output channel.
2091 while(len > 0) {
2092 int64 size = std::min(len, static_cast<int64>(kSpdySegmentSize));
2093 SpdyDataFlags chunk_flags = flags;
2094
2095 // If we chunked this block, and the FIN flag was set, there is more
2096 // data coming. So, remove the flag.
2097 if ((size < len) && (flags & DATA_FLAG_FIN))
2098 chunk_flags = static_cast<SpdyDataFlags>(chunk_flags & ~DATA_FLAG_FIN);
2099
2100 SpdyDataFrame* fdf = spdy_framer_->CreateDataFrame(stream_id, data, size,
2101 chunk_flags);
2102 DataFrame df;
2103 df.size = fdf->length() + SpdyFrame::size();
2104 df.data = fdf->data();
2105 df.delete_when_done = true;
2106 EnqueueDataFrame(df);
2107
2108 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: Sending data frame "
2109 << stream_id << " [" << size << "] shrunk to " << fdf->length()
2110 << ", flags=" << flags;
2111
2112 data += size;
2113 len -= size;
2114 }
2084 } 2115 }
2085 2116
2086 void EnqueueDataFrame(const DataFrame& df) { 2117 void EnqueueDataFrame(const DataFrame& df) {
2087 connection_->EnqueueDataFrame(df); 2118 connection_->EnqueueDataFrame(df);
2088 } 2119 }
2089 2120
2090 void GetOutput() { 2121 void GetOutput() {
2091 while (client_output_list_->size() < 2) { 2122 while (client_output_list_->size() < 2) {
2092 MemCacheIter* mci = client_output_ordering_.GetIter(); 2123 MemCacheIter* mci = client_output_ordering_.GetIter();
2093 if (mci == NULL) { 2124 if (mci == NULL) {
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
3169 for (unsigned int i = 0; i < sm_worker_threads_.size(); ++i) { 3200 for (unsigned int i = 0; i < sm_worker_threads_.size(); ++i) {
3170 sm_worker_threads_[i]->Join(); 3201 sm_worker_threads_[i]->Join();
3171 } 3202 }
3172 return 0; 3203 return 0;
3173 } 3204 }
3174 usleep(1000*10); // 10 ms 3205 usleep(1000*10); // 10 ms
3175 } 3206 }
3176 3207
3177 return 0; 3208 return 0;
3178 } 3209 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698