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

Side by Side Diff: net/socket/client_socket_pool_base.cc

Issue 2086903003: net: Add some metrics on reuse of idle sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/histogram_macros.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
20 #include "base/values.h" 21 #include "base/values.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/log/net_log.h" 23 #include "net/log/net_log.h"
23 24
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 base::TimeDelta idle_time, 969 base::TimeDelta idle_time,
969 Group* group, 970 Group* group,
970 const BoundNetLog& net_log) { 971 const BoundNetLog& net_log) {
971 DCHECK(socket); 972 DCHECK(socket);
972 handle->SetSocket(std::move(socket)); 973 handle->SetSocket(std::move(socket));
973 handle->set_reuse_type(reuse_type); 974 handle->set_reuse_type(reuse_type);
974 handle->set_idle_time(idle_time); 975 handle->set_idle_time(idle_time);
975 handle->set_pool_id(pool_generation_number_); 976 handle->set_pool_id(pool_generation_number_);
976 handle->set_connect_timing(connect_timing); 977 handle->set_connect_timing(connect_timing);
977 978
978 if (handle->is_reused()) { 979 if (reuse_type == ClientSocketHandle::REUSED_IDLE) {
979 net_log.AddEvent( 980 net_log.AddEvent(
980 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, 981 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET,
981 NetLog::IntCallback("idle_ms", 982 NetLog::IntCallback("idle_ms",
982 static_cast<int>(idle_time.InMilliseconds()))); 983 static_cast<int>(idle_time.InMilliseconds())));
984
985 UMA_HISTOGRAM_COUNTS_1000("Net.Socket.IdleSocketReuseTime",
986 idle_time.InSeconds());
987 }
988
989 if (reuse_type != ClientSocketHandle::UNUSED) {
990 // The socket being handed out is no longer considered idle, but was
991 // considered idle until just before this method was called.
992 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.Socket.NumIdleSockets",
993 idle_socket_count() + 1, 1, 256, 50);
983 } 994 }
984 995
985 net_log.AddEvent( 996 net_log.AddEvent(
986 NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, 997 NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET,
987 handle->socket()->NetLog().source().ToEventParametersCallback()); 998 handle->socket()->NetLog().source().ToEventParametersCallback());
988 999
989 handed_out_socket_count_++; 1000 handed_out_socket_count_++;
990 group->IncrementActiveSocketCount(); 1001 group->IncrementActiveSocketCount();
991 } 1002 }
992 1003
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 // If there are no more requests, kill the backup timer. 1320 // If there are no more requests, kill the backup timer.
1310 if (pending_requests_.empty()) 1321 if (pending_requests_.empty())
1311 backup_job_timer_.Stop(); 1322 backup_job_timer_.Stop();
1312 request->CrashIfInvalid(); 1323 request->CrashIfInvalid();
1313 return request; 1324 return request;
1314 } 1325 }
1315 1326
1316 } // namespace internal 1327 } // namespace internal
1317 1328
1318 } // namespace net 1329 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698