[gnome-builder] cache: name egg-task-caches



commit 1efbecdb9ebb8ece9f3060e778a9a1c34fc36955
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 13 15:15:14 2016 +0300

    cache: name egg-task-caches
    
    This makes it easier to see what was evicted in the debug logs.

 contrib/egg/egg-task-cache.c                      |   27 ++++++++++++++++++++-
 contrib/egg/egg-task-cache.h                      |    2 +
 plugins/autotools/ide-autotools-build-system.c    |    2 +
 plugins/autotools/ide-makecache.c                 |    4 +++
 plugins/clang/ide-clang-service.c                 |    2 +
 plugins/ctags/ide-ctags-service.c                 |    2 +
 plugins/gettext/ide-gettext-diagnostic-provider.c |    2 +
 plugins/symbol-tree/symbol-tree-panel.c           |    2 +
 8 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/contrib/egg/egg-task-cache.c b/contrib/egg/egg-task-cache.c
index 0286ba9..a6d9a23 100644
--- a/contrib/egg/egg-task-cache.c
+++ b/contrib/egg/egg-task-cache.c
@@ -57,6 +57,8 @@ struct _EggTaskCache
   GHashTable           *in_flight;
   GHashTable           *queued;
 
+  gchar                *name;
+
   EggHeap              *evict_heap;
   GSource              *evict_source;
   guint                 evict_source_id;
@@ -639,7 +641,8 @@ egg_task_cache_dispose (GObject *object)
       count = g_hash_table_size (self->cache);
       g_clear_pointer (&self->cache, g_hash_table_unref);
 
-      g_debug ("Evected cache of %"G_GINT64_FORMAT" items", count);
+      g_debug ("Evicted cache of %"G_GINT64_FORMAT" items from %s",
+               count, self->name ?: "unnamed cache");
 
       EGG_COUNTER_SUB (cached, count);
     }
@@ -676,6 +679,10 @@ egg_task_cache_dispose (GObject *object)
 static void
 egg_task_cache_finalize (GObject *object)
 {
+  EggTaskCache *self = (EggTaskCache *)object;
+
+  g_clear_pointer (&self->name, g_free);
+
   G_OBJECT_CLASS (egg_task_cache_parent_class)->finalize (object);
 
   EGG_COUNTER_DEC (instances);
@@ -895,3 +902,21 @@ egg_task_cache_get_values (EggTaskCache *self)
 
   return ar;
 }
+
+void
+egg_task_cache_set_name (EggTaskCache *self,
+                         const gchar  *name)
+{
+  g_return_if_fail (EGG_IS_TASK_CACHE (self));
+
+  g_free (self->name);
+  self->name = g_strdup (name);
+
+  if (name && self->evict_source)
+    {
+      g_autofree gchar *full_name = NULL;
+
+      full_name = g_strdup_printf ("[egg_task_cache] %s", name);
+      g_source_set_name (self->evict_source, full_name);
+    }
+}
diff --git a/contrib/egg/egg-task-cache.h b/contrib/egg/egg-task-cache.h
index 5a3affd..fcf5e47 100644
--- a/contrib/egg/egg-task-cache.h
+++ b/contrib/egg/egg-task-cache.h
@@ -59,6 +59,8 @@ EggTaskCache *egg_task_cache_new        (GHashFunc              key_hash_func,
                                          EggTaskCacheCallback   populate_callback,
                                          gpointer               populate_callback_data,
                                          GDestroyNotify         populate_callback_data_destroy);
+void          egg_task_cache_set_name   (EggTaskCache          *self,
+                                         const gchar           *name);
 void          egg_task_cache_get_async  (EggTaskCache          *self,
                                          gconstpointer          key,
                                          gboolean               force_update,
diff --git a/plugins/autotools/ide-autotools-build-system.c b/plugins/autotools/ide-autotools-build-system.c
index 48ae1c0..07940e0 100644
--- a/plugins/autotools/ide-autotools-build-system.c
+++ b/plugins/autotools/ide-autotools-build-system.c
@@ -678,6 +678,8 @@ ide_autotools_build_system_init (IdeAutotoolsBuildSystem *self)
                                          populate_cache_cb,
                                          self,
                                          NULL);
