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

Side by Side Diff: sync/syncable/on_disk_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 unified diff | Download patch
« no previous file with comments | « sync/syncable/directory_backing_store.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/syncable/on_disk_directory_backing_store.h" 5 #include "sync/syncable/on_disk_directory_backing_store.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "sync/syncable/syncable-inl.h" 10 #include "sync/syncable/syncable-inl.h"
(...skipping 11 matching lines...) Expand all
22 }; 22 };
23 23
24 } // namespace 24 } // namespace
25 25
26 OnDiskDirectoryBackingStore::OnDiskDirectoryBackingStore( 26 OnDiskDirectoryBackingStore::OnDiskDirectoryBackingStore(
27 const std::string& dir_name, const base::FilePath& backing_filepath) 27 const std::string& dir_name, const base::FilePath& backing_filepath)
28 : DirectoryBackingStore(dir_name), 28 : DirectoryBackingStore(dir_name),
29 allow_failure_for_test_(false), 29 allow_failure_for_test_(false),
30 backing_filepath_(backing_filepath) { 30 backing_filepath_(backing_filepath) {
31 db_->set_exclusive_locking(); 31 db_->set_exclusive_locking();
32 db_->set_page_size(4096); 32 if (IsSyncBackingDatabase32KEnabled()) {
33 db_->set_page_size(32768);
34 } else {
35 db_->set_page_size(4096);
36 }
33 } 37 }
34 38
35 OnDiskDirectoryBackingStore::~OnDiskDirectoryBackingStore() { } 39 OnDiskDirectoryBackingStore::~OnDiskDirectoryBackingStore() { }
36 40
37 DirOpenResult OnDiskDirectoryBackingStore::TryLoad( 41 DirOpenResult OnDiskDirectoryBackingStore::TryLoad(
38 Directory::MetahandlesMap* handles_map, 42 Directory::MetahandlesMap* handles_map,
39 JournalIndex* delete_journals, 43 JournalIndex* delete_journals,
40 Directory::KernelLoadInfo* kernel_load_info) { 44 Directory::KernelLoadInfo* kernel_load_info) {
41 DCHECK(CalledOnValidThread()); 45 DCHECK(CalledOnValidThread());
42 if (!db_->is_open()) { 46 if (!db_->is_open()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 82
79 // The fallback: delete the current database and return a fresh one. We can 83 // The fallback: delete the current database and return a fresh one. We can
80 // fetch the user's data from the cloud. 84 // fetch the user's data from the cloud.
81 STLDeleteValues(handles_map); 85 STLDeleteValues(handles_map);
82 STLDeleteElements(delete_journals); 86 STLDeleteElements(delete_journals);
83 db_.reset(new sql::Connection); 87 db_.reset(new sql::Connection);
84 // TODO: Manually propagating the default database settings is 88 // TODO: Manually propagating the default database settings is
85 // brittle. Either have a helper to set these up (or generate a new 89 // brittle. Either have a helper to set these up (or generate a new
86 // connection), or add something like Reset() to sql::Connection. 90 // connection), or add something like Reset() to sql::Connection.
87 db_->set_exclusive_locking(); 91 db_->set_exclusive_locking();
88 db_->set_page_size(4096); 92 if (IsSyncBackingDatabase32KEnabled()) {
stanisc 2015/03/17 16:02:41 This code fragment is repeated 4 times. Consider m
Gang Wu 2015/03/17 23:52:46 Done.
93 db_->set_page_size(32768);
94 } else {
95 db_->set_page_size(4096);
96 }
89 db_->set_histogram_tag("SyncDirectory"); 97 db_->set_histogram_tag("SyncDirectory");
90 base::DeleteFile(backing_filepath_, false); 98 base::DeleteFile(backing_filepath_, false);
91 99
92 result = TryLoad(handles_map, delete_journals, kernel_load_info); 100 result = TryLoad(handles_map, delete_journals, kernel_load_info);
93 if (result == OPENED) { 101 if (result == OPENED) {
94 UMA_HISTOGRAM_ENUMERATION( 102 UMA_HISTOGRAM_ENUMERATION(
95 "Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, RESULT_COUNT); 103 "Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, RESULT_COUNT);
96 } else { 104 } else {
97 UMA_HISTOGRAM_ENUMERATION( 105 UMA_HISTOGRAM_ENUMERATION(
98 "Sync.DirectoryOpenResult", SECOND_TRY_FAILURE, RESULT_COUNT); 106 "Sync.DirectoryOpenResult", SECOND_TRY_FAILURE, RESULT_COUNT);
99 } 107 }
100 108
101 return result; 109 return result;
102 } 110 }
103 111
104 void OnDiskDirectoryBackingStore::ReportFirstTryOpenFailure() { 112 void OnDiskDirectoryBackingStore::ReportFirstTryOpenFailure() {
105 // In debug builds, the last thing we want is to silently clear the database. 113 // In debug builds, the last thing we want is to silently clear the database.
106 // It's full of evidence that might help us determine what went wrong. It 114 // It's full of evidence that might help us determine what went wrong. It
107 // might be sqlite's fault, but it could also be a bug in sync. We crash 115 // might be sqlite's fault, but it could also be a bug in sync. We crash
108 // immediately so a developer can investigate. 116 // immediately so a developer can investigate.
109 // 117 //
110 // Developers: If you're not interested in debugging this right now, just move 118 // Developers: If you're not interested in debugging this right now, just move
111 // aside the 'Sync Data' directory in your profile. This is similar to what 119 // aside the 'Sync Data' directory in your profile. This is similar to what
112 // the code would do if this DCHECK were disabled. 120 // the code would do if this DCHECK were disabled.
113 NOTREACHED() << "Crashing to preserve corrupt sync database"; 121 NOTREACHED() << "Crashing to preserve corrupt sync database";
114 } 122 }
115 123
116 } // namespace syncable 124 } // namespace syncable
117 } // namespace syncer 125 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory_backing_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698