Commit de701abe authored by cmumford's avatar cmumford Committed by Commit bot

IndexedDB: Reusing leveldb logs when opening database

This change activates a new open mode in leveldb which reuses logs & manifest
to reduce time to open database.

This affects only Indexed DB databases, not other leveldb's opened elsewhere.

BUG=402980,395799

Review URL: https://codereview.chromium.org/803603004

Cr-Commit-Position: refs/heads/master@{#308493}
parent a0742f1d
......@@ -103,6 +103,7 @@ static leveldb::Status OpenDB(
options.create_if_missing = true;
options.paranoid_checks = true;
options.filter_policy = filter_policy->get();
options.reuse_logs = true;
options.compression = leveldb::kSnappyCompression;
// For info about the troubles we've run into with this parameter, see:
......
......@@ -358,6 +358,8 @@ const char* MethodIDToString(MethodID method) {
return "NewRandomAccessFile";
case kNewWritableFile:
return "NewWritableFile";
case kNewAppendableFile:
return "NewAppendableFile";
case kDeleteFile:
return "DeleteFile";
case kCreateDir:
......@@ -904,6 +906,22 @@ Status ChromiumEnv::NewWritableFile(const std::string& fname,
}
}
Status ChromiumEnv::NewAppendableFile(const std::string& fname,
leveldb::WritableFile** result) {
*result = NULL;
FilePath path = FilePath::FromUTF8Unsafe(fname);
scoped_ptr<base::File> f(new base::File(
path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND));
if (!f->IsValid()) {
RecordErrorAt(kNewAppendableFile);
return MakeIOError(fname, "Unable to create appendable file",
kNewAppendableFile, f->error_details());
}
*result =
new ChromiumWritableFile(fname, f.release(), this, this, make_backup_);
return Status::OK();
}
uint64_t ChromiumEnv::NowMicros() {
return base::TimeTicks::Now().ToInternalValue();
}
......
......@@ -19,6 +19,8 @@
namespace leveldb_env {
// These entries map to values in tools/metrics/histograms/histograms.xml. New
// values should be appended at the end.
enum MethodID {
kSequentialFileRead,
kSequentialFileSkip,
......@@ -41,6 +43,7 @@ enum MethodID {
kNewLogger,
kSyncParent,
kGetChildren,
kNewAppendableFile,
kNumEntries
};
......@@ -129,6 +132,8 @@ class ChromiumEnv : public leveldb::Env,
leveldb::RandomAccessFile** result);
virtual leveldb::Status NewWritableFile(const std::string& fname,
leveldb::WritableFile** result);
virtual leveldb::Status NewAppendableFile(const std::string& fname,
leveldb::WritableFile** result);
virtual leveldb::Status NewLogger(const std::string& fname,
leveldb::Logger** result);
......
......@@ -49274,6 +49274,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="18" label="NewLogger"/>
<int value="19" label="SyncParent"/>
<int value="20" label="GetChildren"/>
<int value="21" label="NewAppendableFile"/>
</enum>
<enum name="LevelDBPrefStoreErrorCodes" type="int">
......@@ -58942,6 +58943,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<suffix name="GetChildren" label="ChromiumEnv::GetChildren"/>
<suffix name="GetFileSize" label="ChromiumEnv::GetFileSize"/>
<suffix name="LockFile" label="ChromiumEnv::LockFile"/>
<suffix name="NewAppendableFile" label="ChromiumEnv::NewAppendableFile"/>
<suffix name="NewRandomAccessFile" label="ChromiumEnv::NewRandomAccessFile"/>
<suffix name="RandomAccessFileRead" label="ChromiumRandomAccessFile::Read"/>
<suffix name="RenameFile" label="ChromiumEnv::RenameFile"/>
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