Commit 917c14ab authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add an experiment for ShapeRuns cache size

Plumb the code to get an experiment for studying the best
ShapeRuns cache size.

The entries of these cache are part of the top allocations
in chrome browser process (based on memlog reports).

Bug: 1050793
Change-Id: I51ca6aebfe6c8ae3881eb3c03a56b4d472216ec7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051976
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741161}
parent 417c1c1d
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop_current.h" #include "base/message_loop/message_loop_current.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/stl_util.h" #include "base/stl_util.h"
...@@ -65,6 +66,13 @@ namespace gfx { ...@@ -65,6 +66,13 @@ namespace gfx {
namespace { namespace {
// Experiment to determine best cache size (see https://crbug.com/1050793).
const base::Feature kShapeRunCacheSize = {"ShapeRunCacheSize",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::FeatureParam<int> kShapeRunCacheSizeParam = {&kShapeRunCacheSize,
"CacheSize", 10000};
// Text length limit. Longer strings are slow and not fully tested. // Text length limit. Longer strings are slow and not fully tested.
const size_t kMaxTextLength = 10000; const size_t kMaxTextLength = 10000;
...@@ -1241,13 +1249,12 @@ struct ShapeRunWithFontInput { ...@@ -1241,13 +1249,12 @@ struct ShapeRunWithFontInput {
// An MRU cache of the results from calling ShapeRunWithFont. Use the same // An MRU cache of the results from calling ShapeRunWithFont. Use the same
// maximum cache size as is used in blink::ShapeCache. // maximum cache size as is used in blink::ShapeCache.
constexpr int kShapeRunCacheSize = 10000;
using ShapeRunCacheBase = base::HashingMRUCache<ShapeRunWithFontInput, using ShapeRunCacheBase = base::HashingMRUCache<ShapeRunWithFontInput,
TextRunHarfBuzz::ShapeOutput, TextRunHarfBuzz::ShapeOutput,
ShapeRunWithFontInput::Hash>; ShapeRunWithFontInput::Hash>;
class ShapeRunCache : public ShapeRunCacheBase { class ShapeRunCache : public ShapeRunCacheBase {
public: public:
ShapeRunCache() : ShapeRunCacheBase(kShapeRunCacheSize) {} ShapeRunCache() : ShapeRunCacheBase(kShapeRunCacheSizeParam.Get()) {}
}; };
void ShapeRunWithFont(const ShapeRunWithFontInput& in, void ShapeRunWithFont(const ShapeRunWithFontInput& in,
......
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