Commit ea047159 authored by Benoît Lizé's avatar Benoît Lizé Committed by Commit Bot

blink/loader: Add a feature to keep ScriptResources alive.

ScriptLoader doesn't keep the ScriptResource instances for async scripts
alive, which artificially decreases memory cache hit rates (see the
attached bug for details and analysis).

Add a feature to tie the lifetime of ScriptResource to the one of
ScriptLoader.

Bug: 1043679
Change-Id: I3dc46d778f2c601fbde0daf18aa47b4b1ed2cc56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033260Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739342}
parent 5094a235
......@@ -24,6 +24,7 @@
#include "third_party/blink/renderer/core/script/script_loader.h"
#include "base/feature_list.h"
#include "third_party/blink/public/common/feature_policy/feature_policy.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy_feature.mojom-blink.h"
......@@ -71,6 +72,13 @@
namespace blink {
namespace {
const base::Feature kKeepScriptResourceAlive{"KeepScriptResourceAlive",
base::FEATURE_DISABLED_BY_DEFAULT};
}
ScriptLoader::ScriptLoader(ScriptElementBase* element,
bool parser_inserted,
bool already_started)
......@@ -973,7 +981,8 @@ void ScriptLoader::PendingScriptFinished(PendingScript* pending_script) {
// memory cache not be in the HTTPCache. So we keep |resource_keep_alive_| to
// keep the resource in the memory cache.
if (resource_keep_alive_ &&
!resource_keep_alive_->GetResponse().IsSignedExchangeInnerResponse()) {
!resource_keep_alive_->GetResponse().IsSignedExchangeInnerResponse() &&
!base::FeatureList::IsEnabled(kKeepScriptResourceAlive)) {
resource_keep_alive_ = nullptr;
}
......
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