[tracker] libtracker-data: Perform VACUUM only on large database files



commit 57235eb302194554feb077019d9c69a4bbd8214f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Feb 12 02:23:49 2018 +0100

    libtracker-data: Perform VACUUM only on large database files
    
    The agressive VACUUM on shutdown is the cause for the reported slowness
    in tracker-store restarts. Let's be a bit more conservative, and only
    trigger VACUUMing when the database file gets hideously large (4GB).
    
    There is the remote possibility that a database is still larger than
    4GB after VACUUM. I'll just make it suck at the moment and do the same
    frequent VACUUMs we get currently.

 src/libtracker-data/tracker-data-manager.c |    2 +-
 src/libtracker-data/tracker-db-manager.c   |   14 ++++++++++++++
 src/libtracker-data/tracker-db-manager.h   |    2 ++
 3 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 8563303..38f8f77 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -4821,7 +4821,7 @@ tracker_data_manager_dispose (GObject *object)
                                g_clear_error (&error);
                        }
 
-                       tracker_db_interface_execute_query (iface, NULL, "VACUUM");
+                       tracker_db_manager_check_perform_vacuum (manager->db_manager);
                }
 
                g_clear_pointer (&manager->db_manager, tracker_db_manager_free);
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index aff39bf..efb0fa2 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -65,6 +65,8 @@
 #define TRACKER_DB_VERSION_FILE       "db-version.txt"
 #define TRACKER_DB_LOCALE_FILE        "db-locale.txt"
 
+#define TRACKER_VACUUM_CHECK_SIZE     ((goffset) 4 * 1024 * 1024 * 1024) /* 4GB */
+
 #define IN_USE_FILENAME               ".meta.isrunning"
 
 #define PARSER_SHA1_FILENAME          "parser-sha1.txt"
@@ -1163,3 +1165,15 @@ tracker_db_manager_tokenizer_update (TrackerDBManager *db_manager)
 
        g_free (filename);
 }
+
+void
+tracker_db_manager_check_perform_vacuum (TrackerDBManager *db_manager)
+{
+       TrackerDBInterface *iface;
+
+       if (tracker_file_get_size (db_manager->db.abs_filename) < TRACKER_VACUUM_CHECK_SIZE)
+               return;
+
+       iface = tracker_db_manager_get_writable_db_interface (db_manager);
+       tracker_db_interface_execute_query (iface, NULL, "VACUUM");
+}
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index 53f73a4..95a71cf 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -96,6 +96,8 @@ void                tracker_db_manager_set_current_locale     (TrackerDBManager
 gboolean            tracker_db_manager_get_tokenizer_changed  (TrackerDBManager      *db_manager);
 void                tracker_db_manager_tokenizer_update       (TrackerDBManager      *db_manager);
 
+void                tracker_db_manager_check_perform_vacuum   (TrackerDBManager      *db_manager);
+
 G_END_DECLS
 
 #endif /* __LIBTRACKER_DB_MANAGER_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]