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

Side by Side Diff: chrome/browser/history/history_database.cc

Issue 8379009: Add a field trial for using lower sqlite cache sizes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/history/history_database.h" 5 #include "chrome/browser/history/history_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
17 #include "chrome/browser/history/history_field_trial.h"
17 #include "sql/transaction.h" 18 #include "sql/transaction.h"
18 19
19 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
20 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
21 #endif 22 #endif
22 23
23 namespace history { 24 namespace history {
24 25
25 namespace { 26 namespace {
26 27
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const FilePath& bookmarks_path) { 72 const FilePath& bookmarks_path) {
72 // Set the exceptional sqlite error handler. 73 // Set the exceptional sqlite error handler.
73 db_.set_error_delegate(GetErrorHandlerForHistoryDb()); 74 db_.set_error_delegate(GetErrorHandlerForHistoryDb());
74 75
75 // Set the database page size to something a little larger to give us 76 // Set the database page size to something a little larger to give us
76 // better performance (we're typically seek rather than bandwidth limited). 77 // better performance (we're typically seek rather than bandwidth limited).
77 // This only has an effect before any tables have been created, otherwise 78 // This only has an effect before any tables have been created, otherwise
78 // this is a NOP. Must be a power of 2 and a max of 8192. 79 // this is a NOP. Must be a power of 2 and a max of 8192.
79 db_.set_page_size(4096); 80 db_.set_page_size(4096);
80 81
81 // Increase the cache size. The page size, plus a little extra, times this 82 if (HistoryFieldTrial::IsLowMemFieldTrial()) {
82 // value, tells us how much memory the cache will use maximum. 83 db_.set_cache_size(64);
83 // 6000 * 4MB = 24MB 84 } else {
84 // TODO(brettw) scale this value to the amount of available memory. 85 // Increase the cache size. The page size, plus a little extra, times this
85 db_.set_cache_size(6000); 86 // value, tells us how much memory the cache will use maximum.
87 // 6000 * 4MB = 24MB
88 // TODO(brettw) scale this value to the amount of available memory.
89 db_.set_cache_size(6000);
90 }
Scott Hess - ex-Googler 2011/10/24 19:15:27 Yeah, I'm with jar, this range is pretty huge. I
86 91
87 // Note that we don't set exclusive locking here. That's done by 92 // Note that we don't set exclusive locking here. That's done by
88 // BeginExclusiveMode below which is called later (we have to be in shared 93 // BeginExclusiveMode below which is called later (we have to be in shared
89 // mode to start out for the in-memory backend to read the data). 94 // mode to start out for the in-memory backend to read the data).
90 95
91 if (!db_.Open(history_name)) 96 if (!db_.Open(history_name))
92 return sql::INIT_FAILURE; 97 return sql::INIT_FAILURE;
93 98
94 // Wrap the rest of init in a tranaction. This will prevent the database from 99 // Wrap the rest of init in a tranaction. This will prevent the database from
95 // getting corrupted if we crash in the middle of initialization or migration. 100 // getting corrupted if we crash in the middle of initialization or migration.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); 340 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);");
336 341
337 // Erase all the full text index files. These will take a while to update and 342 // Erase all the full text index files. These will take a while to update and
338 // are less important, so we just blow them away. Same with the archived 343 // are less important, so we just blow them away. Same with the archived
339 // database. 344 // database.
340 needs_version_17_migration_ = true; 345 needs_version_17_migration_ = true;
341 } 346 }
342 #endif 347 #endif
343 348
344 } // namespace history 349 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698