[gtk/startup-profiling] Add more sysprof marks




commit a10b1b7341822ca751709459f1e21a31641df9a2
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 22 11:36:29 2021 -0400

    Add more sysprof marks
    
    Add a few more marks during gtk_init to figure out where
    our startup time goes, and avoid the sysprof initialization
    from distorting the first mark.

 gdk/gdkdisplay.c         | 12 ++++++++++++
 gsk/ngl/gskngldriver.c   |  9 +++++++++
 gsk/ngl/gsknglrenderer.c |  2 +-
 gtk/gtkmain.c            | 14 ++++++++++++++
 4 files changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 8da1a4cc9f..5067065b03 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1200,6 +1200,10 @@ gdk_display_init_gl (GdkDisplay *self)
 {
   GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
   GdkGLContext *context;
+  gint64 before G_GNUC_UNUSED;
+  gint64 before2 G_GNUC_UNUSED;
+
+  before = GDK_PROFILER_CURRENT_TIME;
 
   if (GDK_DISPLAY_DEBUG_CHECK (self, GL_DISABLE))
     {
@@ -1213,17 +1217,23 @@ gdk_display_init_gl (GdkDisplay *self)
   if (context == NULL)
     return;
 
+  before2 = GDK_PROFILER_CURRENT_TIME;
+
   if (!gdk_gl_context_realize (context, &priv->gl_error))
     {
       g_object_unref (context);
       return;
     }
 
+  gdk_profiler_end_mark (before2, "realize OpenGL context", NULL);
+
   /* Only assign after realize, so GdkGLContext::realize() can use
    * gdk_display_get_gl_context() == NULL to differentiate between
    * the display's context and any other context.
    */
   priv->gl_context = context;
+
+  gdk_profiler_end_mark (before, "initialize OpenGL", NULL);
 }
 
 /**
@@ -1268,6 +1278,8 @@ gdk_display_prepare_gl (GdkDisplay  *self,
         {
           if (error)
             *error = g_error_copy (priv->gl_error);
+
+
           return FALSE;
         }
 
diff --git a/gsk/ngl/gskngldriver.c b/gsk/ngl/gskngldriver.c
index eba888f514..bc4a9ad413 100644
--- a/gsk/ngl/gskngldriver.c
+++ b/gsk/ngl/gskngldriver.c
@@ -26,6 +26,7 @@
 #include <gdk/gdkglcontextprivate.h>
 #include <gdk/gdkdisplayprivate.h>
 #include <gdk/gdktextureprivate.h>
+#include <gdk/gdkprofilerprivate.h>
 #include <gsk/gskdebugprivate.h>
 #include <gsk/gskglshaderprivate.h>
 #include <gsk/gskrendererprivate.h>
@@ -329,6 +330,7 @@ gsk_ngl_driver_load_programs (GskNglDriver  *self,
 {
   GskNglCompiler *compiler;
   gboolean ret = FALSE;
+  G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
 
   g_assert (GSK_IS_NGL_DRIVER (self));
   g_assert (GSK_IS_NGL_COMMAND_QUEUE (self->command_queue));
@@ -396,6 +398,8 @@ gsk_ngl_driver_load_programs (GskNglDriver  *self,
 failure:
   g_clear_object (&compiler);
 
+  gdk_profiler_end_mark (start_time, "load programs", NULL);
+
   return ret;
 }
 
@@ -422,9 +426,12 @@ gsk_ngl_driver_new (GskNglCommandQueue  *command_queue,
 {
   GskNglDriver *self;
   GdkGLContext *context;
+  gint64 before G_GNUC_UNUSED;
 
   g_return_val_if_fail (GSK_IS_NGL_COMMAND_QUEUE (command_queue), NULL);
 
+  before = GDK_PROFILER_CURRENT_TIME;
+
   context = gsk_ngl_command_queue_get_context (command_queue);
 
   gdk_gl_context_make_current (context);
@@ -444,6 +451,8 @@ gsk_ngl_driver_new (GskNglCommandQueue  *command_queue,
   self->icons = gsk_ngl_icon_library_new (self);
   self->shadows = gsk_ngl_shadow_library_new (self);
 
+  gdk_profiler_end_mark (before, "create GskNglDriver", NULL);
+
   return g_steal_pointer (&self);
 }
 
diff --git a/gsk/ngl/gsknglrenderer.c b/gsk/ngl/gsknglrenderer.c
index fa393c11cf..5f8a683b1e 100644
--- a/gsk/ngl/gsknglrenderer.c
+++ b/gsk/ngl/gsknglrenderer.c
@@ -125,7 +125,7 @@ failure:
   g_clear_object (&driver);
   g_clear_object (&context);
 
-  gdk_profiler_end_mark (start_time, "GskNglRenderer realize", NULL);
+  gdk_profiler_end_mark (start_time, "realize GskNglRenderer", NULL);
 
   return ret;
 }
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index accaee07c1..9a7b36eb05 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -26,6 +26,7 @@
 
 #include "gdk/gdk.h"
 #include "gdk/gdk-private.h"
+#include "gdk/gdkprofilerprivate.h"
 #include "gsk/gskprivate.h"
 #include "gsk/gskrendernodeprivate.h"
 #include "gtknative.h"
@@ -520,10 +521,13 @@ static void
 do_post_parse_initialization (void)
 {
   GdkDisplayManager *display_manager;
+  gint64 before G_GNUC_UNUSED;
 
   if (gtk_initialized)
     return;
 
+  before = GDK_PROFILER_CURRENT_TIME;
+
   gettext_initialization ();
 
 #ifdef SIGPIPE
@@ -533,21 +537,28 @@ do_post_parse_initialization (void)
   gtk_widget_set_default_direction (gtk_get_locale_direction ());
 
   gdk_event_init_types ();
+
   gsk_ensure_resources ();
   gsk_render_node_init_types ();
   _gtk_ensure_resources ();
 
+  gdk_profiler_end_mark (before, "basic initialization", NULL);
+
   gtk_initialized = TRUE;
 
+  before = GDK_PROFILER_CURRENT_TIME;
 #ifdef G_OS_UNIX
   gtk_print_backends_init ();
 #endif
   gtk_im_modules_init ();
   gtk_media_file_extension_init ();
+  gdk_profiler_end_mark (before, "init modules", NULL);
 
+  before = GDK_PROFILER_CURRENT_TIME;
   display_manager = gdk_display_manager_get ();
   if (gdk_display_manager_get_default_display (display_manager) != NULL)
     default_display_notify_cb (display_manager);
+  gdk_profiler_end_mark (before, "create display", NULL);
 
   g_signal_connect (display_manager, "notify::default-display",
                     G_CALLBACK (default_display_notify_cb),
@@ -580,6 +591,9 @@ gtk_init_check (void)
   if (gtk_initialized)
     return TRUE;
 
+  if (gdk_profiler_is_running ())
+    g_info ("Profiling is active");
+
   gettext_initialization ();
 
   if (!check_setugid ())


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