Commit f75c1911 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[blink] Add flag for small script streaming

Add a flag to enable streaming small (<30kB) scripts. With the improved
streaming capabilities and reduced background parsing costs, it may be
beneficial to stream all scripts, not just the large ones.

Bug: 865098
Change-Id: I211bbbc8491050041ebcbb4e9d6019263fcfd4eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632430
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664205}
parent 3b0e3cff
......@@ -36,6 +36,10 @@ const base::Feature kEnableGpuRasterizationViewportRestriction{
const base::Feature kScriptStreaming{"ScriptStreaming",
base::FEATURE_ENABLED_BY_DEFAULT};
// Allow streaming small (<30kB) scripts.
const base::Feature kSmallScriptStreaming{"SmallScriptStreaming",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables user level memory pressure signal generation on Android.
const base::Feature kUserLevelMemoryPressureSignal{
"UserLevelMemoryPressureSignal", base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -19,6 +19,7 @@ BLINK_COMMON_EXPORT extern const base::Feature
BLINK_COMMON_EXPORT extern const base::Feature
kEnableGpuRasterizationViewportRestriction;
BLINK_COMMON_EXPORT extern const base::Feature kScriptStreaming;
BLINK_COMMON_EXPORT extern const base::Feature kSmallScriptStreaming;
BLINK_COMMON_EXPORT extern const base::Feature kUserLevelMemoryPressureSignal;
BLINK_COMMON_EXPORT extern const base::Feature kFirstContentfulPaintPlusPlus;
BLINK_COMMON_EXPORT extern const base::Feature kFreezePurgeMemoryAllPagesFrozen;
......
......@@ -11,6 +11,7 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_restrictions.h"
#include "mojo/public/cpp/system/wait.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_code_cache.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h"
......@@ -24,7 +25,6 @@
#include "third_party/blink/renderer/platform/loader/fetch/cached_metadata.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource.h"
#include "third_party/blink/renderer/platform/loader/fetch/response_body_loader.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/worker_pool.h"
......@@ -354,8 +354,12 @@ void RunScriptStreamingTask(
} // namespace
bool ScriptStreamer::HasEnoughDataForStreaming(size_t resource_buffer_size) {
// Only stream larger scripts.
return resource_buffer_size >= small_script_threshold_;
if (base::FeatureList::IsEnabled(features::kSmallScriptStreaming)) {
return resource_buffer_size >= kMaximumLengthOfBOM;
} else {
// Only stream larger scripts.
return resource_buffer_size >= small_script_threshold_;
}
}
// Try to start streaming the script from the given datapipe, taking ownership
......
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