[tracker/wip/carlosg/wal-and-other-fixes: 6/8] libtracker-data: Drop our WAL hook
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/wal-and-other-fixes: 6/8] libtracker-data: Drop our WAL hook
- Date: Wed, 1 Jul 2020 17:40:10 +0000 (UTC)
commit 20b391c66f93d33ae07ddba5a8ebe7e007161cc5
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jul 1 18:11:38 2020 +0200
libtracker-data: Drop our WAL hook
Testing with and without, and it turns out SQLite knows better how
to deal with WAL autocheckpoints, who'd say. Performance with this
WAL hook is worse than without, so drop it.
src/libtracker-data/tracker-db-interface-sqlite.c | 26 --------
src/libtracker-data/tracker-db-interface-sqlite.h | 3 -
src/libtracker-data/tracker-db-manager.c | 75 +----------------------
3 files changed, 2 insertions(+), 102 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 5b36084a9..9648c97ae 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -98,10 +98,6 @@ struct TrackerDBInterface {
/* Used if TRACKER_DB_INTERFACE_USE_MUTEX is set */
GMutex mutex;
- /* Wal */
- TrackerDBWalCallback wal_hook;
- gpointer wal_hook_data;
-
/* User data */
gpointer user_data;
GDestroyNotify user_data_destroy_notify;
@@ -2440,28 +2436,6 @@ tracker_db_interface_sqlite_reset_collator (TrackerDBInterface *db_interface)
}
}
-static gint
-wal_hook (gpointer user_data,
- sqlite3 *db,
- const gchar *db_name,
- gint n_pages)
-{
- TrackerDBInterface *iface = user_data;
-
- iface->wal_hook (iface, n_pages, iface->wal_hook_data);
- return SQLITE_OK;
-}
-
-void
-tracker_db_interface_sqlite_wal_hook (TrackerDBInterface *interface,
- TrackerDBWalCallback callback,
- gpointer user_data)
-{
- interface->wal_hook = callback;
- interface->wal_hook_data = user_data;
- sqlite3_wal_hook (interface->db, wal_hook, interface);
-}
-
gboolean
tracker_db_interface_sqlite_wal_checkpoint (TrackerDBInterface *interface,
gboolean blocking,
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.h
b/src/libtracker-data/tracker-db-interface-sqlite.h
index 517dea506..cdca629f5 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.h
+++ b/src/libtracker-data/tracker-db-interface-sqlite.h
@@ -55,9 +55,6 @@ void tracker_db_interface_sqlite_fts_init (TrackerD
GHashTable
*multivalued,
gboolean create);
void tracker_db_interface_sqlite_reset_collator (TrackerDBInterface *interface);
-void tracker_db_interface_sqlite_wal_hook (TrackerDBInterface *interface,
- TrackerDBWalCallback callback,
- gpointer user_data);
gboolean tracker_db_interface_sqlite_wal_checkpoint (TrackerDBInterface *interface,
gboolean blocking,
GError **error);
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index f2b8a247c..1bf2d6c93 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -103,7 +103,6 @@ typedef enum {
typedef struct {
TrackerDBInterface *iface;
- TrackerDBInterface *wal_iface;
const gchar *file;
const gchar *name;
gchar *abs_filename;
@@ -112,7 +111,7 @@ typedef struct {
} TrackerDBDefinition;
static TrackerDBDefinition db_base = {
- NULL, NULL,
+ NULL,
"meta.db",
"meta",
NULL,
@@ -138,7 +137,6 @@ struct _TrackerDBManager {
GWeakRef iface_data;
GAsyncQueue *interfaces;
- GThread *wal_thread;
};
enum {
@@ -226,9 +224,6 @@ db_set_params (TrackerDBInterface *iface,
g_clear_object (&stmt);
}
- /* disable autocheckpoint */
- tracker_db_interface_execute_query (iface, NULL, "PRAGMA \"%s\".wal_autocheckpoint = 0", database);
-
tracker_db_interface_execute_query (iface, NULL, "PRAGMA \"%s\".journal_size_limit = 10240000",
database);
if (page_size != TRACKER_DB_PAGE_SIZE_DONT_SET) {
@@ -733,14 +728,9 @@ tracker_db_manager_finalize (GObject *object)
TrackerDBManager *db_manager = TRACKER_DB_MANAGER (object);
gboolean readonly = (db_manager->flags & TRACKER_DB_MANAGER_READONLY) != 0;
- if (db_manager->wal_thread)
- g_thread_join (db_manager->wal_thread);
-
g_async_queue_unref (db_manager->interfaces);
g_free (db_manager->db.abs_filename);
- g_clear_object (&db_manager->db.wal_iface);
-
if (db_manager->db.iface) {
if (!readonly)
tracker_db_interface_sqlite_wal_checkpoint (db_manager->db.iface, TRUE, NULL);
@@ -913,60 +903,6 @@ tracker_db_manager_class_init (TrackerDBManagerClass *klass)
1, TRACKER_TYPE_DB_INTERFACE);
}
-static void
-wal_checkpoint (TrackerDBInterface *iface,
- gboolean blocking)
-{
- GError *error = NULL;
-
- tracker_db_interface_sqlite_wal_checkpoint (iface, blocking,
- blocking ? &error : NULL);
-
- if (error) {
- g_warning ("Error in %s WAL checkpoint: %s",
- blocking ? "blocking" : "deferred",
- error->message);
- g_error_free (error);
- }
-}
-
-static gpointer
-wal_checkpoint_thread (gpointer data)
-{
- TrackerDBManager *db_manager = data;
-
- if (!db_manager->db.wal_iface)
- db_manager->db.wal_iface = init_writable_db_interface (db_manager);
-
- if (db_manager->db.wal_iface)
- wal_checkpoint (db_manager->db.wal_iface, FALSE);
-
- return NULL;
-}
-
-static void
-wal_hook (TrackerDBInterface *iface,
- gint n_pages,
- gpointer user_data)
-{
- TrackerDBManager *db_manager = user_data;
-
- /* Ensure there is only one WAL checkpoint at a time */
- if (db_manager->wal_thread)
- g_thread_join (db_manager->wal_thread);
-
- if (n_pages >= 10000) {
- /* Do immediate checkpointing (blocking updates) to
- * prevent excessive WAL file growth.
- */
- wal_checkpoint (iface, TRUE);
- } else {
- /* Defer non-blocking checkpoint to thread */
- db_manager->wal_thread = g_thread_try_new ("wal-checkpoint", wal_checkpoint_thread,
- db_manager, NULL);
- }
-}
-
static TrackerDBInterface *
init_writable_db_interface (TrackerDBManager *db_manager)
{
@@ -988,16 +924,9 @@ init_writable_db_interface (TrackerDBManager *db_manager)
TrackerDBInterface *
tracker_db_manager_get_writable_db_interface (TrackerDBManager *db_manager)
{
- if (db_manager->db.iface == NULL) {
+ if (db_manager->db.iface == NULL)
db_manager->db.iface = init_writable_db_interface (db_manager);
- if (db_manager->db.iface &&
- (db_manager->flags & TRACKER_DB_MANAGER_READONLY) == 0) {
- tracker_db_interface_sqlite_wal_hook (db_manager->db.iface,
- wal_hook, db_manager);
- }
- }
-
return db_manager->db.iface;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]