+
+  egg_task_cache_set_name (self->task_cache, "makecache");
 }
 
 static void
diff --git a/plugins/autotools/ide-makecache.c b/plugins/autotools/ide-makecache.c
index 67b5615..bfef063 100644
--- a/plugins/autotools/ide-makecache.c
+++ b/plugins/autotools/ide-makecache.c
@@ -1470,6 +1470,8 @@ ide_makecache_init (IdeMakecache *self)
                                                  self,
                                                  NULL);
 
+  egg_task_cache_set_name (self->file_targets_cache, "makecache: file-targets-cache");
+
   self->file_flags_cache = egg_task_cache_new ((GHashFunc)g_file_hash,
                                                (GEqualFunc)g_file_equal,
                                                g_object_ref,
@@ -1480,6 +1482,8 @@ ide_makecache_init (IdeMakecache *self)
                                                ide_makecache_get_file_flags_dispatch,
                                                self,
                                                NULL);
+
+  egg_task_cache_set_name (self->file_flags_cache, "makecache: file-flags-cache");
 }
 
 GFile *
diff --git a/plugins/clang/ide-clang-service.c b/plugins/clang/ide-clang-service.c
index d77fc43..93630b1 100644
--- a/plugins/clang/ide-clang-service.c
+++ b/plugins/clang/ide-clang-service.c
@@ -567,6 +567,8 @@ ide_clang_service_start (IdeService *service)
                                           g_object_ref (self),
                                           g_object_unref);
 
+  egg_task_cache_set_name (self->units_cache, "clang translation-unit cache");
+
   self->index = clang_createIndex (0, 0);
   clang_CXIndex_setGlobalOptions (self->index,
                                   CXGlobalOpt_ThreadBackgroundPriorityForAll);
diff --git a/plugins/ctags/ide-ctags-service.c b/plugins/ctags/ide-ctags-service.c
index ff97af5..fa88969 100644
--- a/plugins/ctags/ide-ctags-service.c
+++ b/plugins/ctags/ide-ctags-service.c
@@ -591,6 +591,8 @@ ide_ctags_service_init (IdeCtagsService *self)
                                       ide_ctags_service_build_index_cb,
                                       self,
                                       NULL);
+
+  egg_task_cache_set_name (self->indexes, "ctags index cache");
 }
 
 void
diff --git a/plugins/gettext/ide-gettext-diagnostic-provider.c 
b/plugins/gettext/ide-gettext-diagnostic-provider.c
index 2acf1e9..5a73a1e 100644
--- a/plugins/gettext/ide-gettext-diagnostic-provider.c
+++ b/plugins/gettext/ide-gettext-diagnostic-provider.c
@@ -443,4 +443,6 @@ ide_gettext_diagnostic_provider_init (IdeGettextDiagnosticProvider *self)
                                                 populate_cache,
                                                 self,
                                                 NULL);
+
+  egg_task_cache_set_name (self->diagnostics_cache, "gettext diagnostic cache");
 }
diff --git a/plugins/symbol-tree/symbol-tree-panel.c b/plugins/symbol-tree/symbol-tree-panel.c
index 3b431e5..cd6a9ac 100644
--- a/plugins/symbol-tree/symbol-tree-panel.c
+++ b/plugins/symbol-tree/symbol-tree-panel.c
@@ -329,6 +329,8 @@ symbol_tree_panel_init (SymbolTreePanel *self)
                                             self,
                                             NULL);
 
+  egg_task_cache_set_name (self->symbols_cache, "symbol-tree symbol cache");
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
   g_object_set (self, "title", _("Symbols"), NULL);


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