diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-06 23:41:21 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-06 23:41:21 +0000 |
commit | 6def96414460fb519dc1583aaff3271b07cfba11 (patch) | |
tree | b4b5689d359f09db96172bc98d2d07bd3ba9368f | |
parent | 7e3f8d7c6b71822780bae98c5247b77876560d90 (diff) | |
download | chromium_src-6def96414460fb519dc1583aaff3271b07cfba11.zip chromium_src-6def96414460fb519dc1583aaff3271b07cfba11.tar.gz chromium_src-6def96414460fb519dc1583aaff3271b07cfba11.tar.bz2 |
Added histograms to see if the interval between consecutive connects has
an impact on connect time.
R=jar@chromium.org
NOTRY=true
Review URL: https://codereview.chromium.org/26098002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227233 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/socket/transport_client_socket_pool.cc | 42 | ||||
-rw-r--r-- | net/socket/transport_client_socket_pool.h | 4 |
2 files changed, 45 insertions, 1 deletions
diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc index d03e3e6..87bfc6a 100644 --- a/net/socket/transport_client_socket_pool.cc +++ b/net/socket/transport_client_socket_pool.cc @@ -7,10 +7,12 @@ #include <algorithm> #include "base/compiler_specific.h" +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/strings/string_util.h" +#include "base/synchronization/lock.h" #include "base/time/time.h" #include "base/values.h" #include "net/base/ip_endpoint.h" @@ -46,6 +48,13 @@ bool AddressListOnlyContainsIPv6(const AddressList& list) { } // namespace +// This lock protects |g_last_connect_time|. +static base::LazyInstance<base::Lock>::Leaky + g_last_connect_time_lock = LAZY_INSTANCE_INITIALIZER; + +// |g_last_connect_time| has the last time a connect() call is made. +static base::TimeTicks g_last_connect_time; + TransportSocketParams::TransportSocketParams( const HostPortPair& host_port_pair, bool disable_resolver_cache, @@ -85,7 +94,8 @@ TransportConnectJob::TransportConnectJob( params_(params), client_socket_factory_(client_socket_factory), resolver_(host_resolver), - next_state_(STATE_NONE) { + next_state_(STATE_NONE), + less_than_20ms_since_connect_(true) { } TransportConnectJob::~TransportConnectJob() { @@ -186,6 +196,20 @@ int TransportConnectJob::DoResolveHostComplete(int result) { } int TransportConnectJob::DoTransportConnect() { + base::TimeTicks now = base::TimeTicks::Now(); + base::TimeTicks last_connect_time; + { + base::AutoLock lock(g_last_connect_time_lock.Get()); + last_connect_time = g_last_connect_time; + g_last_connect_time = now; + } + if (last_connect_time.is_null() || + (now - last_connect_time).InMilliseconds() < 20) { + less_than_20ms_since_connect_ = true; + } else { + less_than_20ms_since_connect_ = false; + } + next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; transport_socket_ = client_socket_factory_->CreateTransportClientSocket( addresses_, net_log().net_log(), net_log().source()); @@ -222,6 +246,22 @@ int TransportConnectJob::DoTransportConnectComplete(int result) { base::TimeDelta::FromMinutes(10), 100); + if (less_than_20ms_since_connect_) { + UMA_HISTOGRAM_CUSTOM_TIMES( + "Net.TCP_Connection_Latency_Interval_20ms_Minus", + connect_duration, + base::TimeDelta::FromMilliseconds(1), + base::TimeDelta::FromMinutes(10), + 100); + } else { + UMA_HISTOGRAM_CUSTOM_TIMES( + "Net.TCP_Connection_Latency_Interval_20ms_Plus", + connect_duration, + base::TimeDelta::FromMilliseconds(1), + base::TimeDelta::FromMinutes(10), + 100); + } + if (is_ipv4) { UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency_IPv4_No_Race", connect_duration, diff --git a/net/socket/transport_client_socket_pool.h b/net/socket/transport_client_socket_pool.h index 16e421a..95b51c3 100644 --- a/net/socket/transport_client_socket_pool.h +++ b/net/socket/transport_client_socket_pool.h @@ -125,6 +125,10 @@ class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { base::TimeTicks fallback_connect_start_time_; base::OneShotTimer<TransportConnectJob> fallback_timer_; + // If the interval between this connect and previous connect is less than + // 20ms, then |less_than_20ms_since_connect_| is set to true. + bool less_than_20ms_since_connect_; + DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); }; |