Commit 399262c9 authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

SimpleCache: disable size heuristic for code cache eviction

Experiment showed not using the heuristic prevents accumulating too many
files and performs well

Bug: 1075545, 1073514
Change-Id: I7cb374e7f3283ea809f1bf7635f1ade91009742b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255651Reviewed-by: default avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Maksim Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781309}
parent 568b29a2
...@@ -58,11 +58,6 @@ static const int kEstimatedEntryOverhead = 512; ...@@ -58,11 +58,6 @@ static const int kEstimatedEntryOverhead = 512;
namespace disk_cache { namespace disk_cache {
const base::Feature
SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache{
"SimpleCacheDisableEvictionSizeHeuristicForCodeCache",
base::FEATURE_DISABLED_BY_DEFAULT};
EntryMetadata::EntryMetadata() EntryMetadata::EntryMetadata()
: last_used_time_seconds_since_epoch_(0), : last_used_time_seconds_since_epoch_(0),
entry_size_256b_chunks_(0), entry_size_256b_chunks_(0),
...@@ -422,11 +417,7 @@ void SimpleIndex::StartEvictionIfNeeded() { ...@@ -422,11 +417,7 @@ void SimpleIndex::StartEvictionIfNeeded() {
MEMORY_KB, "Eviction.MaxCacheSizeOnStart2", cache_type_, MEMORY_KB, "Eviction.MaxCacheSizeOnStart2", cache_type_,
static_cast<base::HistogramBase::Sample>(max_size_ / kBytesInKb)); static_cast<base::HistogramBase::Sample>(max_size_ / kBytesInKb));
bool use_size_heuristic = true; bool use_size_heuristic = (cache_type_ != net::GENERATED_BYTE_CODE_CACHE);
if (cache_type_ == net::GENERATED_BYTE_CODE_CACHE) {
use_size_heuristic = !base::FeatureList::IsEnabled(
kSimpleCacheDisableEvictionSizeHeuristicForCodeCache);
}
// Flatten for sorting. // Flatten for sorting.
std::vector<std::pair<uint64_t, const EntrySet::value_type*>> entries; std::vector<std::pair<uint64_t, const EntrySet::value_type*>> entries;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <vector> #include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "base/feature_list.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
...@@ -312,9 +311,6 @@ class NET_EXPORT_PRIVATE SimpleIndex ...@@ -312,9 +311,6 @@ class NET_EXPORT_PRIVATE SimpleIndex
// background we can write the index much more frequently, to insure fresh // background we can write the index much more frequently, to insure fresh
// index on next startup. // index on next startup.
bool app_on_background_ = false; bool app_on_background_ = false;
static const base::Feature
kSimpleCacheDisableEvictionSizeHeuristicForCodeCache;
}; };
} // namespace disk_cache } // namespace disk_cache
......
...@@ -642,10 +642,6 @@ TEST_F(SimpleIndexTest, EvictBySize) { ...@@ -642,10 +642,6 @@ TEST_F(SimpleIndexTest, EvictBySize) {
} }
TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) { TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache}, {});
base::Time now(base::Time::Now()); base::Time now(base::Time::Now());
index()->SetMaxSize(50000); index()->SetMaxSize(50000);
InsertIntoIndexFileReturn(hashes_.at<1>(), now - base::TimeDelta::FromDays(2), InsertIntoIndexFileReturn(hashes_.at<1>(), now - base::TimeDelta::FromDays(2),
...@@ -675,40 +671,6 @@ TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) { ...@@ -675,40 +671,6 @@ TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) {
ASSERT_EQ(2u, last_doom_entry_hashes().size()); ASSERT_EQ(2u, last_doom_entry_hashes().size());
} }
TEST_F(SimpleIndexCodeCacheTest, EnableEvictBySize) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{}, {SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache});
base::Time now(base::Time::Now());
index()->SetMaxSize(50000);
InsertIntoIndexFileReturn(hashes_.at<1>(), now - base::TimeDelta::FromDays(2),
475u);
InsertIntoIndexFileReturn(hashes_.at<2>(), now - base::TimeDelta::FromDays(1),
40000u);
ReturnIndexFile();
WaitForTimeChange();
index()->Insert(hashes_.at<3>());
// Confirm index is as expected: No eviction, everything there.
EXPECT_EQ(3, index()->GetEntryCount());
EXPECT_EQ(0, doom_entries_calls());
EXPECT_TRUE(index()->Has(hashes_.at<1>()));
EXPECT_TRUE(index()->Has(hashes_.at<2>()));
EXPECT_TRUE(index()->Has(hashes_.at<3>()));
// Trigger an eviction, and make sure the right things are tossed.
// This has size-weighting enabled, so it end sup kickicking out entry
// 2, which is biggest, and is enough, even though <1> is older.
index()->UpdateEntrySize(hashes_.at<3>(), 40000u);
EXPECT_EQ(1, doom_entries_calls());
EXPECT_EQ(2, index()->GetEntryCount());
EXPECT_TRUE(index()->Has(hashes_.at<1>()));
EXPECT_FALSE(index()->Has(hashes_.at<2>()));
EXPECT_TRUE(index()->Has(hashes_.at<3>()));
ASSERT_EQ(1u, last_doom_entry_hashes().size());
}
// Same as test above, but using much older entries to make sure that small // Same as test above, but using much older entries to make sure that small
// things eventually get evictied. // things eventually get evictied.
TEST_F(SimpleIndexTest, EvictBySize2) { TEST_F(SimpleIndexTest, EvictBySize2) {
......
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