diff options
-rw-r--r-- | chrome/browser/browser_main.cc | 37 | ||||
-rwxr-xr-x | chrome/renderer/render_view.cc | 34 | ||||
-rw-r--r-- | net/net.gyp | 1 | ||||
-rw-r--r-- | net/socket/client_socket_pool.cc | 29 | ||||
-rw-r--r-- | net/socket/client_socket_pool.h | 4 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base.h | 14 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base_unittest.cc | 3 | ||||
-rw-r--r-- | net/socket/socks_client_socket_pool.cc | 3 | ||||
-rw-r--r-- | net/socket/tcp_client_socket_pool.cc | 3 |
9 files changed, 115 insertions, 13 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 712f7e1..37c4947 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -784,9 +784,44 @@ int BrowserMain(const MainFunctionParams& parameters) { } else if (conn_trial_grp == conn_16) { net::HttpNetworkSession::set_max_sockets_per_group(16); } else { - DCHECK(false); + NOTREACHED(); } + // A/B test for determining a value for unused socket timeout. Currently the + // timeout defaults to 10 seconds. Having this value set too low won't allow + // us to take advantage of idle sockets. Setting it to too high could + // possibly result in more ERR_CONNECT_RESETs, requiring one RTT to receive + // the RST packet and possibly another RTT to re-establish the connection. + const FieldTrial::Probability kIdleSktToDivisor = 100; // Idle socket timeout + const FieldTrial::Probability kSktToProb = 25; // 25% probability + + scoped_refptr<FieldTrial> socket_timeout_trial = + new FieldTrial("IdleSktToImpact", kIdleSktToDivisor); + + const int socket_timeout_5 = + socket_timeout_trial->AppendGroup("_idle_timeout_5", kSktToProb); + const int socket_timeout_10 = + socket_timeout_trial->AppendGroup("_idle_timeout_10", kSktToProb); + const int socket_timeout_20 = + socket_timeout_trial->AppendGroup("_idle_timeout_20", kSktToProb); + const int socket_timeout_60 = + socket_timeout_trial->AppendGroup("_idle_timeout_60", + FieldTrial::kAllRemainingProbability); + + const int idle_to_trial_grp = socket_timeout_trial->group(); + + if (idle_to_trial_grp == socket_timeout_5) { + net::ClientSocketPool::set_unused_idle_socket_timeout(5); + } else if (idle_to_trial_grp == socket_timeout_10) { + // This (10 seconds) is the current default value. + net::ClientSocketPool::set_unused_idle_socket_timeout(10); + } else if (idle_to_trial_grp == socket_timeout_20) { + net::ClientSocketPool::set_unused_idle_socket_timeout(20); + } else if (idle_to_trial_grp == socket_timeout_60) { + net::ClientSocketPool::set_unused_idle_socket_timeout(60); + } else { + NOTREACHED(); + } // When --use-spdy not set, users will be in A/B test for spdy. // group A (_npn_with_spdy): this means npn and spdy are enabled. In diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index a8d5ab2..693746f 100755 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -4637,6 +4637,40 @@ void RenderView::DumpLoadHistograms() const { } } + + static bool use_idle_socket_timeout_histogram( + FieldTrialList::Find("IdleSktToImpact") && + !FieldTrialList::Find("IdleSktToImpact")->group_name().empty()); + if (use_idle_socket_timeout_histogram) { + UMA_HISTOGRAM_ENUMERATION( + FieldTrial::MakeName("PLT.Abandoned", "IdleSktToImpact"), + abandoned_page ? 1 : 0, 2); + switch (load_type) { + case NavigationState::NORMAL_LOAD: + PLT_HISTOGRAM(FieldTrial::MakeName( + "PLT.BeginToFinish_NormalLoad", "IdleSktToImpact"), + begin_to_finish); + break; + case NavigationState::LINK_LOAD_NORMAL: + PLT_HISTOGRAM(FieldTrial::MakeName( + "PLT.BeginToFinish_LinkLoadNormal", "IdleSktToImpact"), + begin_to_finish); + break; + case NavigationState::LINK_LOAD_RELOAD: + PLT_HISTOGRAM(FieldTrial::MakeName( + "PLT.BeginToFinish_LinkLoadReload", "IdleSktToImpact"), + begin_to_finish); + break; + case NavigationState::LINK_LOAD_CACHE_STALE_OK: + PLT_HISTOGRAM(FieldTrial::MakeName( + "PLT.BeginToFinish_LinkLoadStaleOk", "IdleSktToImpact"), + begin_to_finish); + break; + default: + break; + } + } + // Histograms to determine if SDCH has an impact. // TODO(jar): Consider removing per-link load types and the enumeration. static bool use_sdch_histogram(FieldTrialList::Find("GlobalSdch") && diff --git a/net/net.gyp b/net/net.gyp index a9c9455..e5914bb 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -440,6 +440,7 @@ 'socket/client_socket_handle.cc', 'socket/client_socket_handle.h', 'socket/client_socket_pool.h', + 'socket/client_socket_pool.cc', 'socket/client_socket_pool_base.cc', 'socket/client_socket_pool_base.h', 'socket/client_socket_pool_histograms.cc', diff --git a/net/socket/client_socket_pool.cc b/net/socket/client_socket_pool.cc new file mode 100644 index 0000000..4cefe8d --- /dev/null +++ b/net/socket/client_socket_pool.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2010 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/socket/client_socket_pool.h"
+
+namespace {
+
+// The maximum duration, in seconds, to keep used idle persistent sockets
+// alive.
+// TODO(ziadh): Change this timeout after getting histogram data on how long it
+// should be.
+int g_unused_idle_socket_timeout = 10;
+
+} // namespace
+
+namespace net {
+
+// static
+int ClientSocketPool::unused_idle_socket_timeout() {
+ return g_unused_idle_socket_timeout;
+}
+
+// static
+void ClientSocketPool::set_unused_idle_socket_timeout(int timeout) {
+ g_unused_idle_socket_timeout = timeout;
+}
+
+} // namespace net
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h index c5f6f16..807104e 100644 --- a/net/socket/client_socket_pool.h +++ b/net/socket/client_socket_pool.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" +#include "base/time.h" #include "base/template_util.h" #include "net/base/completion_callback.h" #include "net/base/host_resolver.h" @@ -103,6 +104,9 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> { // UMA_HISTOGRAM_* macros because they are callsite static. virtual scoped_refptr<ClientSocketPoolHistograms> histograms() const = 0; + static int unused_idle_socket_timeout(); + static void set_unused_idle_socket_timeout(int timeout); + protected: ClientSocketPool() {} virtual ~ClientSocketPool() {} diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index 3e1de22..942142d 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -193,7 +193,7 @@ class ClientSocketPoolBaseHelper // See ClientSocketPool::Flush for documentation on this function. void Flush(); - + // See ClientSocketPool::CloseIdleSockets for documentation on this function. void CloseIdleSockets(); @@ -450,11 +450,11 @@ class ClientSocketPoolBaseHelper // selecting the highest priority request across *all* groups. // // |may_have_stalled_group_| is not conclusive, since when we cancel pending - // requests, we may reach the situation where we have the maximum number of + // requests, we may reach the situation where we have the maximum number of // sockets, but no request is stalled because of the global socket limit // (although some requests may be blocked on the socket per group limit). // We don't strictly maintain |may_have_stalled_group_|, since that would - // require a linear search through all groups in |group_map_| to see if one + // require a linear search through all groups in |group_map_| to see if one // of them is stalled. bool may_have_stalled_group_; @@ -476,11 +476,6 @@ class ClientSocketPoolBaseHelper } // namespace internal -// The maximum duration, in seconds, to keep unused idle persistent sockets -// alive. -// TODO(willchan): Change this timeout after getting histogram data on how -// long it should be. -static const int kUnusedIdleSocketTimeout = 10; // The maximum duration, in seconds, to keep used idle persistent sockets alive. static const int kUsedIdleSocketTimeout = 300; // 5 minutes @@ -563,7 +558,8 @@ class ClientSocketPoolBase { return helper_->CancelRequest(group_name, handle); } - void ReleaseSocket(const std::string& group_name, ClientSocket* socket, int id) { + void ReleaseSocket(const std::string& group_name, ClientSocket* socket, + int id) { return helper_->ReleaseSocket(group_name, socket, id); } diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 286949a..c9ad282 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -423,7 +423,8 @@ class ClientSocketPoolBaseTest : public ClientSocketPoolTest { CreatePoolWithIdleTimeouts( max_sockets, max_sockets_per_group, - base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout), + base::TimeDelta::FromSeconds( + ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout)); } diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc index ad924f8..455b671 100644 --- a/net/socket/socks_client_socket_pool.cc +++ b/net/socket/socks_client_socket_pool.cc @@ -166,7 +166,8 @@ SOCKSClientSocketPool::SOCKSClientSocketPool( NetworkChangeNotifier* network_change_notifier, NetLog* net_log) : base_(max_sockets, max_sockets_per_group, histograms, - base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout), + base::TimeDelta::FromSeconds( + ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), new SOCKSConnectJobFactory(tcp_pool, host_resolver, net_log), network_change_notifier) {} diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc index b798bc4..f2e9609 100644 --- a/net/socket/tcp_client_socket_pool.cc +++ b/net/socket/tcp_client_socket_pool.cc @@ -181,7 +181,8 @@ TCPClientSocketPool::TCPClientSocketPool( NetworkChangeNotifier* network_change_notifier, NetLog* net_log) : base_(max_sockets, max_sockets_per_group, histograms, - base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout), + base::TimeDelta::FromSeconds( + ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), new TCPConnectJobFactory(client_socket_factory, host_resolver, net_log), |