Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_impl.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
| index 39108877eb551027f55ebfd7e6d29a13dc89690d..d3919eee0a6c3949abd2ce4965d71f00d0b0fb39 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_impl.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
| @@ -168,6 +168,9 @@ static ResourceDispatcherHostImpl* g_resource_dispatcher_host; |
| // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates |
| const int kUpdateLoadStatesIntervalMsec = 250; |
| +// The interval for calls to RecordOutstandingRequestsStats. |
| +const int kRecordOutstandingRequestsStatsIntervalMsec = 60000; |
| + |
| // Maximum byte "cost" of all the outstanding requests for a renderer. |
| // See declaration of |max_outstanding_requests_cost_per_process_| for details. |
| // This bound is 25MB, which allows for around 6000 outstanding requests. |
| @@ -339,6 +342,8 @@ ResourceDispatcherHostImpl::ResourceDispatcherHostImpl( |
| kMaxOutstandingRequestsCostPerProcess), |
| largest_outstanding_request_count_seen_(0), |
| largest_outstanding_request_per_process_count_seen_(0), |
| + peak_outstanding_request_count_(0), |
| + peak_outstanding_request_count_multitab_(0), |
| delegate_(nullptr), |
| loader_delegate_(nullptr), |
| allow_cross_origin_auth_prompt_(false), |
| @@ -361,6 +366,7 @@ ResourceDispatcherHostImpl::ResourceDispatcherHostImpl( |
| base::Bind(&ResourceDispatcherHostImpl::OnInit, base::Unretained(this))); |
| update_load_states_timer_.reset(new base::RepeatingTimer()); |
| + record_outstanding_requests_stats_timer_.reset(new base::RepeatingTimer()); |
| } |
| // The default ctor is only used by unittests. It is reasonable to assume that |
| @@ -589,13 +595,20 @@ bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader, |
| } |
| void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) { |
| - // Make sure we have the load state monitor running. |
| + // Make sure we have the load state monitors running. |
| if (!update_load_states_timer_->IsRunning() && |
| scheduler_->HasLoadingClients()) { |
| update_load_states_timer_->Start( |
| FROM_HERE, TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
| this, &ResourceDispatcherHostImpl::UpdateLoadInfo); |
| } |
| + if (!record_outstanding_requests_stats_timer_->IsRunning()) { |
| + record_outstanding_requests_stats_timer_->Start( |
| + FROM_HERE, |
| + TimeDelta::FromMilliseconds( |
| + kRecordOutstandingRequestsStatsIntervalMsec), |
| + this, &ResourceDispatcherHostImpl::RecordOutstandingRequestsStats); |
| + } |
| } |
| void ResourceDispatcherHostImpl::DidReceiveRedirect( |
| @@ -784,10 +797,11 @@ void ResourceDispatcherHostImpl::OnShutdown() { |
| is_shutdown_ = true; |
| pending_loaders_.clear(); |
| - // Make sure we shutdown the timer now, otherwise by the time our destructor |
| + // Make sure we shutdown the timers now, otherwise by the time our destructor |
| // runs if the timer is still running the Task is deleted twice (once by |
| // the MessageLoop and the second time by RepeatingTimer). |
| update_load_states_timer_.reset(); |
| + record_outstanding_requests_stats_timer_.reset(); |
| // Clear blocked requests if any left. |
| // Note that we have to do this in 2 passes as we cannot call |
| @@ -1969,6 +1983,15 @@ ResourceDispatcherHostImpl::IncrementOutstandingRequestsCount( |
| largest_outstanding_request_per_process_count_seen_); |
| } |
| + if (num_in_flight_requests_ > peak_outstanding_request_count_) { |
| + peak_outstanding_request_count_ = num_in_flight_requests_; |
| + } |
| + |
| + if (outstanding_requests_stats_map_.size() >= 2 && |
|
Takashi Toyoshima
2017/06/20 07:39:21
This will report if there is one background tab th
Kunihiko Sakamoto
2017/06/20 08:39:28
Done.
|
| + num_in_flight_requests_ > peak_outstanding_request_count_multitab_) { |
| + peak_outstanding_request_count_multitab_ = num_in_flight_requests_; |
| + } |
| + |
| return stats; |
| } |
| @@ -2497,6 +2520,22 @@ void ResourceDispatcherHostImpl::UpdateLoadInfo() { |
| base::Bind(UpdateLoadStateOnUI, loader_delegate_, base::Passed(&infos))); |
| } |
| +void ResourceDispatcherHostImpl::RecordOutstandingRequestsStats() { |
| + if (peak_outstanding_request_count_ != 0) { |
| + UMA_HISTOGRAM_COUNTS_1M( |
| + "Net.ResourceDispatcherHost.PeakOutstandingRequests", |
| + peak_outstanding_request_count_); |
| + peak_outstanding_request_count_ = 0; |
|
Takashi Toyoshima
2017/06/20 07:39:21
this will not report at the next time if there are
Kunihiko Sakamoto
2017/06/20 08:39:28
Good catch, thanks!
Done.
|
| + } |
| + |
| + if (peak_outstanding_request_count_multitab_ != 0) { |
| + UMA_HISTOGRAM_COUNTS_1M( |
| + "Net.ResourceDispatcherHost.PeakOutstandingRequests.MultiTabLoading", |
| + peak_outstanding_request_count_multitab_); |
| + peak_outstanding_request_count_multitab_ = 0; |
| + } |
| +} |
| + |
| void ResourceDispatcherHostImpl::BlockRequestsForRoute( |
| const GlobalFrameRoutingId& global_routing_id) { |
| DCHECK(io_thread_task_runner_->BelongsToCurrentThread()); |