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

Unified Diff: net/http/http_basic_stream.cc

Issue 6990036: Deciding best connection to schedule requests on based on cwnd and idle time (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: connect_time_micros_ Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_basic_stream.cc
===================================================================
--- net/http/http_basic_stream.cc (revision 88319)
+++ net/http/http_basic_stream.cc (working copy)
@@ -4,6 +4,7 @@
#include "net/http/http_basic_stream.h"
+#include "base/metrics/histogram.h"
#include "base/stringprintf.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
@@ -15,6 +16,9 @@
namespace net {
+// static
+std::string HttpBasicStream::g_warm_connection_field_trial_group_;
+
HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection,
HttpStreamParser* parser,
bool using_proxy)
@@ -34,6 +38,7 @@
request_info_ = request_info;
parser_.reset(new HttpStreamParser(connection_.get(), request_info,
read_buf_, net_log));
+ bytes_read_offset_ = connection_->socket()->NumBytesRead();
return OK;
}
@@ -50,6 +55,7 @@
request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n",
request_info_->method.c_str(),
path.c_str());
+ response_ = response;
return parser_->SendRequest(request_line_, headers, request_body, response,
callback);
}
@@ -119,4 +125,29 @@
return false;
}
+void HttpBasicStream::LogNumRttVsBytesMetrics() const {
+ int64 total_bytes_read = connection_->socket()->NumBytesRead();
+ int64 bytes_received = total_bytes_read - bytes_read_offset_;
+ int64 num_kb = bytes_received / 1024;
+ double rtt = connection_->socket()->GetConnectTimeMicros() / 1000;
+
+ if (num_kb < 1024 && rtt > 0) { // Ignore responses > 1MB
+ base::TimeDelta duration = base::Time::Now() -
+ response_->request_time;
+ double num_rtt = static_cast<double>(duration.InMilliseconds()) / rtt;
+ int64 num_rtt_scaled = (4 * num_rtt);
+
+ // Integer representation of <num_kb, num_rtt_scaled> tuple.
+ int val = 1024 * num_rtt_scaled + num_kb;
Mike Belshe 2011/06/10 18:11:42 I think this is ridiculous still. I see that you'
Gagan 2011/06/12 20:11:44 Done.
+
+ std::string histogram = "Net.RTT_vs_KB_";
+ histogram.append(g_warm_connection_field_trial_group_);
Mike Belshe 2011/06/10 18:11:42 OK - I see, g_warm_connection_field_trial_group is
Gagan 2011/06/12 20:11:44 Done.
+ HISTOGRAM_CUSTOM_COUNTS(histogram, val, 4096, 3048000, 1000);
+ LOG(ERROR) << request_line_
+ << "\nrtt = " << rtt << "\tnum_rtt = " << num_rtt
+ << "\tnum_kb = " << num_kb << "\tval = " << val
+ << "\ttotal bytes = " << total_bytes_read;
+ }
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698