Commit 69b699da authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

[Feed] Disable read cache for LevelDB usages

This is an attempt to reduce the memory footprint LevelDB has on the
Feed experiment. This will reduce performance, but also reduce the
impact Feed has on memory usage. We want to prioritize memory here.

Bug: 914597
Change-Id: I42e36b126606cadd5212dab620aef867acdc8f76
Reviewed-on: https://chromium-review.googlesource.com/c/1387948
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629827}
parent 2f4c7133
......@@ -36,6 +36,12 @@ const char kContentDatabaseFolder[] = "content";
const size_t kDatabaseWriteBufferSizeBytes = 64 * 1024; // 64KB
const size_t kDatabaseWriteBufferSizeBytesForLowEndDevice = 32 * 1024; // 32KB
leveldb::ReadOptions CreateReadOptions() {
leveldb::ReadOptions opts;
opts.fill_cache = false;
return opts;
}
bool DatabaseKeyFilter(const std::unordered_set<std::string>& key_set,
const std::string& key) {
return key_set.find(key) != key_set.end();
......@@ -97,6 +103,7 @@ void FeedContentDatabase::LoadContent(const std::vector<std::string>& keys,
storage_database_->LoadEntriesWithFilter(
base::BindRepeating(&DatabaseKeyFilter, std::move(key_set)),
CreateReadOptions(), /* target_prefix */ "",
base::BindOnce(&FeedContentDatabase::OnLoadEntriesForLoadContent,
weak_ptr_factory_.GetWeakPtr(), base::TimeTicks::Now(),
std::move(callback)));
......@@ -108,6 +115,7 @@ void FeedContentDatabase::LoadContentByPrefix(const std::string& prefix,
storage_database_->LoadEntriesWithFilter(
base::BindRepeating(&DatabasePrefixFilter, std::move(prefix)),
CreateReadOptions(), /* target_prefix */ "",
base::BindOnce(&FeedContentDatabase::OnLoadEntriesForLoadContent,
weak_ptr_factory_.GetWeakPtr(), base::TimeTicks::Now(),
std::move(callback)));
......
......@@ -23,6 +23,12 @@ namespace image_fetcher {
namespace {
leveldb::ReadOptions CreateReadOptions() {
leveldb::ReadOptions opts;
opts.fill_cache = false;
return opts;
}
int64_t ToDatabaseTime(base::Time time) {
return time.since_origin().InMicroseconds();
}
......@@ -143,7 +149,8 @@ void ImageMetadataStoreLevelDB::UpdateImageMetadata(const std::string& key) {
}
database_->LoadEntriesWithFilter(
base::BindRepeating(&KeyMatcherFilter, key),
base::BindRepeating(&KeyMatcherFilter, key), CreateReadOptions(),
/* target_prefix */ "",
base::BindOnce(&ImageMetadataStoreLevelDB::UpdateImageMetadataImpl,
weak_ptr_factory_.GetWeakPtr()));
}
......
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