[tracker] libtracker-miner: Call next_files_async() in batches



commit 2e7e70a2eaa4dda0ea28eaa1876d34aab1d1c934
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jul 7 23:24:20 2017 +0200

    libtracker-miner: Call next_files_async() in batches
    
    Instead of painstakingly requesting GFileInfos one by one,
    request several of those in a single batch. This is a lot easier
    to the main loop, because we don't need hitting it several times
    per file.
    
    This and the previous commits result in massive speedups to
    TrackerMinerFS, since CPU time in userspace during TrackerMinerFS
    activity was largely dominated by GSource and main loop overhead.
    Somewhere around 1.80x-2x faster for initial indexing, and up to
    3x faster for startup on an already indexed FS, from unscientifical
    testing with a quarter million files contained in ~17K folders.

 src/libtracker-miner/tracker-crawler.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
index 61373bc..0af8d1f 100644
--- a/src/libtracker-miner/tracker-crawler.c
+++ b/src/libtracker-miner/tracker-crawler.c
@@ -51,7 +51,7 @@ typedef struct {
        DirectoryRootInfo  *root_info;
        DirectoryProcessingData *dir_info;
        GFile *dir_file;
-       GSList *files;
+       GList *files;
 } DataProviderData;
 
 struct DirectoryChildData {
@@ -796,7 +796,7 @@ data_provider_data_add (DataProviderData *dpd)
 {
        TrackerCrawler *crawler;
        GFile *parent;
-       GSList *l;
+       GList *l;
 
        crawler = dpd->crawler;
        parent = dpd->dir_file;
@@ -827,7 +827,7 @@ data_provider_data_add (DataProviderData *dpd)
                g_object_unref (info);
        }
 
-       g_slist_free (dpd->files);
+       g_list_free (dpd->files);
        dpd->files = NULL;
 }
 
@@ -838,7 +838,7 @@ data_provider_data_free (DataProviderData *dpd)
        g_object_unref (dpd->crawler);
 
        if (dpd->files) {
-               g_slist_free_full (dpd->files, g_object_unref);
+               g_list_free_full (dpd->files, g_object_unref);
        }
 
        if (dpd->enumerator) {
@@ -941,9 +941,10 @@ enumerate_next_cb (GObject      *object,
                process_func_start (dpd->crawler);
        } else {
                /* More work to do, we keep reference given to us */
-               dpd->files = g_slist_prepend (dpd->files, info->data);
+               dpd->files = g_list_concat (dpd->files, info);
                g_file_enumerator_next_files_async (G_FILE_ENUMERATOR (object),
-                                                   1, G_PRIORITY_LOW,
+                                                   MAX_SIMULTANEOUS_ITEMS,
+                                                   G_PRIORITY_LOW,
                                                    dpd->crawler->priv->cancellable,
                                                    enumerate_next_cb,
                                                    dpd);
@@ -982,7 +983,8 @@ data_provider_begin_cb (GObject      *object,
        }
 
        g_file_enumerator_next_files_async (dpd->enumerator,
-                                           1, G_PRIORITY_LOW,
+                                           MAX_SIMULTANEOUS_ITEMS,
+                                           G_PRIORITY_LOW,
                                            dpd->crawler->priv->cancellable,
                                            enumerate_next_cb,
                                            dpd);


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