summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 04:22:44 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 04:22:44 +0000
commit0d8fa3ecb7ed0a7f6e0d9cd0a750a29bd8bed370 (patch)
treec4cb5532d0bee1567641c0cc7147d8b1ebbad5f1
parentbb39f362bd5222de3b9f3f7ab2d5bb69c2aeca39 (diff)
downloadchromium_src-0d8fa3ecb7ed0a7f6e0d9cd0a750a29bd8bed370.zip
chromium_src-0d8fa3ecb7ed0a7f6e0d9cd0a750a29bd8bed370.tar.gz
chromium_src-0d8fa3ecb7ed0a7f6e0d9cd0a750a29bd8bed370.tar.bz2
DNS prefetch experiment extension: Consider different connection count limits
This CL both enables selection of a run-time selected limit on the number of connections to a single host, and varies that limit to see how it relates to DNS prefetch latency in connections. r=wtc Review URL: http://codereview.chromium.org/62083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13339 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_main.cc24
-rw-r--r--net/http/http_network_session.cc22
-rw-r--r--net/http/http_network_session.h14
-rw-r--r--net/net.gyp1
4 files changed, 50 insertions, 11 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 8dc32d4..0ef576f 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -48,6 +48,7 @@
#include "grit/generated_resources.h"
#include "grit/net_resources.h"
#include "net/base/net_module.h"
+#include "net/http/http_network_session.h"
#if defined(OS_POSIX)
// TODO(port): get rid of this include. It's used just to provide declarations
@@ -316,7 +317,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
if (!parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) {
// Display a warning if the user is running windows 2000.
- // TODO(port). We should probably change this to a "check for minimum
+ // TODO(port): We should probably change this to a "check for minimum
// requirements" function, implemented by each platform.
CheckForWin2000();
}
@@ -439,14 +440,21 @@ int BrowserMain(const MainFunctionParams& parameters) {
net::EnsureWinsockInit();
#endif // defined(OS_WIN)
- // Set up a field trial.
+ // Set up a field trial to see what disabling DNS pre-resolution does to
+ // latency of network transactions.
FieldTrial::Probability kDIVISOR = 100;
- FieldTrial::Probability kDISABLE = 1; // 1%.
+ FieldTrial::Probability k_PROBABILITY_PER_GROUP = 10; // 10%.
scoped_refptr<FieldTrial> dns_trial = new FieldTrial("DnsImpact", kDIVISOR);
- int disabled_group = dns_trial->AppendGroup("_disabled_prefetch", kDISABLE);
+
+ dns_trial->AppendGroup("_disabled_prefetch", k_PROBABILITY_PER_GROUP);
+ int disabled_plus_4_connections = dns_trial->AppendGroup(
+ "_disabled_prefetch_4_connections", k_PROBABILITY_PER_GROUP);
+ int enabled_plus_4_connections = dns_trial->AppendGroup(
+ "_enabled_prefetch_4_connections", k_PROBABILITY_PER_GROUP);
scoped_ptr<chrome_browser_net::DnsPrefetcherInit> dns_prefetch_init;
- if (dns_trial->group() != disabled_group) {
+ if (dns_trial->group() == FieldTrial::kNotParticipating ||
+ dns_trial->group() == enabled_plus_4_connections) {
// Initialize the DNS prefetch system
dns_prefetch_init.reset(
new chrome_browser_net::DnsPrefetcherInit(user_prefs));
@@ -454,6 +462,12 @@ int BrowserMain(const MainFunctionParams& parameters) {
chrome_browser_net::RestoreSubresourceReferrers(local_state);
}
+ if (dns_trial->group() == disabled_plus_4_connections ||
+ dns_trial->group() == enabled_plus_4_connections) {
+ net::HttpNetworkSession::set_max_sockets_per_group(4);
+ }
+
+
#if defined(OS_WIN)
// Init common control sex.
INITCOMMONCONTROLSEX config;
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
new file mode 100644
index 0000000..a498ed0
--- /dev/null
+++ b/net/http/http_network_session.cc
@@ -0,0 +1,22 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/http_network_session.h"
+
+#include "base/logging.h"
+
+namespace net {
+
+// static
+int HttpNetworkSession::max_sockets_per_group_ = 6;
+
+// static
+void HttpNetworkSession::set_max_sockets_per_group(int socket_count) {
+ DCHECK(0 < socket_count);
+ // The following is a sanity check... but we should NEVER be near this value.
+ DCHECK(100 > socket_count);
+ max_sockets_per_group_ = socket_count;
+}
+
+} // namespace net
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 2dd1b89..7c4ac68 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -17,13 +17,8 @@ class ProxyService;
// This class holds session objects used by HttpNetworkTransaction objects.
class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
public:
- // Allow up to 6 connections per host.
- enum {
- MAX_SOCKETS_PER_GROUP = 6
- };
-
explicit HttpNetworkSession(ProxyService* proxy_service)
- : connection_pool_(new ClientSocketPool(MAX_SOCKETS_PER_GROUP)),
+ : connection_pool_(new ClientSocketPool(max_sockets_per_group_)),
proxy_service_(proxy_service) {
DCHECK(proxy_service);
}
@@ -35,7 +30,14 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
SSLConfigService* ssl_config_service() { return &ssl_config_service_; }
#endif
+ static void set_max_sockets_per_group(int socket_count);
+
private:
+ // Default to allow up to 6 connections per host. Experiment and tuning may
+ // try other values (greater than 0). Too large may cause many problems, such
+ // as home routers blocking the connections!?!?
+ static int max_sockets_per_group_;
+
HttpAuthCache auth_cache_;
scoped_refptr<ClientSocketPool> connection_pool_;
ProxyService* proxy_service_;
diff --git a/net/net.gyp b/net/net.gyp
index ca972fc..cfd17f6 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -217,6 +217,7 @@
'http/http_chunked_decoder.h',
'http/http_network_layer.cc',
'http/http_network_layer.h',
+ 'http/http_network_session.cc',
'http/http_network_session.h',
'http/http_network_transaction.cc',
'http/http_network_transaction.h',