Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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(40); | |
| 146 } else { | |
| 147 db_.set_cache_size(512); | |
|
jar (doing other things)
2011/10/24 18:40:55
Rather than having exactly two choices, have you c
Scott Hess - ex-Googler
2011/10/24 19:15:27
Wait - from our chat I thought this was 32, which
brettw
2011/10/25 01:55:02
How about I'll change this to 128. Depending on wh
Scott Hess - ex-Googler
2011/10/26 21:44:59
OK, seems reasonable.
One "thing" about having ju
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |