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

Side by Side Diff: sql/connection.cc

Issue 16356007: Disable sqlite lookaside buffers by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back to disabling in sql/connection.cc Created 7 years, 6 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 | « no previous file | 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 "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // Histogram failures specific to initial open for debugging 624 // Histogram failures specific to initial open for debugging
625 // purposes. 625 // purposes.
626 UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenFailure", err & 0xff, 50); 626 UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenFailure", err & 0xff, 50);
627 627
628 OnSqliteError(err, NULL); 628 OnSqliteError(err, NULL);
629 Close(); 629 Close();
630 db_ = NULL; 630 db_ = NULL;
631 return false; 631 return false;
632 } 632 }
633 633
634 // SQLite uses a lookaside buffer to improve performance of small mallocs.
635 // Chromium already depends on small mallocs being efficient, so we disable
636 // this to avoid the extra memory overhead.
637 // This must be called immediatly after opening the database before any SQL
638 // statements are run.
639 sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0);
640
634 // sqlite3_open() does not actually read the database file (unless a 641 // sqlite3_open() does not actually read the database file (unless a
635 // hot journal is found). Successfully executing this pragma on an 642 // hot journal is found). Successfully executing this pragma on an
636 // existing database requires a valid header on page 1. 643 // existing database requires a valid header on page 1.
637 // TODO(shess): For now, just probing to see what the lay of the 644 // TODO(shess): For now, just probing to see what the lay of the
638 // land is. If it's mostly SQLITE_NOTADB, then the database should 645 // land is. If it's mostly SQLITE_NOTADB, then the database should
639 // be razed. 646 // be razed.
640 err = ExecuteAndReturnErrorCode("PRAGMA auto_vacuum"); 647 err = ExecuteAndReturnErrorCode("PRAGMA auto_vacuum");
641 if (err != SQLITE_OK) 648 if (err != SQLITE_OK)
642 UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenProbeFailure", err & 0xff, 50); 649 UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenProbeFailure", err & 0xff, 50);
643 650
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 // as a single string. This doesn't appear to be an API contract, 786 // as a single string. This doesn't appear to be an API contract,
780 // it could return separate lines, so loop _and_ split. 787 // it could return separate lines, so loop _and_ split.
781 while (stmt.Step()) { 788 while (stmt.Step()) {
782 std::string result(stmt.ColumnString(0)); 789 std::string result(stmt.ColumnString(0));
783 base::SplitString(result, '\n', messages); 790 base::SplitString(result, '\n', messages);
784 } 791 }
785 return stmt.Succeeded(); 792 return stmt.Succeeded();
786 } 793 }
787 794
788 } // namespace sql 795 } // namespace sql
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698