Commit a6ed7cd5 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Tweak leveldb options to reduce memory use

See https://groups.google.com/a/chromium.org/d/msg/storage-dev/7LPVIl2dx_M/-rQaqjCTDAAJ
for some data and discussion.

Bug: 793109
Change-Id: I342af261c094fbf26a934737b56960fb2c244011
Reviewed-on: https://chromium-review.googlesource.com/1026164Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553741}
parent 38a801fc
......@@ -40,8 +40,11 @@ bool DownloadStore::IsInitialized() {
void DownloadStore::Initialize(InitCallback callback) {
DCHECK(!IsInitialized());
db_->Init(kDatabaseClientName, database_dir_,
leveldb_proto::CreateSimpleOptions(),
// These options reduce memory consumption.
leveldb_env::Options options = leveldb_proto::CreateSimpleOptions();
options.reuse_logs = false;
options.write_buffer_size = 64 << 10; // 64 KiB
db_->Init(kDatabaseClientName, database_dir_, options,
base::BindOnce(&DownloadStore::OnDatabaseInited,
weak_factory_.GetWeakPtr(), std::move(callback)));
}
......
......@@ -26,8 +26,7 @@ const char kImageDatabaseUMAClientName[] = "NTPSnippetImages";
const char kSnippetDatabaseFolder[] = "snippets";
const char kImageDatabaseFolder[] = "images";
const size_t kDatabaseWriteBufferSizeBytes = 512 << 10;
const size_t kDatabaseWriteBufferSizeBytesForLowEndDevice = 128 << 10;
const size_t kDatabaseWriteBufferSizeBytes = 128 << 10;
} // namespace
namespace ntp_snippets {
......@@ -59,11 +58,9 @@ RemoteSuggestionsDatabase::RemoteSuggestionsDatabase(
weak_ptr_factory_(this) {
base::FilePath snippet_dir = database_dir.AppendASCII(kSnippetDatabaseFolder);
leveldb_env::Options options = leveldb_proto::CreateSimpleOptions();
if (base::SysInfo::IsLowEndDevice()) {
options.write_buffer_size = kDatabaseWriteBufferSizeBytesForLowEndDevice;
} else {
options.write_buffer_size = kDatabaseWriteBufferSizeBytes;
}
options.reuse_logs = false; // Consumes less RAM over time.
options.write_buffer_size = kDatabaseWriteBufferSizeBytes;
database_->Init(kDatabaseUMAClientName, snippet_dir, options,
base::Bind(&RemoteSuggestionsDatabase::OnDatabaseInited,
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