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 @@
#include "content/common/resource_messages.h"
#include "content/public/browser/resource_request_info.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/load_flags.h"
#include "net/base/request_priority.h"
......@@ -423,7 +424,15 @@ class ResourceScheduler::Client {
resource_scheduler->throttle_delayable_.GetMaxDelayableRequests(
network_quality_estimator)),
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() {}
......@@ -488,6 +497,14 @@ class ResourceScheduler::Client {
void OnNavigate() {
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;
max_delayable_requests_ =
resource_scheduler_->throttle_delayable_.GetMaxDelayableRequests(
......@@ -960,6 +977,8 @@ class ResourceScheduler::Client {
bool is_loaded_;
// Tracks if the main HTML parser has reached the body which marks the end of
// layout-blocking resources.
// This is disabled and the is always true when kRendererSideResourceScheduler
// is enabled.
bool has_html_body_;
bool using_spdy_proxy_;
RequestQueue pending_requests_;
......
......@@ -38,6 +38,19 @@ constexpr base::HistogramBase::Sample kMaximumReportSize1G =
// Bucket count for metrics.
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,
// or on throttled state vs on not-throttled state.
// Used to report histograms. Do not reorder or insert new items.
......@@ -54,14 +67,15 @@ base::HistogramBase::Sample ToSample(ReportCircumstance 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;
bool result =
base::GetFieldTrialParams(kResourceLoadSchedulerTrial, &trial_params);
bool result = base::GetFieldTrialParams(trial_name, &trial_params);
if (!result)
return default_param;
const auto& found = trial_params.find(name);
const auto& found = trial_params.find(parameter_name);
if (found == trial_params.end())
return default_param;
......@@ -75,16 +89,17 @@ uint32_t GetFieldTrialUint32Param(const char* name, uint32_t default_param) {
uint32_t GetOutstandingThrottledLimit(FetchContext* context) {
DCHECK(context);
uint32_t main_frame_limit =
GetFieldTrialUint32Param(kOutstandingLimitForBackgroundMainFrameName,
kOutstandingLimitForBackgroundFrameDefault);
uint32_t main_frame_limit = GetFieldTrialUint32Param(
kResourceLoadSchedulerTrial, kOutstandingLimitForBackgroundMainFrameName,
kOutstandingLimitForBackgroundFrameDefault);
if (context->IsMainFrame())
return main_frame_limit;
// 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
// consider sub-frames' specific limit work.
return GetFieldTrialUint32Param(kOutstandingLimitForBackgroundSubFrameName,
return GetFieldTrialUint32Param(kResourceLoadSchedulerTrial,
kOutstandingLimitForBackgroundSubFrameName,
main_frame_limit);
}
......@@ -331,15 +346,26 @@ ResourceLoadScheduler::ResourceLoadScheduler(FetchContext* context)
traffic_monitor_ = std::make_unique<ResourceLoadScheduler::TrafficMonitor>(
context_->IsMainFrame());
if (!RuntimeEnabledFeatures::ResourceLoadSchedulerEnabled())
if (!RuntimeEnabledFeatures::ResourceLoadSchedulerEnabled() &&
!Platform::Current()->IsRendererSideResourceSchedulerEnabled()) {
return;
}
auto* scheduler = context->GetFrameScheduler();
if (!scheduler)
return;
if (Platform::Current()->IsRendererSideResourceSchedulerEnabled())
if (Platform::Current()->IsRendererSideResourceSchedulerEnabled()) {
policy_ = context->InitialLoadThrottlingPolicy();
outstanding_limit_ =
GetFieldTrialUint32Param(kRendererSideResourceScheduler,
kLimitForRendererSideResourceSchedulerName,
kLimitForRendererSideResourceScheduler);
tight_outstanding_limit_ = GetFieldTrialUint32Param(
kRendererSideResourceScheduler,
kTightLimitForRendererSideResourceSchedulerName,
kTightLimitForRendererSideResourceScheduler);
}
is_enabled_ = true;
scheduler->AddThrottlingObserver(WebFrameScheduler::ObserverType::kLoader,
......@@ -617,6 +643,10 @@ void ResourceLoadScheduler::MaybeRun() {
has_enough_running_requets) {
break;
}
if (IsThrottablePriority(pending_requests_.begin()->priority) &&
has_enough_running_requets) {
break;
}
ClientId id = pending_requests_.begin()->client_id;
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