[pango/speed-up-format-filtering: 3/3] fontconfig: Add some trace marks




commit b4169db571c62133e7ce987f6b2d52115e8a16bf
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Aug 19 14:10:57 2020 -0400

    fontconfig: Add some trace marks
    
    Add trace marks around the expensive fontconfig
    calls, and for when we are waiting on them.

 pango/pangofc-fontmap.c | 44 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 5fefb373..f9c72a36 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -54,6 +54,7 @@
 #include "pango-impl-utils.h"
 #include "pango-enum-types.h"
 #include "pango-coverage-private.h"
+#include "pango-trace-private.h"
 #include <hb-ft.h>
 
 
@@ -826,12 +827,15 @@ match_in_thread (GTask        *task,
   ThreadData *td = task_data;
   FcResult result;
   FcPattern *match;
+  gint64 before = PANGO_TRACE_CURRENT_TIME;
 
   match = FcFontSetMatch (td->config,
                           &td->fonts, 1,
                           td->pattern,
                           &result);
 
+  pango_trace_mark (before, "FcFontSetMatch", NULL);
+
   g_mutex_lock (&td->patterns->mutex);
   td->patterns->match = match;
   g_cond_signal (&td->patterns->cond);
@@ -847,6 +851,7 @@ sort_in_thread (GTask        *task,
   ThreadData *td = task_data;
   FcResult result;
   FcFontSet *fontset;
+  gint64 before = PANGO_TRACE_CURRENT_TIME;
 
   fontset = FcFontSetSort (td->config,
                            &td->fonts, 1,
@@ -855,6 +860,8 @@ sort_in_thread (GTask        *task,
                            NULL,
                            &result);
 
+  pango_trace_mark (before, "FcFontSetSort", NULL);
+
   g_mutex_lock (&td->patterns->mutex);
   td->patterns->fontset = fontset;
   g_cond_signal (&td->patterns->cond);
@@ -1007,16 +1014,25 @@ pango_fc_patterns_get_font_pattern (PangoFcPatterns *pats, int i, gboolean *prep
 
   if (i == 0)
     {
+      gint64 before = PANGO_TRACE_CURRENT_TIME;
+      gboolean waited = FALSE;
+
       g_mutex_lock (&pats->mutex);
 
       while (!pats->match && !pats->fontset)
-        g_cond_wait (&pats->cond, &pats->mutex);
+        {
+          waited = TRUE;
+          g_cond_wait (&pats->cond, &pats->mutex);
+        }
 
       match = pats->match;
       fontset = pats->fontset;
 
       g_mutex_unlock (&pats->mutex);
 
+      if (waited)
+        pango_trace_mark (before, "wait for FcFontMatch", NULL);
+
       if (match)
         {
           *prepare = FALSE;
@@ -1025,14 +1041,23 @@ pango_fc_patterns_get_font_pattern (PangoFcPatterns *pats, int i, gboolean *prep
     }
   else
     {
+      gint64 before = PANGO_TRACE_CURRENT_TIME;
+      gboolean waited = FALSE;
+
       g_mutex_lock (&pats->mutex);
 
       while (!pats->fontset)
-        g_cond_wait (&pats->cond, &pats->mutex);
+        {
+          waited = TRUE;
+          g_cond_wait (&pats->cond, &pats->mutex);
+        }
 
       fontset = pats->fontset;
 
       g_mutex_unlock (&pats->mutex);
+
+      if (waited)
+        pango_trace_mark (before, "wait for FcFontSort", NULL);
     }
 
   if (fontset)
@@ -1323,8 +1348,12 @@ init_in_thread (GTask        *task,
                 gpointer      task_data,
                 GCancellable *cancellable)
 {
+  gint64 before = PANGO_TRACE_CURRENT_TIME;
+
   FcInit ();
 
+  pango_trace_mark (before, "FcInit", NULL);
+
   g_mutex_lock (&fc_init_mutex);
   fc_initialized = TRUE;
   g_cond_signal (&fc_init_cond);
@@ -1334,10 +1363,19 @@ init_in_thread (GTask        *task,
 static void
 wait_for_fc_init (void)
 {
+  gint64 before = PANGO_TRACE_CURRENT_TIME;
+  gboolean waited = FALSE;
+
   g_mutex_lock (&fc_init_mutex);
   while (!fc_initialized)
-    g_cond_wait (&fc_init_cond, &fc_init_mutex);
+    {
+      waited = TRUE;
+      g_cond_wait (&fc_init_cond, &fc_init_mutex);
+    }
   g_mutex_unlock (&fc_init_mutex);
+
+  if (waited)
+    pango_trace_mark (before, "wait for FcInit", NULL);
 }
 
 static void


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