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

Side by Side Diff: chrome/browser/history/text_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, 2 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 | 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 <limits> 5 #include <limits>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/history/text_database.h" 9 #include "chrome/browser/history/text_database.h"
10 10
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 17 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
18 #include "chrome/browser/history/history_field_trial.h"
18 #include "sql/statement.h" 19 #include "sql/statement.h"
19 #include "sql/transaction.h" 20 #include "sql/transaction.h"
20 21
21 // There are two tables in each database, one full-text search (FTS) table which 22 // There are two tables in each database, one full-text search (FTS) table which
22 // indexes the contents and title of the pages. The other is a regular SQLITE 23 // indexes the contents and title of the pages. The other is a regular SQLITE
23 // table which contains non-indexed information about the page. All columns of 24 // table which contains non-indexed information about the page. All columns of
24 // a FTS table are indexed using the text search algorithm, which isn't what we 25 // a FTS table are indexed using the text search algorithm, which isn't what we
25 // want for things like times. If this were in the FTS table, there would be 26 // want for things like times. If this were in the FTS table, there would be
26 // different words in the index for each time number. 27 // different words in the index for each time number.
27 // 28 //
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Set the database page size to something a little larger to give us 132 // Set the database page size to something a little larger to give us
132 // better performance (we're typically seek rather than bandwidth limited). 133 // better performance (we're typically seek rather than bandwidth limited).
133 // This only has an effect before any tables have been created, otherwise 134 // This only has an effect before any tables have been created, otherwise
134 // this is a NOP. Must be a power of 2 and a max of 8192. 135 // this is a NOP. Must be a power of 2 and a max of 8192.
135 db_.set_page_size(4096); 136 db_.set_page_size(4096);
136 137
137 // The default cache size is 2000 which give >8MB of data. Since we will often 138 // The default cache size is 2000 which give >8MB of data. Since we will often
138 // have 2-3 of these objects, each with their own 8MB, this adds up very fast. 139 // have 2-3 of these objects, each with their own 8MB, this adds up very fast.
139 // We therefore reduce the size so when there are multiple objects, we're not 140 // We therefore reduce the size so when there are multiple objects, we're not
140 // too big. 141 // too big.
141 db_.set_cache_size(512); 142 if (HistoryFieldTrial::IsLowMemFieldTrial()) {
143 // FTS does merges of 16 pages at a time, so we need a working set size
144 // somewhat greater than that to prevent too much thrashing.
145 db_.set_cache_size(128);
146 } else {
147 db_.set_cache_size(512);
148 }
142 149
143 // Run the database in exclusive mode. Nobody else should be accessing the 150 // Run the database in exclusive mode. Nobody else should be accessing the
144 // database while we're running, and this will give somewhat improved perf. 151 // database while we're running, and this will give somewhat improved perf.
145 db_.set_exclusive_locking(); 152 db_.set_exclusive_locking();
146 153
147 // Attach the database to our index file. 154 // Attach the database to our index file.
148 if (!db_.Open(file_name_)) 155 if (!db_.Open(file_name_))
149 return false; 156 return false;
150 157
151 // Meta table tracking version information. 158 // Meta table tracking version information.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } else { 382 } else {
376 // Since we got the results in order, we know the last item is the last 383 // Since we got the results in order, we know the last item is the last
377 // time we considered. 384 // time we considered.
378 *first_time_searched = results->back().time; 385 *first_time_searched = results->back().time;
379 } 386 }
380 387
381 statement.Reset(); 388 statement.Reset();
382 } 389 }
383 390
384 } // namespace history 391 } // namespace history
OLDNEW
« chrome/browser/history/history_field_trial.cc ('K') | « chrome/browser/history/in_memory_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698