[gtk/new-sysprof: 2/2] Port tracing to the sysprof collector api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/new-sysprof: 2/2] Port tracing to the sysprof collector api
- Date: Wed, 19 Aug 2020 22:50:39 +0000 (UTC)
commit 289d2a53c1e6f588c13a8c6f982d96d04c3a6450
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 19 18:49:34 2020 -0400
Port tracing to the sysprof collector api
Use the new sysprof collector api to do tracing.
config.h.meson | 2 +-
gdk/gdk.c | 6 -
gdk/gdkdrawcontext.c | 10 +-
gdk/gdkframeclock.c | 12 +-
gdk/gdkframeclockidle.c | 7 +-
gdk/gdkprofiler.c | 291 ++++++++-----------------------------
gdk/gdkprofilerprivate.h | 94 +++++++-----
gdk/gdksurface.c | 14 +-
gdk/wayland/gdkdisplay-wayland.c | 2 +-
gdk/wayland/gdkglcontext-wayland.c | 2 +-
gdk/wayland/gdksurface-wayland.c | 8 +-
gdk/x11/gdkdisplay-x11.c | 2 +-
gsk/gl/gskglrenderer.c | 2 +-
gsk/vulkan/gskvulkanrenderer.c | 2 -
gtk/gtkapplication.c | 4 +-
gtk/gtkbuilderparser.c | 4 +-
gtk/gtkcssnode.c | 9 +-
gtk/gtkcssprovider.c | 4 +-
gtk/gtkemojichooser.c | 6 +-
gtk/gtkicontheme.c | 6 +-
gtk/gtkimcontextsimple.c | 2 +-
gtk/gtkwidget.c | 4 +-
gtk/gtkwindow.c | 2 +-
meson.build | 2 +-
24 files changed, 162 insertions(+), 335 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index d8d5228693..f6a0ea0187 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -103,7 +103,7 @@
#mesondefine HAVE_SYS_PARAM_H
/* Have the sysprof-capture library */
-#mesondefine HAVE_SYSPROF_CAPTURE
+#mesondefine HAVE_SYSPROF
/* Define to 1 if you have the <sys/stat.h> header file. */
#mesondefine HAVE_SYS_STAT_H
diff --git a/gdk/gdk.c b/gdk/gdk.c
index ae3194bb59..b762831657 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -26,7 +26,6 @@
#include "gdkversionmacros.h"
-#include "gdkprofilerprivate.h"
#include "gdkinternals.h"
#include "gdkintl.h"
@@ -304,11 +303,6 @@ gdk_pre_parse (void)
g_warning ("GDK_DEBUG set but ignored because GTK isn't built with G_ENABLE_DEBUG");
#endif /* G_ENABLE_DEBUG */
- if (g_getenv ("GTK_TRACE_FD"))
- gdk_profiler_start (atoi (g_getenv ("GTK_TRACE_FD")));
- else if (g_getenv ("GTK_TRACE"))
- gdk_profiler_start (-1);
-
#ifndef G_HAS_CONSTRUCTORS
stash_desktop_startup_notification_id ();
#endif
diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c
index 75d7e61546..0002d9e136 100644
--- a/gdk/gdkdrawcontext.c
+++ b/gdk/gdkdrawcontext.c
@@ -175,17 +175,13 @@ gdk_draw_context_class_init (GdkDrawContextClass *klass)
g_object_class_install_properties (gobject_class, LAST_PROP, pspecs);
}
-#ifdef G_ENABLE_DEBUG
static guint pixels_counter;
-#endif
static void
gdk_draw_context_init (GdkDrawContext *self)
{
-#ifdef G_ENABLE_DEBUG
if (pixels_counter == 0)
pixels_counter = gdk_profiler_define_int_counter ("frame pixels", "Pixels drawn per frame");
-#endif
}
/**
@@ -383,12 +379,8 @@ gdk_draw_context_end_frame (GdkDrawContext *context)
GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context, priv->frame_region);
-#ifdef G_ENABLE_DEBUG
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_set_int_counter (pixels_counter,
- g_get_monotonic_time (),
- region_get_pixels (priv->frame_region));
-#endif
+ gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region));
g_clear_pointer (&priv->frame_region, cairo_region_destroy);
g_clear_object (&priv->surface->paint_context);
diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c
index 612a3c07ad..b884ca404c 100644
--- a/gdk/gdkframeclock.c
+++ b/gdk/gdkframeclock.c
@@ -673,7 +673,7 @@ _gdk_frame_clock_emit_before_paint (GdkFrameClock *frame_clock)
void
_gdk_frame_clock_emit_update (GdkFrameClock *frame_clock)
{
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
g_signal_emit (frame_clock, signals[UPDATE], 0);
@@ -684,7 +684,7 @@ _gdk_frame_clock_emit_update (GdkFrameClock *frame_clock)
void
_gdk_frame_clock_emit_layout (GdkFrameClock *frame_clock)
{
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
g_signal_emit (frame_clock, signals[LAYOUT], 0);
@@ -695,7 +695,7 @@ _gdk_frame_clock_emit_layout (GdkFrameClock *frame_clock)
void
_gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock)
{
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
g_signal_emit (frame_clock, signals[PAINT], 0);
@@ -795,9 +795,5 @@ _gdk_frame_clock_add_timings_to_profiler (GdkFrameClock *clock,
if (timings->presentation_time != 0)
gdk_profiler_add_mark (timings->presentation_time, 0, "presented window", NULL);
- if (timings->presentation_time != 0 || timings->drawn_time != 0)
- {
- gint64 time = timings->presentation_time != 0 ? timings->presentation_time : timings->drawn_time;
- gdk_profiler_set_counter (fps_counter, time, frame_clock_get_fps (clock));
- }
+ gdk_profiler_set_counter (fps_counter, frame_clock_get_fps (clock));
}
diff --git a/gdk/gdkframeclockidle.c b/gdk/gdkframeclockidle.c
index fe2de4667e..12498c1bbb 100644
--- a/gdk/gdkframeclockidle.c
+++ b/gdk/gdkframeclockidle.c
@@ -400,7 +400,7 @@ gdk_frame_clock_paint_idle (void *data)
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
gboolean skip_to_resume_events;
GdkFrameTimings *timings = NULL;
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
priv->paint_idle_id = 0;
priv->in_paint_idle = TRUE;
@@ -734,7 +734,7 @@ gdk_frame_clock_idle_freeze (GdkFrameClock *clock)
if (priv->freeze_count == 0)
{
if (GDK_PROFILER_IS_RUNNING)
- priv->freeze_time = g_get_monotonic_time ();
+ priv->freeze_time = GDK_PROFILER_CURRENT_TIME;
}
priv->freeze_count++;
@@ -766,8 +766,7 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
{
if (priv->freeze_time != 0)
{
- gdk_profiler_end_mark (priv->freeze_time,
- "frameclock frozen", NULL);
+ gdk_profiler_end_mark (priv->freeze_time, "frameclock frozen", NULL);
priv->freeze_time = 0;
}
}
diff --git a/gdk/gdkprofiler.c b/gdk/gdkprofiler.c
index e87fefbd50..9564c3fe7f 100644
--- a/gdk/gdkprofiler.c
+++ b/gdk/gdkprofiler.c
@@ -20,6 +20,8 @@
#include "config.h"
+#include "gdkprofilerprivate.h"
+
#include <sys/types.h>
#include <signal.h>
@@ -28,301 +30,126 @@
#endif
#include "gdkversionmacros.h"
-#include "gdkprofilerprivate.h"
#include "gdkframeclockprivate.h"
-#ifdef HAVE_SYSPROF_CAPTURE
-
-#include <sysprof-capture.h>
-
-static SysprofCaptureWriter *writer = NULL;
-static gboolean running = FALSE;
-
-static void
-profiler_stop (int s)
-{
- if (writer)
- sysprof_capture_writer_unref (writer);
-}
-
-void
-gdk_profiler_start (int fd)
-{
- if (writer)
- return;
-
- sysprof_clock_init ();
-
- if (fd == -1)
- {
- char *filename;
-
- filename = g_strdup_printf ("gtk.%d.syscap", getpid ());
- g_print ("Writing profiling data to %s\n", filename);
- writer = sysprof_capture_writer_new (filename, 16*1024);
- g_free (filename);
- }
- else if (fd > 2)
- writer = sysprof_capture_writer_new_from_fd (fd, 16*1024);
-
- if (writer)
- running = TRUE;
-
- atexit (G_CALLBACK (profiler_stop));
- signal (SIGTERM, profiler_stop);
-}
-
-void
-gdk_profiler_stop (void)
-{
- running = FALSE;
-}
gboolean
gdk_profiler_is_running (void)
{
- return running;
+#ifdef HAVE_SYSPROF
+ return sysprof_collector_is_active ();
+#else
+ return FALSE;
+#endif
}
void
-gdk_profiler_add_mark (gint64 start,
- guint64 duration,
- const char *name,
- const char *message)
+(gdk_profiler_add_mark) (gint64 begin_time,
+ gint64 duration,
+ const char *name,
+ const char *message)
{
- if (!running)
- return;
-
- sysprof_capture_writer_add_mark (writer,
- start * 1000L,
- -1, getpid (),
- duration * 1000L,
- "gtk", name, message);
+#ifdef HAVE_SYSPROF
+ sysprof_collector_mark (begin_time, duration, "gtk", name, message);
+#endif
}
-static void add_markvf (gint64 start,
- guint64 duration,
- const char *name,
- const char *format,
- va_list args) G_GNUC_PRINTF(4, 0);
-
-static void
-add_markvf (gint64 start,
- guint64 duration,
- const char *name,
- const char *format,
- va_list args)
+void
+(gdk_profiler_end_mark) (gint64 begin_time,
+ const char *name,
+ const char *message)
{
- char *message;
- message = g_strdup_vprintf (format, args);
- sysprof_capture_writer_add_mark (writer,
- start * 1000L,
- -1, getpid (),
- duration * 1000L,
- "gtk", name, message);
- g_free (message);
+#ifdef HAVE_SYSPROF
+ sysprof_collector_mark (begin_time, GDK_PROFILER_CURRENT_TIME - begin_time, "gtk", name, message);
+#endif
}
void
-gdk_profiler_add_markf (gint64 start,
- guint64 duration,
- const char *name,
- const char *format,
- ...)
+(gdk_profiler_add_markf) (gint64 begin_time,
+ gint64 duration,
+ const gchar *name,
+ const gchar *message_format,
+ ...)
{
+#ifdef HAVE_SYSPROF
va_list args;
-
- if (!running)
- return;
-
- va_start (args, format);
- add_markvf (start, duration, name, format, args);
+ va_start (args, message_format);
+ sysprof_collector_mark_vprintf (begin_time, duration, "gtk", name, message_format, args);
va_end (args);
+#endif /* HAVE_SYSPROF */
}
void
-gdk_profiler_end_mark (gint64 start,
- const char *name,
- const char *message)
-{
- if (!running)
- return;
-
- sysprof_capture_writer_add_mark (writer,
- start * 1000L,
- -1, getpid (),
- (g_get_monotonic_time () - start) * 1000L,
- "gtk", name, message);
-}
-
-void
-gdk_profiler_end_markf (gint64 start,
- const char *name,
- const char *format,
- ...)
+(gdk_profiler_end_markf) (gint64 begin_time,
+ const gchar *name,
+ const gchar *message_format,
+ ...)
{
+#ifdef HAVE_SYSPROF
va_list args;
-
- if (!running)
- return;
-
- va_start (args, format);
- add_markvf (start, g_get_monotonic_time () - start, name, format, args);
+ va_start (args, message_format);
+ sysprof_collector_mark_vprintf (begin_time, GDK_PROFILER_CURRENT_TIME - begin_time, "gtk", name,
message_format, args);
va_end (args);
+#endif /* HAVE_SYSPROF */
}
-
-static guint
+static inline guint
define_counter (const char *name,
const char *description,
int type)
{
+#ifdef HAVE_SYSPROF
SysprofCaptureCounter counter;
- if (!writer)
- return 0;
-
- counter.id = (guint) sysprof_capture_writer_request_counter (writer, 1);
+ counter.id = sysprof_collector_request_counters (1);
counter.type = type;
counter.value.vdbl = 0;
g_strlcpy (counter.category, "gtk", sizeof counter.category);
g_strlcpy (counter.name, name, sizeof counter.name);
g_strlcpy (counter.description, description, sizeof counter.name);
- sysprof_capture_writer_define_counters (writer,
- SYSPROF_CAPTURE_CURRENT_TIME,
- -1,
- getpid (),
- &counter,
- 1);
+ sysprof_collector_define_counters (&counter, 1);
return counter.id;
+#else
+ return 0;
+#endif
}
guint
-gdk_profiler_define_counter (const char *name,
- const char *description)
+(gdk_profiler_define_counter) (const char *name,
+ const char *description)
{
return define_counter (name, description, SYSPROF_CAPTURE_COUNTER_DOUBLE);
}
guint
-gdk_profiler_define_int_counter (const char *name,
- const char *description)
+(gdk_profiler_define_int_counter) (const char *name,
+ const char *description)
{
return define_counter (name, description, SYSPROF_CAPTURE_COUNTER_INT64);
}
void
-gdk_profiler_set_counter (guint id,
- gint64 time,
- double val)
+(gdk_profiler_set_counter) (guint id,
+ double val)
{
+#ifdef HAVE_SYSPROF
SysprofCaptureCounterValue value;
- if (!running)
- return;
-
value.vdbl = val;
- sysprof_capture_writer_set_counters (writer,
- time * 1000L,
- -1, getpid (),
- &id, &value, 1);
+ sysprof_collector_set_counters (&id, &value, 1);
+#endif
}
void
-gdk_profiler_set_int_counter (guint id,
- gint64 time,
- gint64 val)
+(gdk_profiler_set_int_counter) (guint id,
+ gint64 val)
{
+#ifdef HAVE_SYSPROF
SysprofCaptureCounterValue value;
- if (!running)
- return;
-
value.v64 = val;
- sysprof_capture_writer_set_counters (writer,
- time * 1000L,
- -1, getpid (),
- &id, &value, 1);
-}
-
-#else
-
-void
-gdk_profiler_start (int fd)
-{
-}
-
-void
-gdk_profiler_stop (void)
-{
-}
-
-gboolean
-gdk_profiler_is_running (void)
-{
- return FALSE;
-}
-
-void
-gdk_profiler_add_mark (gint64 start,
- guint64 duration,
- const char *name,
- const char *message)
-{
-}
-
-void
-gdk_profiler_add_markf (gint64 start,
- guint64 duration,
- const char *name,
- const char *format,
- ...)
-{
-}
-
-void
-gdk_profiler_end_mark (gint64 start,
- const char *name,
- const char *message)
-{
-}
-
-void
-gdk_profiler_end_markf (gint64 start,
- const char *name,
- const char *format,
- ...)
-{
-}
-
-guint
-gdk_profiler_define_counter (const char *name,
- const char *description)
-{
- return 0;
-}
-
-void
-gdk_profiler_set_counter (guint id,
- gint64 time,
- double value)
-{
-}
-
-guint
-gdk_profiler_define_int_counter (const char *name,
- const char *description)
-{
- return 0;
-}
-
-void
-gdk_profiler_set_int_counter (guint id,
- gint64 time,
- gint64 value)
-{
+ sysprof_collector_set_counters (&id, &value, 1);
+#endif
}
-
-#endif /* G_OS_WIN32 */
diff --git a/gdk/gdkprofilerprivate.h b/gdk/gdkprofilerprivate.h
index f06296d359..c515ab4871 100644
--- a/gdk/gdkprofilerprivate.h
+++ b/gdk/gdkprofilerprivate.h
@@ -21,52 +21,72 @@
#include "gdk/gdkframeclock.h"
#include "gdk/gdkdisplay.h"
-G_BEGIN_DECLS
-
/* Ensure we included config.h as needed for the below HAVE_SYSPROF_CAPTURE check */
#ifndef GETTEXT_PACKAGE
#error "config.h was not included before gdkprofilerprivate.h."
#endif
-/* We make this a macro you use as if (GDK_PROFILER_IS_RUNNING) because that
- * way we can ensure all the code is compiled out when not supported, and
- * we can add a G_UNLIKELY() for better codegen if it is.
- */
-#ifdef HAVE_SYSPROF_CAPTURE
-#define GDK_PROFILER_IS_RUNNING G_UNLIKELY (gdk_profiler_is_running ())
+#ifdef HAVE_SYSPROF
+#include <sysprof-capture.h>
+#endif
+
+G_BEGIN_DECLS
+
+#ifdef HAVE_SYSPROF
+#define GDK_PROFILER_IS_RUNNING (gdk_profiler_is_running ())
+#define GDK_PROFILER_CURRENT_TIME SYSPROF_CAPTURE_CURRENT_TIME
#else
-#define GDK_PROFILER_IS_RUNNING FALSE
+#define GDK_PROFILER_IS_RUNNING 0
+#define GDK_PROFILER_CURRENT_TIME 0
#endif
-void gdk_profiler_start (int fd);
-void gdk_profiler_stop (void);
gboolean gdk_profiler_is_running (void);
-void gdk_profiler_add_mark (gint64 start,
- guint64 duration,
- const char *name,
- const char *message);
-void gdk_profiler_add_markf (gint64 start,
- guint64 duration,
- const char *name,
- const char *format,
- ...) G_GNUC_PRINTF (4, 5);
-void gdk_profiler_end_mark (gint64 start,
- const char *name,
- const char *message);
-void gdk_profiler_end_markf (gint64 start,
- const char *name,
- const char *format,
- ...) G_GNUC_PRINTF (3, 4);
-guint gdk_profiler_define_counter (const char *name,
- const char *description);
-void gdk_profiler_set_counter (guint id,
- gint64 time,
- double value);
-guint gdk_profiler_define_int_counter (const char *name,
- const char *description);
-void gdk_profiler_set_int_counter (guint id,
- gint64 time,
- gint64 value);
+
+void gdk_profiler_add_mark (gint64 begin_time,
+ gint64 duration,
+ const gchar *name,
+ const gchar *message);
+void gdk_profiler_add_markf (gint64 begin_time,
+ gint64 duration,
+ const gchar *name,
+ const gchar *message_format,
+ ...) G_GNUC_PRINTF (4, 5);
+void gdk_profiler_end_mark (gint64 begin_time,
+ const gchar *name,
+ const gchar *message);
+void gdk_profiler_end_markf (gint64 begin_time,
+ const gchar *name,
+ const gchar *message_format,
+ ...) G_GNUC_PRINTF (3, 4);
+
+guint gdk_profiler_define_counter (const char *name,
+ const char *description);
+guint gdk_profiler_define_int_counter (const char *name,
+ const char *description);
+void gdk_profiler_set_counter (guint id,
+ double value);
+void gdk_profiler_set_int_counter (guint id,
+ gint64 value);
+
+#ifndef HAVE_SYSPROF
+#define gdk_profiler_add_mark(b, d, n, m)
+#define gdk_profiler_end_mark(b, n, m)
+/* Optimise the whole call out */
+#if defined(G_HAVE_ISO_VARARGS)
+#define gdk_profiler_add_markf(b, d, n, m, ...)
+#define gdk_profiler_end_markf(b, n, m, ...)
+#elif defined(G_HAVE_GNUC_VARARGS)
+#define gdk_profiler_add_markf(b, d, n, m...)
+#define gdk_profiler_end_markf(b, n, m...)
+#else
+/* no varargs macro support; the call will have to be optimised out by the compiler */
+#endif
+
+#define gdk_profiler_define_counter(n, d) 0
+#define gdk_profiler_define_int_counter(n, d) 0
+#define gdk_profiler_set_counter(i, v)
+#define gdk_profiler_set_int_counter(i, v)
+#endif
G_END_DECLS
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 2145736901..c122e044e9 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2679,16 +2679,17 @@ check_autohide (GdkEvent *event)
return FALSE;
}
-static void
+static inline void
add_event_mark (GdkEvent *event,
- gint64 time,
- guint64 duration)
+ gint64 time)
{
+#ifdef HAVE_SYSPROF
char *message = NULL;
const char *kind;
GEnumClass *class;
GEnumValue *value;
GdkEventType event_type;
+ gint64 end_time = GDK_PROFILER_CURRENT_TIME;
event_type = gdk_event_get_event_type (event);
class = g_type_class_ref (GDK_TYPE_EVENT_TYPE);
@@ -2772,15 +2773,16 @@ add_event_mark (GdkEvent *event,
break;
}
- gdk_profiler_add_mark (time, duration, "event", message ? message : kind);
+ gdk_profiler_add_mark (time, end_time - time, "event", message ? message : kind);
g_free (message);
+#endif
}
gboolean
gdk_surface_handle_event (GdkEvent *event)
{
- gint64 begin_time = g_get_monotonic_time ();
+ gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
gboolean handled = FALSE;
if (check_autohide (event))
@@ -2801,7 +2803,7 @@ gdk_surface_handle_event (GdkEvent *event)
}
if (GDK_PROFILER_IS_RUNNING)
- add_event_mark (event, begin_time, g_get_monotonic_time () - begin_time);
+ add_event_mark (event, begin_time);
return handled;
}
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 6d19b8dad5..26eb7c96e8 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -1109,7 +1109,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
guint size;
const char *name;
GValue v = G_VALUE_INIT;
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
g_assert (display_wayland);
g_assert (display_wayland->shm);
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 0b9dbb5da7..8ed0bb1d49 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -239,7 +239,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
- gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "swap buffers");
+ gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "swap buffers");
if (display_wayland->have_egl_swap_buffers_with_damage)
{
int i, j, n_rects = cairo_region_num_rectangles (painted);
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index b788be2ce7..a444a4ee44 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -504,7 +504,7 @@ frame_callback (void *data,
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
GdkFrameTimings *timings;
- gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "frame event");
+ gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "frame event");
GDK_DISPLAY_NOTE (GDK_DISPLAY (display_wayland), EVENTS, g_message ("frame %p", surface));
wl_callback_destroy (callback);
@@ -640,7 +640,7 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
* before we need to stage any changes, then we can take it back and
* use it again.
*/
- gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "surface commit");
+ gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
impl->pending_commit = FALSE;
@@ -1801,7 +1801,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
maybe_set_gtk_surface_dbus_properties (surface);
maybe_set_gtk_surface_modal (surface);
- gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "surface commit");
+ gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
}
@@ -2558,7 +2558,7 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
}
}
- gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "surface commit");
+ gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
if (GDK_IS_POPUP (surface))
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 269ae28829..7534167673 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -843,7 +843,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
_gdk_x11_surface_grab_check_unmap (surface, xevent->xany.serial);
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_markf (g_get_monotonic_time (), 0, "unmapped window", "0x%lx", GDK_SURFACE_XID
(surface));
+ gdk_profiler_add_markf (GDK_PROFILER_CURRENT_TIME, 0, "unmapped window", "0x%lx",
GDK_SURFACE_XID (surface));
}
break;
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index eb503ecdd5..da64fd6357 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -3069,7 +3069,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
GError **error)
{
GskGLRenderer *self = GSK_GL_RENDERER (renderer);
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
/* If we didn't get a GdkGLContext before realization, try creating
* one now, for our exclusive use.
diff --git a/gsk/vulkan/gskvulkanrenderer.c b/gsk/vulkan/gskvulkanrenderer.c
index cd91c90820..031ca89329 100644
--- a/gsk/vulkan/gskvulkanrenderer.c
+++ b/gsk/vulkan/gskvulkanrenderer.c
@@ -215,10 +215,8 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
{
gdk_profiler_add_mark (start_time, cpu_time, "render", "");
gdk_profiler_set_int_counter (texture_pixels_counter,
- start_time + cpu_time,
gsk_profiler_counter_get (profiler,
self->profile_counters.texture_pixels));
gdk_profiler_set_int_counter (fallback_pixels_counter,
- start_time + cpu_time,
gsk_profiler_counter_get (profiler,
self->profile_counters.fallback_pixels));
}
#endif
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index 4a5c473685..c9ba1bb43b 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -252,14 +252,14 @@ gtk_application_startup (GApplication *g_application)
{
GtkApplication *application = GTK_APPLICATION (g_application);
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
gint64 before2;
G_APPLICATION_CLASS (gtk_application_parent_class)->startup (g_application);
gtk_action_muxer_insert (priv->muxer, "app", G_ACTION_GROUP (application));
- before2 = g_get_monotonic_time ();
+ before2 = GDK_PROFILER_CURRENT_TIME;
gtk_init ();
if (GDK_PROFILER_IS_RUNNING)
gdk_profiler_end_mark (before2, "gtk init", NULL);
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index e222813e68..2ae5202215 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -2168,7 +2168,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
const char * domain;
ParserData data;
GSList *l;
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
/* Store the original domain so that interface domain attribute can be
* applied for the builder and the original domain can be restored after
@@ -2246,7 +2246,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
if (GDK_PROFILER_IS_RUNNING)
{
- guint64 after = g_get_monotonic_time ();
+ guint64 after = GDK_PROFILER_CURRENT_TIME;
if (after - before > 500)
gdk_profiler_add_mark (before, after - before, "builder load", filename);
}
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index b8522a1e37..d14196f9d9 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -1364,7 +1364,7 @@ gtk_css_node_validate (GtkCssNode *cssnode)
{
GtkCountingBloomFilter filter = GTK_COUNTING_BLOOM_FILTER_INIT;
gint64 timestamp;
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
g_assert (cssnode->parent == NULL);
@@ -1374,10 +1374,9 @@ gtk_css_node_validate (GtkCssNode *cssnode)
if (GDK_PROFILER_IS_RUNNING)
{
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "css validation", "");
- gdk_profiler_set_int_counter (invalidated_nodes_counter, after, invalidated_nodes);
- gdk_profiler_set_int_counter (created_styles_counter, after, created_styles);
+ gdk_profiler_end_mark (before, "css validation", "");
+ gdk_profiler_set_int_counter (invalidated_nodes_counter, invalidated_nodes);
+ gdk_profiler_set_int_counter (created_styles_counter, created_styles);
invalidated_nodes = 0;
created_styles = 0;
}
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 8b4e710b93..c606f21d3f 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -978,7 +978,7 @@ gtk_css_provider_postprocess (GtkCssProvider *css_provider)
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
GtkCssSelectorTreeBuilder *builder;
guint i;
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
g_array_sort (priv->rulesets, gtk_css_provider_compare_rule);
@@ -1020,7 +1020,7 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
GFile *file,
GBytes *bytes)
{
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
if (bytes == NULL)
{
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index 85078a8434..182a14fb63 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -571,9 +571,9 @@ populate_emoji_chooser (gpointer data)
{
GtkEmojiChooser *chooser = data;
GVariant *item;
- guint64 start, now;
+ gint64 start, now;
- start = g_get_monotonic_time ();
+ start = GDK_PROFILER_CURRENT_TIME;
if (!chooser->data)
{
@@ -614,7 +614,7 @@ populate_emoji_chooser (gpointer data)
add_emoji (chooser->box, FALSE, item, 0, chooser);
g_variant_unref (item);
- now = g_get_monotonic_time ();
+ now = GDK_PROFILER_CURRENT_TIME;
if (now > start + 8000)
{
if (GDK_PROFILER_IS_RUNNING)
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index cd1010376d..8c94a47fad 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2074,7 +2074,7 @@ ensure_valid_themes (GtkIconTheme *self,
if (non_blocking)
return FALSE;
- before = g_get_monotonic_time ();
+ before = GDK_PROFILER_CURRENT_TIME;
load_themes (self);
@@ -3720,7 +3720,7 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
if (icon->texture)
return;
- before = g_get_monotonic_time ();
+ before = GDK_PROFILER_CURRENT_TIME;
/* This is the natural pixel size for the requested icon size + scale in this directory.
* We precalculate this so we can use it as a rasterization size for svgs.
@@ -3825,7 +3825,7 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
if (GDK_PROFILER_IS_RUNNING)
{
- guint64 end = g_get_monotonic_time ();
+ gint64 end = GDK_PROFILER_CURRENT_TIME;
/* Don't report quick (< 0.5 msec) parses */
if (end - before > 500 || !in_thread)
gdk_profiler_add_markf (before, (end - before), in_thread ? "icon load (thread)" : "icon load" ,
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index 65eaf25dbb..da559f7144 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -247,7 +247,7 @@ init_compose_table_thread_cb (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- guint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
if (g_task_return_error_if_cancelled (task))
return;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 771bae0841..7ee91bcf93 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10951,7 +10951,7 @@ gtk_widget_render (GtkWidget *widget,
GskRenderer *renderer;
GskRenderNode *root;
double x, y;
- gint64 before_snapshot = g_get_monotonic_time ();
+ gint64 before_snapshot = GDK_PROFILER_CURRENT_TIME;
gint64 before_render = 0;
if (!GTK_IS_NATIVE (widget))
@@ -10969,7 +10969,7 @@ gtk_widget_render (GtkWidget *widget,
if (GDK_PROFILER_IS_RUNNING)
{
- before_render = g_get_monotonic_time ();
+ before_render = GDK_PROFILER_CURRENT_TIME;
gdk_profiler_add_mark (before_snapshot, (before_render - before_snapshot), "widget snapshot", "");
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5807205741..1e4250848f 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1873,7 +1873,7 @@ static void
gtk_window_native_check_resize (GtkNative *native)
{
GtkWidget *widget = GTK_WIDGET (native);
- gint64 before = g_get_monotonic_time ();
+ gint64 before = GDK_PROFILER_CURRENT_TIME;
if (!_gtk_widget_get_alloc_needed (widget))
gtk_widget_ensure_allocate (widget);
diff --git a/meson.build b/meson.build
index d193835a75..7b32667bf9 100644
--- a/meson.build
+++ b/meson.build
@@ -718,7 +718,7 @@ if profiler_enabled
fallback: ['sysprof', 'libsysprof_capture_dep'],
)
if profiler_dep.found()
- cdata.set('HAVE_SYSPROF_CAPTURE', profiler_dep.found())
+ cdata.set('HAVE_SYSPROF', profiler_dep.found())
else
error('Profiler support not found, but was explicitly requested.')
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]