Commit 2a9a8201 authored by Daniel Murphy's avatar Daniel Murphy Committed by Commit Bot

[LevelDatabase] Switched file handle eviction to LRU (previously MRU)

During compaction each level is scanned at the same time sequentially.
This means there are files being read from each level at the same
time but each level is read in a sequential manner. Files are read
multiple times during scanning, first reading the end of the file then
contents inside.

Because of this behavior, most-recently-used eviction is the worst
because:
1. The multiple reads in a file (in a non-sequential manner) causes a
   ton of filesystem thrashing here.
2. Files are never re-read once they are finished being scanned in a
   level, so there is no reason to keep it the handle around.

Least-recently-used eviction more closely models the reading behavior
of a leveldb compaction, and this uses leveldb's sharded LRU cache.

File thrashing here is the suspected cause of the assigned bug, where
leveldb never opens. This is a speculative but educated guess fix.

Bug: 795369
Change-Id: I7f4965a2a93b05ae558688e58d220b0fcf549430
Reviewed-on: https://chromium-review.googlesource.com/905575
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarChris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537275}
parent 08916fed
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "leveldb/cache.h"
#include "leveldb/db.h" #include "leveldb/db.h"
#include "leveldb/env.h" #include "leveldb/env.h"
#include "leveldb/export.h" #include "leveldb/export.h"
...@@ -134,8 +135,6 @@ class LEVELDB_EXPORT RetrierProvider { ...@@ -134,8 +135,6 @@ class LEVELDB_EXPORT RetrierProvider {
MethodID method) const = 0; MethodID method) const = 0;
}; };
class Semaphore;
class LEVELDB_EXPORT ChromiumEnv : public leveldb::Env, class LEVELDB_EXPORT ChromiumEnv : public leveldb::Env,
public UMALogger, public UMALogger,
public RetrierProvider { public RetrierProvider {
...@@ -240,7 +239,7 @@ class LEVELDB_EXPORT ChromiumEnv : public leveldb::Env, ...@@ -240,7 +239,7 @@ class LEVELDB_EXPORT ChromiumEnv : public leveldb::Env,
using BGQueue = base::circular_deque<BGItem>; using BGQueue = base::circular_deque<BGItem>;
BGQueue queue_; BGQueue queue_;
LockTable locks_; LockTable locks_;
std::unique_ptr<Semaphore> file_semaphore_; std::unique_ptr<leveldb::Cache> file_cache_;
}; };
// Tracks databases open via OpenDatabase() method and exposes them to // Tracks databases open via OpenDatabase() method and exposes them to
......
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