Commit 8e3c4837 authored by Aditya Keerthi's avatar Aditya Keerthi Committed by Commit Bot

Introduce experiment to control font cache invalidation when purging renderers

The PurgeRendererMemoryWhenBackgrounded (formerly PurgeAndSuspend)
feature sends a critical memory pressure signal within 4 minutes
of a renderer being backgrounded. This feature was introduced to
improved memory usage.

Whenever a critical memory pressure signal occurs within a renderer,
the font cache is invalidated. This behavior always causes a full
layout to occur when the renderer is foregrounded, which would
negatively impact tab switch time. This idea is validated by benchmarks
collected in the associated bug.

The PurgeRendererMemoryWhenBackgrounded was shipped due to its positive
impact on memory usage, and font cache invalidation may play a role in
the gains. An experiment is being introduced to assess the impact of font
cache invalidation when purging. The experiment will only run on desktop
clients, to avoid changing behavior during low memory situations (signal
sent only on Android).

Bug: 939543
Change-Id: Ieb814417d70f2881d0d6ddd61d4a9dc142e0b666
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1532908Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Aditya Keerthi <adityakeerthi@google.com>
Cr-Commit-Position: refs/heads/master@{#645311}
parent 3e2cc183
...@@ -38,6 +38,11 @@ const base::Feature kFirstContentfulPaintPlusPlus{ ...@@ -38,6 +38,11 @@ const base::Feature kFirstContentfulPaintPlusPlus{
const base::Feature kFreezePurgeMemoryAllPagesFrozen{ const base::Feature kFreezePurgeMemoryAllPagesFrozen{
"FreezePurgeMemoryAllPagesFrozen", base::FEATURE_DISABLED_BY_DEFAULT}; "FreezePurgeMemoryAllPagesFrozen", base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether or not the font cache is invalidated when a critical memory
// pressure signal is sent.
const base::Feature kInvalidateFontCacheOnPurge{
"InvalidateFontCacheOnPurge", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables the experimental sweep-line algorithm for tracking "jank" from // Enables the experimental sweep-line algorithm for tracking "jank" from
// layout objects changing their visual location between animation frames. // layout objects changing their visual location between animation frames.
const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine", const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
......
...@@ -20,6 +20,7 @@ BLINK_COMMON_EXPORT extern const base::Feature kScriptStreaming; ...@@ -20,6 +20,7 @@ BLINK_COMMON_EXPORT extern const base::Feature kScriptStreaming;
BLINK_COMMON_EXPORT extern const base::Feature kFirstContentfulPaintPlusPlus; BLINK_COMMON_EXPORT extern const base::Feature kFirstContentfulPaintPlusPlus;
BLINK_COMMON_EXPORT extern const base::Feature kFreezePurgeMemoryAllPagesFrozen; BLINK_COMMON_EXPORT extern const base::Feature kFreezePurgeMemoryAllPagesFrozen;
BLINK_COMMON_EXPORT extern const base::Feature kImplicitRootScroller; BLINK_COMMON_EXPORT extern const base::Feature kImplicitRootScroller;
BLINK_COMMON_EXPORT extern const base::Feature kInvalidateFontCacheOnPurge;
BLINK_COMMON_EXPORT extern const base::Feature kJankTrackingSweepLine; BLINK_COMMON_EXPORT extern const base::Feature kJankTrackingSweepLine;
BLINK_COMMON_EXPORT extern const base::Feature kBlinkGenPropertyTrees; BLINK_COMMON_EXPORT extern const base::Feature kBlinkGenPropertyTrees;
BLINK_COMMON_EXPORT extern const base::Feature kLayoutNG; BLINK_COMMON_EXPORT extern const base::Feature kLayoutNG;
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#include "third_party/blink/renderer/platform/memory_pressure_listener.h" #include "third_party/blink/renderer/platform/memory_pressure_listener.h"
#include "base/feature_list.h"
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "third_party/blink/public/common/device_memory/approximated_device_memory.h" #include "third_party/blink/public/common/device_memory/approximated_device_memory.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/web/blink.h" #include "third_party/blink/public/web/blink.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/fonts/font_global_context.h" #include "third_party/blink/renderer/platform/fonts/font_global_context.h"
...@@ -126,7 +128,8 @@ void MemoryPressureListenerRegistry::OnPurgeMemory() { ...@@ -126,7 +128,8 @@ void MemoryPressureListenerRegistry::OnPurgeMemory() {
void MemoryPressureListenerRegistry::ClearMemory() { void MemoryPressureListenerRegistry::ClearMemory() {
// TODO(tasak|bashi): Make FontCache a MemoryPressureListener rather than // TODO(tasak|bashi): Make FontCache a MemoryPressureListener rather than
// clearing caches here. // clearing caches here.
FontGlobalContext::ClearMemory(); if (base::FeatureList::IsEnabled(features::kInvalidateFontCacheOnPurge))
FontGlobalContext::ClearMemory();
} }
void MemoryPressureListenerRegistry::ClearThreadSpecificMemory() { void MemoryPressureListenerRegistry::ClearThreadSpecificMemory() {
......
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