Commit b78c75b4 authored by Kunihiko Sakamoto's avatar Kunihiko Sakamoto Committed by Commit Bot

Add UMA for per-frame outstanding resource requests

This adds UMA to track the peak number of requests with "running" state
in ResourceLoadScheduler. The value is reported when the frame is
reached the network 2-quiet state.

Bug: 729951
Change-Id: I6d2c6f5f5094a0a8071904484cb10d14de087e7c
Reviewed-on: https://chromium-review.googlesource.com/564872Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarTakashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486727}
parent 9a7108cd
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
#include "core/timing/PerformanceBase.h" #include "core/timing/PerformanceBase.h"
#include "platform/WebFrameScheduler.h" #include "platform/WebFrameScheduler.h"
#include "platform/exported/WrappedResourceRequest.h" #include "platform/exported/WrappedResourceRequest.h"
#include "platform/instrumentation/resource_coordinator/FrameResourceCoordinator.h"
#include "platform/instrumentation/tracing/TracedValue.h" #include "platform/instrumentation/tracing/TracedValue.h"
#include "platform/loader/fetch/ClientHintsPreferences.h" #include "platform/loader/fetch/ClientHintsPreferences.h"
#include "platform/loader/fetch/FetchInitiatorTypeNames.h" #include "platform/loader/fetch/FetchInitiatorTypeNames.h"
...@@ -606,9 +605,8 @@ void FrameFetchContext::DidLoadResource(Resource* resource) { ...@@ -606,9 +605,8 @@ void FrameFetchContext::DidLoadResource(Resource* resource) {
if (!document_) if (!document_)
return; return;
FirstMeaningfulPaintDetector::From(*document_).CheckNetworkStable(); FirstMeaningfulPaintDetector::From(*document_).CheckNetworkStable();
if (FrameResourceCoordinator::IsEnabled()) { NetworkQuietDetector::From(*document_).CheckNetworkStable();
NetworkQuietDetector::From(*document_).CheckNetworkStable();
}
if (resource->IsLoadEventBlockingResourceType()) if (resource->IsLoadEventBlockingResourceType())
document_->CheckCompleted(); document_->CheckCompleted();
} }
......
...@@ -69,12 +69,16 @@ void NetworkQuietDetector::NetworkQuietTimerFired(TimerBase*) { ...@@ -69,12 +69,16 @@ void NetworkQuietDetector::NetworkQuietTimerFired(TimerBase*) {
ActiveConnections() > kNetworkQuietMaximumConnections) ActiveConnections() > kNetworkQuietMaximumConnections)
return; return;
network_quiet_reached_ = true; network_quiet_reached_ = true;
auto frame_resource_coordinator = if (FrameResourceCoordinator::IsEnabled()) {
GetSupplementable()->GetFrame()->GetFrameResourceCoordinator(); auto frame_resource_coordinator =
if (frame_resource_coordinator) { GetSupplementable()->GetFrame()->GetFrameResourceCoordinator();
frame_resource_coordinator->SendEvent( if (frame_resource_coordinator) {
resource_coordinator::mojom::EventType::kOnLocalFrameNetworkIdle); frame_resource_coordinator->SendEvent(
resource_coordinator::mojom::EventType::kOnLocalFrameNetworkIdle);
}
} }
GetSupplementable()->Fetcher()->OnNetworkQuiet();
} }
DEFINE_TRACE(NetworkQuietDetector) { DEFINE_TRACE(NetworkQuietDetector) {
......
...@@ -155,6 +155,8 @@ class PLATFORM_EXPORT ResourceFetcher ...@@ -155,6 +155,8 @@ class PLATFORM_EXPORT ResourceFetcher
void RemovePreload(Resource*); void RemovePreload(Resource*);
void OnNetworkQuiet() { scheduler_->OnNetworkQuiet(); }
// Workaround for https://crbug.com/666214. // Workaround for https://crbug.com/666214.
// TODO(hiroshige): Remove this hack. // TODO(hiroshige): Remove this hack.
void EmulateLoadStartedForInspector(Resource*, void EmulateLoadStartedForInspector(Resource*,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "platform/Histogram.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
namespace blink { namespace blink {
...@@ -132,13 +133,74 @@ void ResourceLoadScheduler::SetOutstandingLimitForTesting(size_t limit) { ...@@ -132,13 +133,74 @@ void ResourceLoadScheduler::SetOutstandingLimitForTesting(size_t limit) {
SetOutstandingLimitAndMaybeRun(limit); SetOutstandingLimitAndMaybeRun(limit);
} }
void ResourceLoadScheduler::OnNetworkQuiet() {
DCHECK(IsMainThread());
if (maximum_running_requests_seen_ == 0)
return;
DEFINE_STATIC_LOCAL(
CustomCountHistogram, main_frame_throttled,
("Blink.ResourceLoadScheduler.PeakRequests.MainframeThrottled", 0, 10000,
25));
DEFINE_STATIC_LOCAL(
CustomCountHistogram, main_frame_not_throttled,
("Blink.ResourceLoadScheduler.PeakRequests.MainframeNotThrottled", 0,
10000, 25));
DEFINE_STATIC_LOCAL(
CustomCountHistogram, main_frame_partially_throttled,
("Blink.ResourceLoadScheduler.PeakRequests.MainframePartiallyThrottled",
0, 10000, 25));
DEFINE_STATIC_LOCAL(
CustomCountHistogram, sub_frame_throttled,
("Blink.ResourceLoadScheduler.PeakRequests.SubframeThrottled", 0, 10000,
25));
DEFINE_STATIC_LOCAL(
CustomCountHistogram, sub_frame_not_throttled,
("Blink.ResourceLoadScheduler.PeakRequests.SubframeNotThrottled", 0,
10000, 25));
DEFINE_STATIC_LOCAL(
CustomCountHistogram, sub_frame_partially_throttled,
("Blink.ResourceLoadScheduler.PeakRequests.SubframePartiallyThrottled", 0,
10000, 25));
switch (throttling_history_) {
case ThrottlingHistory::kInitial:
case ThrottlingHistory::kNotThrottled:
if (context_->IsMainFrame())
main_frame_not_throttled.Count(maximum_running_requests_seen_);
else
sub_frame_not_throttled.Count(maximum_running_requests_seen_);
break;
case ThrottlingHistory::kThrottled:
if (context_->IsMainFrame())
main_frame_throttled.Count(maximum_running_requests_seen_);
else
sub_frame_throttled.Count(maximum_running_requests_seen_);
break;
case ThrottlingHistory::kPartiallyThrottled:
if (context_->IsMainFrame())
main_frame_partially_throttled.Count(maximum_running_requests_seen_);
else
sub_frame_partially_throttled.Count(maximum_running_requests_seen_);
break;
}
}
void ResourceLoadScheduler::OnThrottlingStateChanged( void ResourceLoadScheduler::OnThrottlingStateChanged(
WebFrameScheduler::ThrottlingState state) { WebFrameScheduler::ThrottlingState state) {
switch (state) { switch (state) {
case WebFrameScheduler::ThrottlingState::kThrottled: case WebFrameScheduler::ThrottlingState::kThrottled:
if (throttling_history_ == ThrottlingHistory::kInitial)
throttling_history_ = ThrottlingHistory::kThrottled;
else if (throttling_history_ == ThrottlingHistory::kNotThrottled)
throttling_history_ = ThrottlingHistory::kPartiallyThrottled;
SetOutstandingLimitAndMaybeRun(outstanding_throttled_limit_); SetOutstandingLimitAndMaybeRun(outstanding_throttled_limit_);
break; break;
case WebFrameScheduler::ThrottlingState::kNotThrottled: case WebFrameScheduler::ThrottlingState::kNotThrottled:
if (throttling_history_ == ThrottlingHistory::kInitial)
throttling_history_ = ThrottlingHistory::kNotThrottled;
else if (throttling_history_ == ThrottlingHistory::kThrottled)
throttling_history_ = ThrottlingHistory::kPartiallyThrottled;
SetOutstandingLimitAndMaybeRun(kOutstandingUnlimited); SetOutstandingLimitAndMaybeRun(kOutstandingUnlimited);
break; break;
} }
...@@ -172,6 +234,9 @@ void ResourceLoadScheduler::MaybeRun() { ...@@ -172,6 +234,9 @@ void ResourceLoadScheduler::MaybeRun() {
void ResourceLoadScheduler::Run(ResourceLoadScheduler::ClientId id, void ResourceLoadScheduler::Run(ResourceLoadScheduler::ClientId id,
ResourceLoadSchedulerClient* client) { ResourceLoadSchedulerClient* client) {
running_requests_.insert(id); running_requests_.insert(id);
if (running_requests_.size() > maximum_running_requests_seen_) {
maximum_running_requests_seen_ = running_requests_.size();
}
client->Run(); client->Run();
} }
......
...@@ -83,6 +83,8 @@ class PLATFORM_EXPORT ResourceLoadScheduler final ...@@ -83,6 +83,8 @@ class PLATFORM_EXPORT ResourceLoadScheduler final
// Sets outstanding limit for testing. // Sets outstanding limit for testing.
void SetOutstandingLimitForTesting(size_t limit); void SetOutstandingLimitForTesting(size_t limit);
void OnNetworkQuiet();
// WebFrameScheduler::Observer overrides: // WebFrameScheduler::Observer overrides:
void OnThrottlingStateChanged(WebFrameScheduler::ThrottlingState) override; void OnThrottlingStateChanged(WebFrameScheduler::ThrottlingState) override;
...@@ -122,6 +124,17 @@ class PLATFORM_EXPORT ResourceLoadScheduler final ...@@ -122,6 +124,17 @@ class PLATFORM_EXPORT ResourceLoadScheduler final
// Holds clients that were granted and are running. // Holds clients that were granted and are running.
HashSet<ClientId> running_requests_; HashSet<ClientId> running_requests_;
// Largest number of running requests seen so far.
unsigned maximum_running_requests_seen_ = 0;
enum class ThrottlingHistory {
kInitial,
kThrottled,
kNotThrottled,
kPartiallyThrottled
};
ThrottlingHistory throttling_history_ = ThrottlingHistory::kInitial;
// Holds clients that haven't been granted, and are waiting for a grant. // Holds clients that haven't been granted, and are waiting for a grant.
HeapHashMap<ClientId, Member<ResourceLoadSchedulerClient>> HeapHashMap<ClientId, Member<ResourceLoadSchedulerClient>>
pending_request_map_; pending_request_map_;
......
...@@ -5670,6 +5670,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -5670,6 +5670,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram base="true" name="Blink.ResourceLoadScheduler.PeakRequests"
units="requests">
<!-- Name completed by histogram_suffixes name="ResourceLoadScheduler.FrameType" -->
<owner>ksakamoto@chromium.org</owner>
<summary>
The largest number of outstanding resource requests issued by a frame until
the network 2-quiet (no more than 2 active network requests for 1 seconds).
</summary>
</histogram>
<histogram name="Blink.RestoredCachedStyleSheet" <histogram name="Blink.RestoredCachedStyleSheet"
enum="RestoredCachedStyleSheet"> enum="RestoredCachedStyleSheet">
<obsolete> <obsolete>
...@@ -96581,6 +96592,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -96581,6 +96592,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<affected-histogram name="Net.ResourceLoader.ResponseStartToEnd"/> <affected-histogram name="Net.ResourceLoader.ResponseStartToEnd"/>
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="ResourceLoadScheduler.FrameType" separator=".">
<suffix name="MainframeThrottled" label="Main frame, throttled"/>
<suffix name="MainframeNotThrottled" label="Main frame, not throttled"/>
<suffix name="MainframePartiallyThrottled"
label="Main frame, partially throttled"/>
<suffix name="SubframeThrottled" label="Sub frame, throttled"/>
<suffix name="SubframeNotThrottled" label="Sub frame, not throttled"/>
<suffix name="SubframePartiallyThrottled"
label="Sub frame, partially throttled"/>
<affected-histogram name="Blink.ResourceLoadScheduler.PeakRequests"/>
</histogram_suffixes>
<histogram_suffixes name="ResourcePrefetchPredictorNetworkTypePrefetch" <histogram_suffixes name="ResourcePrefetchPredictorNetworkTypePrefetch"
separator="."> separator=".">
<obsolete> <obsolete>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment