summaryrefslogtreecommitdiffstats
path: root/sql/connection.h
diff options
context:
space:
mode:
authorshess <shess@chromium.org>2015-09-23 13:29:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-23 20:33:56 +0000
commit9a1948a4d6d445d5c8e209bdcd1cd050af72060b (patch)
treea2b6abac4673affa109bcc57ae72d67904ae8c29 /sql/connection.h
parentfa2fd3809241aae99bf07463ff99ad03dc9a1e07 (diff)
downloadchromium_src-9a1948a4d6d445d5c8e209bdcd1cd050af72060b.zip
chromium_src-9a1948a4d6d445d5c8e209bdcd1cd050af72060b.tar.gz
chromium_src-9a1948a4d6d445d5c8e209bdcd1cd050af72060b.tar.bz2
[sql] Use memory-mapped I/O for sql::Connection.
sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's memory-mapped I/O. Additionally instrument to flush dirty pages from the page cache after writes. BUG=489784,533682 Review URL: https://codereview.chromium.org/1349863003 Cr-Commit-Position: refs/heads/master@{#350362}
Diffstat (limited to 'sql/connection.h')
-rw-r--r--sql/connection.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/connection.h b/sql/connection.h
index 19592d9..d456b6c 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -146,6 +146,9 @@ class SQL_EXPORT Connection {
// other platforms.
void set_restrict_to_user() { restrict_to_user_ = true; }
+ // Call to opt out of memory-mapped file I/O.
+ void set_mmap_disabled() { mmap_disabled_ = true; }
+
// Set an error-handling callback. On errors, the error number (and
// statement, if available) will be passed to the callback.
//
@@ -638,6 +641,12 @@ class SQL_EXPORT Connection {
return clock_->Now();
}
+ // Release page-cache memory if memory-mapped I/O is enabled and the database
+ // was changed. Passing true for |implicit_change_performed| allows
+ // overriding the change detection for cases like DDL (CREATE, DROP, etc),
+ // which do not participate in the total-rows-changed tracking.
+ void ReleaseCacheMemoryIfNeeded(bool implicit_change_performed);
+
// The actual sqlite database. Will be NULL before Init has been called or if
// Init resulted in an error.
sqlite3* db_;
@@ -679,6 +688,17 @@ class SQL_EXPORT Connection {
// databases.
bool poisoned_;
+ // |true| if SQLite memory-mapped I/O is not desired for this connection.
+ bool mmap_disabled_;
+
+ // |true| if SQLite memory-mapped I/O was enabled for this connection.
+ // Used by ReleaseCacheMemoryIfNeeded().
+ bool mmap_enabled_;
+
+ // Used by ReleaseCacheMemoryIfNeeded() to track if new changes have happened
+ // since memory was last released.
+ int total_changes_at_last_release_;
+
ErrorCallback error_callback_;
// Tag for auxiliary histograms.