]> source.dussan.org Git - rspamd.git/commitdiff
Enable mmap in sqlite3.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 5 Oct 2015 17:58:13 +0000 (18:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 5 Oct 2015 17:58:13 +0000 (18:58 +0100)
src/libserver/fuzzy_backend.c
src/libutil/sqlite_utils.c

index 3d4bb6c233a5f8ff0972944bdfa6b0cf828020b9..af6eb193d16da101334a37c60a8f861683cc0d31 100644 (file)
@@ -415,7 +415,8 @@ rspamd_fuzzy_backend_open (const gchar *path, GError **err)
        static const char sqlite_wal[] = "PRAGMA journal_mode=\"wal\";",
                        fallback_journal[] = "PRAGMA journal_mode=\"off\";",
                        foreign_keys[] = "PRAGMA foreign_keys=\"ON\";",
-                       secure_delete[] = "PRAGMA secure_delete=\"OFF\";";
+                       secure_delete[] = "PRAGMA secure_delete=\"OFF\";",
+                       enable_mmap[] = "PRAGMA mmap_size=268435456;";
        gint rc;
 
        if (path == NULL) {
@@ -485,6 +486,13 @@ rspamd_fuzzy_backend_open (const gchar *path, GError **err)
                                sqlite3_errmsg (backend->db));
        }
 
+       if (sizeof (gpointer) >= 8 &&
+                       (rc = sqlite3_exec (backend->db, enable_mmap, NULL, NULL, NULL)) !=
+                       SQLITE_OK) {
+               msg_warn_fuzzy_backend ("cannot enable mmap: %s",
+                               sqlite3_errmsg (backend->db));
+       }
+
        rspamd_fuzzy_backend_run_simple (RSPAMD_FUZZY_BACKEND_VACUUM, backend, NULL);
 
        if (rspamd_fuzzy_backend_run_stmt (backend, RSPAMD_FUZZY_BACKEND_COUNT)
index d677a0dc24eaa88eda4d40d3677effc5d64567f3..980d07abc5d7d6a7caeea706461a9b853cab7109 100644 (file)
@@ -250,7 +250,8 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
        static const char sqlite_wal[] = "PRAGMA journal_mode=\"wal\";",
                        exclusive_lock_sql[] = "PRAGMA locking_mode=\"exclusive\";",
                        fsync_sql[] = "PRAGMA synchronous=1;",
-                       foreign_keys[] = "PRAGMA foreign_keys=\"ON\";";
+                       foreign_keys[] = "PRAGMA foreign_keys=\"ON\";",
+                       enable_mmap[] = "PRAGMA mmap_size=268435456;";
        gboolean create = FALSE, has_lock = FALSE;
 
        flags = SQLITE_OPEN_READWRITE;
@@ -384,6 +385,13 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
                                sqlite3_errmsg (sqlite));
        }
 
+       if (sizeof (gpointer) >= 8 &&
+               (rc = sqlite3_exec (sqlite, enable_mmap, NULL, NULL, NULL)) !=
+                       SQLITE_OK) {
+               msg_warn_pool ("cannot enable mmap: %s",
+                               sqlite3_errmsg (sqlite));
+       }
+
        if (has_lock) {
                msg_debug_pool ("removing lock from %s", lock_path);
                rspamd_file_unlock (lock_fd, FALSE);