Commit b727ed00 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Control the HTML parser yield interval via field trial.

The parser currently yields every 500ms unless it encounters a script tag. We will experiment
with different values and observe the impact.

https://goo.gl/zwQWyW

Change-Id: I1dcec74fb41e438393e505323707c00d76b49d15
Reviewed-on: https://chromium-review.googlesource.com/1148172
Commit-Queue: Fergal Daly <fergal@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582554}
parent e39a9a26
......@@ -25,6 +25,8 @@
#include "third_party/blink/renderer/core/html/parser/html_parser_scheduler.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_thread.h"
#include "third_party/blink/renderer/core/dom/document.h"
......@@ -35,6 +37,10 @@
namespace blink {
const base::Feature kHTMLParsingYieldTime {
"HTMLParsingYieldTime", base::FEATURE_DISABLED_BY_DEFAULT
};
PumpSession::PumpSession(unsigned& nesting_level)
: NestingLevelIncrementer(nesting_level) {}
......@@ -55,12 +61,18 @@ void SpeculationsPumpSession::AddedElementTokens(size_t count) {
processed_element_tokens_ += count;
}
const double kDefaultParserTimeLimit = 0.5;
HTMLParserScheduler::HTMLParserScheduler(
HTMLDocumentParser* parser,
scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner)
: parser_(parser),
loading_task_runner_(std::move(loading_task_runner)),
is_paused_with_active_timer_(false) {}
is_paused_with_active_timer_(false),
parser_time_limit_(
base::GetFieldTrialParamByFeatureAsDouble(kHTMLParsingYieldTime,
"limit",
kDefaultParserTimeLimit)) {}
HTMLParserScheduler::~HTMLParserScheduler() = default;
......@@ -111,8 +123,7 @@ inline bool HTMLParserScheduler::ShouldYield(
->ShouldYieldForHighPriorityWork())
return true;
const double kParserTimeLimit = 0.5;
if (session.ElapsedTime() > kParserTimeLimit)
if (session.ElapsedTime() > parser_time_limit_)
return true;
// Yield if a lot of DOM work has been done in this session and a script tag
......
......@@ -105,6 +105,7 @@ class HTMLParserScheduler final
TaskHandle cancellable_continue_parse_task_handle_;
bool is_paused_with_active_timer_;
const double parser_time_limit_;
DISALLOW_COPY_AND_ASSIGN(HTMLParserScheduler);
};
......
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