Commit 5bfdef58 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Reduce the write buffer for leveldb instances associated with Feed

I expect this to have a positive impact on Feed's memory usage.

Bug: 914597
Change-Id: I98b482fdbbf3f3a230902d7764cc32931c2c5784
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1749459
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686209}
parent 300d3fce
......@@ -24,8 +24,12 @@ namespace {
const char kContentDatabaseFolder[] = "content";
const size_t kDatabaseWriteBufferSizeBytes = 64 * 1024; // 64KB
const size_t kDatabaseWriteBufferSizeBytesForLowEndDevice = 32 * 1024; // 32KB
// Content writes vary a lot in size, loading full page will will have a couple
// dozen writes totaling a couple dozen KB, but there's a lot of variability.
// This should result in some batching while also keeping the memory impact very
// small.
const size_t kDatabaseWriteBufferSizeBytes = 8 * 1024; // 8KB
const size_t kDatabaseWriteBufferSizeBytesForLowEndDevice = 4 * 1024; // 4KB
leveldb::ReadOptions CreateReadOptions() {
leveldb::ReadOptions opts;
......
......@@ -22,8 +22,9 @@ namespace {
const char kJournalDatabaseFolder[] = "journal";
const size_t kDatabaseWriteBufferSizeBytes = 64 * 1024; // 64KB
const size_t kDatabaseWriteBufferSizeBytesForLowEndDevice = 32 * 1024; // 32KB
// Journal updates happen infrequently and are typically ~8KB. However there's
// also one tiny write during startup before more writes that 1KB should handle.
const size_t kDatabaseWriteBufferSizeBytes = 1 * 1024; // 1KB
void ReportLoadTimeHistogram(bool success, base::TimeTicks start_time) {
base::TimeDelta load_time = base::TimeTicks::Now() - start_time;
......@@ -69,9 +70,7 @@ bool FeedJournalDatabase::IsInitialized() const {
void FeedJournalDatabase::InitInternal() {
leveldb_env::Options options = leveldb_proto::CreateSimpleOptions();
options.write_buffer_size = base::SysInfo::IsLowEndDevice()
? kDatabaseWriteBufferSizeBytesForLowEndDevice
: kDatabaseWriteBufferSizeBytes;
options.write_buffer_size = kDatabaseWriteBufferSizeBytes;
storage_database_->Init(
options, base::BindOnce(&FeedJournalDatabase::OnDatabaseInitialized,
......
......@@ -36,10 +36,10 @@ int64_t ToDatabaseTime(base::Time time) {
// The folder where the data will be stored on disk.
const char kImageDatabaseFolder[] = "cached_image_fetcher_images";
// The amount of data to build up in memory before converting to a sorted on-
// disk file.
const size_t kDatabaseWriteBufferSizeBytes = 64 * 1024; // 64KB
const size_t kDatabaseWriteBufferSizeBytesForLowEndDevice = 32 * 1024; // 32KB
// Most writes are very small, <100 bytes. This should buffer a handful of them
// together, but not much more. This should allow a handful of them to be
// buffered together without causing a significant impact to memory.
const size_t kDatabaseWriteBufferSizeBytes = 1 * 1024; // 1KB
bool KeyMatcherFilter(std::string key, const std::string& other_key) {
return key.compare(other_key) == 0;
......@@ -80,11 +80,7 @@ ImageMetadataStoreLevelDB::~ImageMetadataStoreLevelDB() = default;
void ImageMetadataStoreLevelDB::Initialize(base::OnceClosure callback) {
leveldb_env::Options options = leveldb_proto::CreateSimpleOptions();
if (base::SysInfo::IsLowEndDevice()) {
options.write_buffer_size = kDatabaseWriteBufferSizeBytesForLowEndDevice;
} else {
options.write_buffer_size = kDatabaseWriteBufferSizeBytes;
}
options.write_buffer_size = kDatabaseWriteBufferSizeBytes;
database_->Init(
options,
......
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