Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: sync/syncable/directory_backing_store.cc

Issue 1016563005: Increase page size for SyncData DB from 4K to maximum supported 32K (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/syncable/directory_backing_store.h ('k') | sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory_backing_store.cc
diff --git a/sync/syncable/directory_backing_store.cc b/sync/syncable/directory_backing_store.cc
index 9d18a2dbb3bcc5eb27bc430a0dde410c13187099..772ced41e222b032b9bf55a73af23bf73d8064ca 100644
--- a/sync/syncable/directory_backing_store.cc
+++ b/sync/syncable/directory_backing_store.cc
@@ -10,6 +10,7 @@
#include "base/base64.h"
#include "base/logging.h"
+#include "base/metrics/field_trial.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
@@ -175,8 +176,9 @@ DirectoryBackingStore::DirectoryBackingStore(const string& dir_name)
dir_name_(dir_name),
needs_column_refresh_(false) {
db_->set_histogram_tag("SyncDirectory");
- db_->set_page_size(4096);
db_->set_cache_size(32);
+ databasePageSize_ = IsSyncBackingDatabase32KEnabled() ? 32768 : 4096;
+ db_->set_page_size(databasePageSize_);
}
DirectoryBackingStore::DirectoryBackingStore(const string& dir_name,
@@ -308,6 +310,11 @@ bool DirectoryBackingStore::SaveChanges(
}
bool DirectoryBackingStore::InitializeTables() {
+ int page_size = 0;
+ if (IsSyncBackingDatabase32KEnabled() && GetDatabasePageSize(&page_size) &&
+ page_size == 4096) {
+ IncreasePageSizeTo32K();
+ }
sql::Transaction transaction(db_.get());
if (!transaction.Begin())
return false;
@@ -1592,5 +1599,35 @@ void DirectoryBackingStore::PrepareSaveEntryStatement(
base::StringPrintf(query.c_str(), "metas").c_str()));
}
+// Get page size for the database.
+bool DirectoryBackingStore::GetDatabasePageSize(int* page_size) {
+ sql::Statement s(db_->GetUniqueStatement("PRAGMA page_size"));
+ if (!s.Step())
+ return false;
+ *page_size = s.ColumnInt(0);
+ return true;
+}
+
+bool DirectoryBackingStore::IsSyncBackingDatabase32KEnabled() {
+ const std::string group_name =
+ base::FieldTrialList::FindFullName("SyncBackingDatabase32K");
+ return group_name == "Enabled";
+}
+
+bool DirectoryBackingStore::IncreasePageSizeTo32K() {
+ if (!db_->Execute("PRAGMA page_size=32768;") || !Vacuum()) {
+ return false;
+ }
+ return true;
+}
+
+bool DirectoryBackingStore::Vacuum() {
+ DCHECK_EQ(db_->transaction_nesting(), 0);
+ if (!db_->Execute("VACUUM;")) {
+ return false;
+ }
+ return true;
+}
+
} // namespace syncable
} // namespace syncer
« no previous file with comments | « sync/syncable/directory_backing_store.h ('k') | sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698