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

Side by Side Diff: net/http/http_stream_factory_impl.cc

Issue 2809453002: Add JobController/Job count to UMA histograms when the count hits limit (Closed)
Patch Set: change a comment Created 3 years, 8 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
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/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } // anonymous namespace 100 } // anonymous namespace
101 101
102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, 102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session,
103 bool for_websockets) 103 bool for_websockets)
104 : session_(session), 104 : session_(session),
105 job_factory_(new DefaultJobFactory()), 105 job_factory_(new DefaultJobFactory()),
106 for_websockets_(for_websockets) {} 106 for_websockets_(for_websockets) {}
107 107
108 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { 108 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() {
109 DCHECK(spdy_session_request_map_.empty()); 109 DCHECK(spdy_session_request_map_.empty());
110 int alt_job_count = 0; 110 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobControllerAtShutDown",
111 int main_job_count = 0; 111 job_controller_set_.size());
112 int preconnect_controller_count = 0;
113 for (const auto& it : job_controller_set_) {
114 DCHECK(it->HasPendingAltJob() || it->HasPendingMainJob());
115 // For a preconnect controller, it should have exactly the main job.
116 if (it->is_preconnect()) {
117 preconnect_controller_count++;
118 continue;
119 }
120 // For non-preconnects.
121 if (it->HasPendingAltJob())
122 alt_job_count++;
123 if (it->HasPendingMainJob())
124 main_job_count++;
125 }
126 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect",
127 preconnect_controller_count);
128 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob",
129 alt_job_count);
130 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob",
131 main_job_count);
132 } 112 }
133 113
134 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( 114 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream(
135 const HttpRequestInfo& request_info, 115 const HttpRequestInfo& request_info,
136 RequestPriority priority, 116 RequestPriority priority,
137 const SSLConfig& server_ssl_config, 117 const SSLConfig& server_ssl_config,
138 const SSLConfig& proxy_ssl_config, 118 const SSLConfig& proxy_ssl_config,
139 HttpStreamRequest::Delegate* delegate, 119 HttpStreamRequest::Delegate* delegate,
140 bool enable_ip_based_pooling, 120 bool enable_ip_based_pooling,
141 bool enable_alternative_services, 121 bool enable_alternative_services,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 RequestPriority priority, 168 RequestPriority priority,
189 const SSLConfig& server_ssl_config, 169 const SSLConfig& server_ssl_config,
190 const SSLConfig& proxy_ssl_config, 170 const SSLConfig& proxy_ssl_config,
191 HttpStreamRequest::Delegate* delegate, 171 HttpStreamRequest::Delegate* delegate,
192 WebSocketHandshakeStreamBase::CreateHelper* 172 WebSocketHandshakeStreamBase::CreateHelper*
193 websocket_handshake_stream_create_helper, 173 websocket_handshake_stream_create_helper,
194 HttpStreamRequest::StreamType stream_type, 174 HttpStreamRequest::StreamType stream_type,
195 bool enable_ip_based_pooling, 175 bool enable_ip_based_pooling,
196 bool enable_alternative_services, 176 bool enable_alternative_services,
197 const NetLogWithSource& net_log) { 177 const NetLogWithSource& net_log) {
178 AddJobControllerCountToHistograms();
179
198 auto job_controller = base::MakeUnique<JobController>( 180 auto job_controller = base::MakeUnique<JobController>(
199 this, delegate, session_, job_factory_.get(), request_info, 181 this, delegate, session_, job_factory_.get(), request_info,
200 /* is_preconnect = */ false, enable_ip_based_pooling, 182 /* is_preconnect = */ false, enable_ip_based_pooling,
201 enable_alternative_services); 183 enable_alternative_services);
202 JobController* job_controller_raw_ptr = job_controller.get(); 184 JobController* job_controller_raw_ptr = job_controller.get();
203 job_controller_set_.insert(std::move(job_controller)); 185 job_controller_set_.insert(std::move(job_controller));
204 Request* request = job_controller_raw_ptr->Start( 186 Request* request = job_controller_raw_ptr->Start(
205 request_info, delegate, websocket_handshake_stream_create_helper, net_log, 187 request_info, delegate, websocket_handshake_stream_create_helper, net_log,
206 stream_type, priority, server_ssl_config, proxy_ssl_config); 188 stream_type, priority, server_ssl_config, proxy_ssl_config);
207 189
208 return request; 190 return request;
209 } 191 }
210 192
211 void HttpStreamFactoryImpl::PreconnectStreams( 193 void HttpStreamFactoryImpl::PreconnectStreams(
212 int num_streams, 194 int num_streams,
213 const HttpRequestInfo& request_info) { 195 const HttpRequestInfo& request_info) {
196 AddJobControllerCountToHistograms();
197
214 SSLConfig server_ssl_config; 198 SSLConfig server_ssl_config;
215 SSLConfig proxy_ssl_config; 199 SSLConfig proxy_ssl_config;
216 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); 200 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config);
217 // All preconnects should perform EV certificate verification. 201 // All preconnects should perform EV certificate verification.
218 server_ssl_config.verify_ev_cert = true; 202 server_ssl_config.verify_ev_cert = true;
219 proxy_ssl_config.verify_ev_cert = true; 203 proxy_ssl_config.verify_ev_cert = true;
220 204
221 DCHECK(!for_websockets_); 205 DCHECK(!for_websockets_);
222 206
223 auto job_controller = base::MakeUnique<JobController>( 207 auto job_controller = base::MakeUnique<JobController>(
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 HostPortPair host_port_pair = proxy_info.proxy_server().host_port_pair(); 349 HostPortPair host_port_pair = proxy_info.proxy_server().host_port_pair();
366 DCHECK(!host_port_pair.IsEmpty()); 350 DCHECK(!host_port_pair.IsEmpty());
367 351
368 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), 352 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(),
369 host_port_pair.port()); 353 host_port_pair.port());
370 354
371 return session_->http_server_properties()->SupportsRequestPriority( 355 return session_->http_server_properties()->SupportsRequestPriority(
372 scheme_host_port); 356 scheme_host_port);
373 } 357 }
374 358
359 void HttpStreamFactoryImpl::AddJobControllerCountToHistograms() const {
360 // Only log the count of JobControllers when the count is hitting the
361 // boundary: 100, 200, 400, etc.
362 if (job_controller_set_.size() % 100 != 0)
363 return;
364
365 unsigned int job_controller_count_100 = job_controller_set_.size() / 100;
366 if ((job_controller_count_100 & (job_controller_count_100 - 1)) != 0)
367 return;
xunjieli 2017/04/10 23:13:21 Line 362 to 367 can be written as: if (job_contr
Zhongyi Shi 2017/04/10 23:30:12 Changed the limit to a multiple of 100.
368
369 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobController",
370 job_controller_set_.size());
371
372 int alt_job_count = 0;
373 int main_job_count = 0;
374 int preconnect_controller_count = 0;
375 for (const auto& job_controller : job_controller_set_) {
376 DCHECK(job_controller->HasPendingAltJob() ||
377 job_controller->HasPendingMainJob());
378 // For a preconnect controller, it should have exactly the main job.
379 if (job_controller->is_preconnect()) {
380 preconnect_controller_count++;
381 continue;
382 }
383 // For non-preconnects.
384 if (job_controller->HasPendingAltJob())
385 alt_job_count++;
386 if (job_controller->HasPendingMainJob())
387 main_job_count++;
388 }
389 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect",
390 preconnect_controller_count);
391 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob",
392 alt_job_count);
393 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob",
394 main_job_count);
395 }
396
375 void HttpStreamFactoryImpl::DumpMemoryStats( 397 void HttpStreamFactoryImpl::DumpMemoryStats(
376 base::trace_event::ProcessMemoryDump* pmd, 398 base::trace_event::ProcessMemoryDump* pmd,
377 const std::string& parent_absolute_name) const { 399 const std::string& parent_absolute_name) const {
378 if (job_controller_set_.empty()) 400 if (job_controller_set_.empty())
379 return; 401 return;
380 std::string name = 402 std::string name =
381 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); 403 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str());
382 base::trace_event::MemoryAllocatorDump* factory_dump = 404 base::trace_event::MemoryAllocatorDump* factory_dump =
383 pmd->CreateAllocatorDump(name); 405 pmd->CreateAllocatorDump(name);
384 size_t alt_job_count = 0; 406 size_t alt_job_count = 0;
(...skipping 27 matching lines...) Expand all
412 factory_dump->AddScalar("main_job_count", 434 factory_dump->AddScalar("main_job_count",
413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 435 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
414 main_job_count); 436 main_job_count);
415 // The number of preconnect controllers. 437 // The number of preconnect controllers.
416 factory_dump->AddScalar("preconnect_count", 438 factory_dump->AddScalar("preconnect_count",
417 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 439 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
418 preconnect_controller_count); 440 preconnect_controller_count);
419 } 441 }
420 442
421 } // namespace net 443 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698