[gtk/wip/chergert/sysprof-3] profiler: port GdkProfiler to sysprof-3
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/sysprof-3] profiler: port GdkProfiler to sysprof-3
- Date: Thu, 30 May 2019 02:03:16 +0000 (UTC)
commit 3a0beeadc5881a19a66bfcff7174fdad6f906158
Author: Christian Hergert <chergert redhat com>
Date: Wed May 29 19:02:30 2019 -0700
profiler: port GdkProfiler to sysprof-3
This uses the new sysprof-3 ABI to implement the capture writer. It also
uses the statically linked libsysprof-capture-3.a that is provided with
Sysprof for the capture writing to ensure that we do not leak any symbols
nor depend on any additional libraries.
The GTK_TRACE_FD can be used to pass a FD for tracing into Gtk. Sysprof
uses this when the Gtk instrument is selected for recording.
config.h.meson | 3 +
gdk/capture/sp-capture-types.h | 224 --------
gdk/capture/sp-capture-writer.c | 1123 ---------------------------------------
gdk/capture/sp-capture-writer.h | 132 -----
gdk/capture/sp-clock.c | 52 --
gdk/capture/sp-clock.h | 55 --
gdk/gdk.c | 4 +-
gdk/gdkprofiler.c | 64 +--
gdk/meson.build | 13 +-
meson.build | 11 +
meson_options.txt | 2 +
11 files changed, 56 insertions(+), 1627 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 436e1a1501..e52badaede 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -130,6 +130,9 @@
/* Define to 1 if you have the <sys/param.h> header file. */
#mesondefine HAVE_SYS_PARAM_H
+#
+/* Have the sysprof-capture library */
+#mesondefine HAVE_SYSPROF_CAPTURE
/* 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 bc03cbad99..c3c58b053b 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -213,8 +213,8 @@ gdk_pre_parse (void)
(GDebugKey *) gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
- if (g_getenv ("SYSPROF_TRACE_FD"))
- gdk_profiler_start (atoi (g_getenv ("SYSPROF_TRACE_FD")));
+ 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);
}
diff --git a/gdk/gdkprofiler.c b/gdk/gdkprofiler.c
index 15a54ad05f..93055ac9a8 100644
--- a/gdk/gdkprofiler.c
+++ b/gdk/gdkprofiler.c
@@ -30,18 +30,18 @@
#include "gdkprofilerprivate.h"
#include "gdkframeclockprivate.h"
-#ifndef G_OS_WIN32
+#ifdef HAVE_SYSPROF_CAPTURE
-#include "capture/sp-capture-writer.h"
+#include <sysprof-capture.h>
-static SpCaptureWriter *writer = NULL;
+static SysprofCaptureWriter *writer = NULL;
static gboolean running = FALSE;
static void
profiler_stop (void)
{
if (writer)
- sp_capture_writer_unref (writer);
+ sysprof_capture_writer_unref (writer);
}
void
@@ -50,7 +50,7 @@ gdk_profiler_start (int fd)
if (writer)
return;
- sp_clock_init ();
+ sysprof_clock_init ();
if (fd == -1)
{
@@ -58,11 +58,11 @@ gdk_profiler_start (int fd)
filename = g_strdup_printf ("gtk.%d.syscap", getpid ());
g_print ("Writing profiling data to %s\n", filename);
- writer = sp_capture_writer_new (filename, 16*1024);
+ writer = sysprof_capture_writer_new (filename, 16*1024);
g_free (filename);
}
else if (fd > 2)
- writer = sp_capture_writer_new_from_fd (fd, 16*1024);
+ writer = sysprof_capture_writer_new_from_fd (fd, 16*1024);
if (writer)
running = TRUE;
@@ -91,11 +91,11 @@ gdk_profiler_add_mark (gint64 start,
if (!running)
return;
- sp_capture_writer_add_mark (writer,
- start,
- -1, getpid (),
- duration,
- "gtk", name, message);
+ sysprof_capture_writer_add_mark (writer,
+ start,
+ -1, getpid (),
+ duration,
+ "gtk", name, message);
}
static guint
@@ -103,24 +103,24 @@ define_counter (const char *name,
const char *description,
int type)
{
- SpCaptureCounter counter;
+ SysprofCaptureCounter counter;
if (!writer)
return 0;
- counter.id = (guint) sp_capture_writer_request_counter (writer, 1);
+ counter.id = (guint) sysprof_capture_writer_request_counter (writer, 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);
- sp_capture_writer_define_counters (writer,
- SP_CAPTURE_CURRENT_TIME,
- -1,
- getpid (),
- &counter,
- 1);
+ sysprof_capture_writer_define_counters (writer,
+ SYSPROF_CAPTURE_CURRENT_TIME,
+ -1,
+ getpid (),
+ &counter,
+ 1);
return counter.id;
}
@@ -129,14 +129,14 @@ guint
gdk_profiler_define_counter (const char *name,
const char *description)
{
- return define_counter (name, description, SP_CAPTURE_COUNTER_DOUBLE);
+ return define_counter (name, description, SYSPROF_CAPTURE_COUNTER_DOUBLE);
}
guint
gdk_profiler_define_int_counter (const char *name,
const char *description)
{
- return define_counter (name, description, SP_CAPTURE_COUNTER_INT64);
+ return define_counter (name, description, SYSPROF_CAPTURE_COUNTER_INT64);
}
void
@@ -144,16 +144,16 @@ gdk_profiler_set_counter (guint id,
gint64 time,
double val)
{
- SpCaptureCounterValue value;
+ SysprofCaptureCounterValue value;
if (!running)
return;
value.vdbl = val;
- sp_capture_writer_set_counters (writer,
- time,
- -1, getpid (),
- &id, &value, 1);
+ sysprof_capture_writer_set_counters (writer,
+ time,
+ -1, getpid (),
+ &id, &value, 1);
}
void
@@ -161,16 +161,16 @@ gdk_profiler_set_int_counter (guint id,
gint64 time,
gint64 val)
{
- SpCaptureCounterValue value;
+ SysprofCaptureCounterValue value;
if (!running)
return;
value.v64 = val;
- sp_capture_writer_set_counters (writer,
- time,
- -1, getpid (),
- &id, &value, 1);
+ sysprof_capture_writer_set_counters (writer,
+ time,
+ -1, getpid (),
+ &id, &value, 1);
}
#else
diff --git a/gdk/meson.build b/gdk/meson.build
index 7380961ccf..21c38df33e 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -47,13 +47,6 @@ gdk_public_sources = files([
'gdkprofiler.c'
])
-if not win32_enabled
- gdk_public_sources += files([
- 'capture/sp-capture-writer.c',
- 'capture/sp-clock.c'
- ])
-endif
-
gdk_public_headers = files([
'gdk-autocleanup.h',
'gdk.h',
@@ -188,6 +181,12 @@ gdk_deps = [
vulkan_dep,
]
+if profiler_enabled
+ if profiler_dep.found()
+ gdk_deps += [profiler_dep]
+ endif
+endif
+
# add generated gdk sources
gdk_sources += [
gdkconfig,
diff --git a/meson.build b/meson.build
index 97cc7fdf28..34cf3cfcc5 100644
--- a/meson.build
+++ b/meson.build
@@ -666,6 +666,16 @@ if cloudproviders_enabled
endif
endif
+profiler_enabled = get_option('profiler')
+if profiler_enabled
+ profiler_dep = dependency('sysprof-capture-3', static: true, required: true)
+ if profiler_dep.found()
+ cdata.set('HAVE_SYSPROF_CAPTURE', profiler_dep.found())
+ else
+ error('Profiler support not found, but was explicitly requested.')
+ endif
+endif
+
graphene_dep_type = graphene_dep.type_name()
if graphene_dep_type == 'pkgconfig'
graphene_has_sse2 = graphene_dep.get_pkgconfig_variable('graphene_has_sse2') == '1'
@@ -811,6 +821,7 @@ summary = [
' Vulkan support: @0@'.format(have_vulkan),
' Cloud support: @0@'.format(get_option('cloudproviders')),
' Colord support: @0@'.format(get_option('colord')),
+ ' Profiler: @0@'.format(get_option('profiler')),
' Introspection: @0@'.format(get_option('introspection')),
' Documentation: @0@'.format(get_option('documentation')),
' Man pages: @0@'.format(get_option('man-pages')),
diff --git a/meson_options.txt b/meson_options.txt
index a189ee2cba..20dc5d0338 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -21,6 +21,8 @@ option('xinerama', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto
description : 'Enable support for the Xinerama extension')
option('cloudproviders', type: 'boolean', value: false,
description : 'Enable the cloudproviders support')
+option('profiler', type: 'boolean', value: false,
+ description : 'Enable profiler support')
# Print backends
option('print-backends', type : 'string', value : 'cups,file',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]