Commit 82c469c8 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Set up a finch experiment on RendererSideResourceScheduler

This CL sets the outstanding limits for ResourceLoadScheduler for the
experiment, and disables the body detection logic  from
ResourceScheduler.

Bug: 785770
Change-Id: I178d65da2681a1790dc1fc67c1318d9c809007a7
Reviewed-on: https://chromium-review.googlesource.com/799612
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarTakashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarRandy Smith <rdsmith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521519}
parent fce9ec8d
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "content/common/resource_messages.h" #include "content/common/resource_messages.h"
#include "content/public/browser/resource_request_info.h" #include "content/public/browser/resource_request_info.h"
#include "content/public/browser/resource_throttle.h" #include "content/public/browser/resource_throttle.h"
#include "content/public/common/content_features.h"
#include "net/base/host_port_pair.h" #include "net/base/host_port_pair.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
...@@ -423,7 +424,15 @@ class ResourceScheduler::Client { ...@@ -423,7 +424,15 @@ class ResourceScheduler::Client {
resource_scheduler->throttle_delayable_.GetMaxDelayableRequests( resource_scheduler->throttle_delayable_.GetMaxDelayableRequests(
network_quality_estimator)), network_quality_estimator)),
resource_scheduler_(resource_scheduler), resource_scheduler_(resource_scheduler),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {
if (base::FeatureList::IsEnabled(
features::kRendererSideResourceScheduler)) {
// When kRendererSideResourceScheduler is enabled, "layout blocking"
// concept is moved to the renderer side, so the shceduler works always
// with the normal mode.
has_html_body_ = true;
}
}
~Client() {} ~Client() {}
...@@ -488,6 +497,14 @@ class ResourceScheduler::Client { ...@@ -488,6 +497,14 @@ class ResourceScheduler::Client {
void OnNavigate() { void OnNavigate() {
has_html_body_ = false; has_html_body_ = false;
if (base::FeatureList::IsEnabled(
features::kRendererSideResourceScheduler)) {
// When kRendererSideResourceScheduler is enabled, "layout blocking"
// concept is moved to the renderer side, so the shceduler works always
// with the normal mode.
has_html_body_ = true;
}
is_loaded_ = false; is_loaded_ = false;
max_delayable_requests_ = max_delayable_requests_ =
resource_scheduler_->throttle_delayable_.GetMaxDelayableRequests( resource_scheduler_->throttle_delayable_.GetMaxDelayableRequests(
...@@ -960,6 +977,8 @@ class ResourceScheduler::Client { ...@@ -960,6 +977,8 @@ class ResourceScheduler::Client {
bool is_loaded_; bool is_loaded_;
// Tracks if the main HTML parser has reached the body which marks the end of // Tracks if the main HTML parser has reached the body which marks the end of
// layout-blocking resources. // layout-blocking resources.
// This is disabled and the is always true when kRendererSideResourceScheduler
// is enabled.
bool has_html_body_; bool has_html_body_;
bool using_spdy_proxy_; bool using_spdy_proxy_;
RequestQueue pending_requests_; RequestQueue pending_requests_;
......
...@@ -38,6 +38,19 @@ constexpr base::HistogramBase::Sample kMaximumReportSize1G = ...@@ -38,6 +38,19 @@ constexpr base::HistogramBase::Sample kMaximumReportSize1G =
// Bucket count for metrics. // Bucket count for metrics.
constexpr int32_t kReportBucketCount = 25; constexpr int32_t kReportBucketCount = 25;
constexpr char kRendererSideResourceScheduler[] =
"RendererSideResourceScheduler";
// These values are copied from resource_scheduler.cc, but the meaning is a bit
// different because ResourceScheduler counts the running delayable requests
// while ResourceLoadScheduler counts all the running requests.
constexpr size_t kTightLimitForRendererSideResourceScheduler = 1u;
constexpr size_t kLimitForRendererSideResourceScheduler = 10u;
constexpr char kTightLimitForRendererSideResourceSchedulerName[] =
"tight_limit";
constexpr char kLimitForRendererSideResourceSchedulerName[] = "limit";
// Represents a resource load circumstance, e.g. from main frame vs sub-frames, // Represents a resource load circumstance, e.g. from main frame vs sub-frames,
// or on throttled state vs on not-throttled state. // or on throttled state vs on not-throttled state.
// Used to report histograms. Do not reorder or insert new items. // Used to report histograms. Do not reorder or insert new items.
...@@ -54,14 +67,15 @@ base::HistogramBase::Sample ToSample(ReportCircumstance circumstance) { ...@@ -54,14 +67,15 @@ base::HistogramBase::Sample ToSample(ReportCircumstance circumstance) {
return static_cast<base::HistogramBase::Sample>(circumstance); return static_cast<base::HistogramBase::Sample>(circumstance);
} }
uint32_t GetFieldTrialUint32Param(const char* name, uint32_t default_param) { uint32_t GetFieldTrialUint32Param(const char* trial_name,
const char* parameter_name,
uint32_t default_param) {
std::map<std::string, std::string> trial_params; std::map<std::string, std::string> trial_params;
bool result = bool result = base::GetFieldTrialParams(trial_name, &trial_params);
base::GetFieldTrialParams(kResourceLoadSchedulerTrial, &trial_params);
if (!result) if (!result)
return default_param; return default_param;
const auto& found = trial_params.find(name); const auto& found = trial_params.find(parameter_name);
if (found == trial_params.end()) if (found == trial_params.end())
return default_param; return default_param;
...@@ -75,16 +89,17 @@ uint32_t GetFieldTrialUint32Param(const char* name, uint32_t default_param) { ...@@ -75,16 +89,17 @@ uint32_t GetFieldTrialUint32Param(const char* name, uint32_t default_param) {
uint32_t GetOutstandingThrottledLimit(FetchContext* context) { uint32_t GetOutstandingThrottledLimit(FetchContext* context) {
DCHECK(context); DCHECK(context);
uint32_t main_frame_limit = uint32_t main_frame_limit = GetFieldTrialUint32Param(
GetFieldTrialUint32Param(kOutstandingLimitForBackgroundMainFrameName, kResourceLoadSchedulerTrial, kOutstandingLimitForBackgroundMainFrameName,
kOutstandingLimitForBackgroundFrameDefault); kOutstandingLimitForBackgroundFrameDefault);
if (context->IsMainFrame()) if (context->IsMainFrame())
return main_frame_limit; return main_frame_limit;
// We do not have a fixed default limit for sub-frames, but use the limit for // We do not have a fixed default limit for sub-frames, but use the limit for
// the main frame so that it works as how previous versions that haven't // the main frame so that it works as how previous versions that haven't
// consider sub-frames' specific limit work. // consider sub-frames' specific limit work.
return GetFieldTrialUint32Param(kOutstandingLimitForBackgroundSubFrameName, return GetFieldTrialUint32Param(kResourceLoadSchedulerTrial,
kOutstandingLimitForBackgroundSubFrameName,
main_frame_limit); main_frame_limit);
} }
...@@ -331,15 +346,26 @@ ResourceLoadScheduler::ResourceLoadScheduler(FetchContext* context) ...@@ -331,15 +346,26 @@ ResourceLoadScheduler::ResourceLoadScheduler(FetchContext* context)
traffic_monitor_ = std::make_unique<ResourceLoadScheduler::TrafficMonitor>( traffic_monitor_ = std::make_unique<ResourceLoadScheduler::TrafficMonitor>(
context_->IsMainFrame()); context_->IsMainFrame());
if (!RuntimeEnabledFeatures::ResourceLoadSchedulerEnabled()) if (!RuntimeEnabledFeatures::ResourceLoadSchedulerEnabled() &&
!Platform::Current()->IsRendererSideResourceSchedulerEnabled()) {
return; return;
}
auto* scheduler = context->GetFrameScheduler(); auto* scheduler = context->GetFrameScheduler();
if (!scheduler) if (!scheduler)
return; return;
if (Platform::Current()->IsRendererSideResourceSchedulerEnabled()) if (Platform::Current()->IsRendererSideResourceSchedulerEnabled()) {
policy_ = context->InitialLoadThrottlingPolicy(); policy_ = context->InitialLoadThrottlingPolicy();
outstanding_limit_ =
GetFieldTrialUint32Param(kRendererSideResourceScheduler,
kLimitForRendererSideResourceSchedulerName,
kLimitForRendererSideResourceScheduler);
tight_outstanding_limit_ = GetFieldTrialUint32Param(
kRendererSideResourceScheduler,
kTightLimitForRendererSideResourceSchedulerName,
kTightLimitForRendererSideResourceScheduler);
}
is_enabled_ = true; is_enabled_ = true;
scheduler->AddThrottlingObserver(WebFrameScheduler::ObserverType::kLoader, scheduler->AddThrottlingObserver(WebFrameScheduler::ObserverType::kLoader,
...@@ -617,6 +643,10 @@ void ResourceLoadScheduler::MaybeRun() { ...@@ -617,6 +643,10 @@ void ResourceLoadScheduler::MaybeRun() {
has_enough_running_requets) { has_enough_running_requets) {
break; break;
} }
if (IsThrottablePriority(pending_requests_.begin()->priority) &&
has_enough_running_requets) {
break;
}
ClientId id = pending_requests_.begin()->client_id; ClientId id = pending_requests_.begin()->client_id;
pending_requests_.erase(pending_requests_.begin()); pending_requests_.erase(pending_requests_.begin());
......
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