mirror of
https://github.com/brl/mutter.git
synced 2025-04-15 14:49:39 +00:00
context: Start persistent profiling via command line argument
Persistent profiling was started via an env var, but that's rather hard to discover and remember without grepping; change to use a command line argument. The profiler is started early, even during (though late in) configuration, but configuration should ideally be instant and pointless to configure. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
This commit is contained in:
parent
e16d683721
commit
1ca76e9b9c
@ -73,6 +73,7 @@ typedef struct _MetaContextMainOptions
|
|||||||
#ifdef HAVE_NATIVE_BACKEND
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
GList *virtual_monitor_infos;
|
GList *virtual_monitor_infos;
|
||||||
#endif
|
#endif
|
||||||
|
char *trace_file;
|
||||||
} MetaContextMainOptions;
|
} MetaContextMainOptions;
|
||||||
|
|
||||||
struct _MetaContextMain
|
struct _MetaContextMain
|
||||||
@ -298,6 +299,10 @@ meta_context_main_configure (MetaContext *context,
|
|||||||
context_main->options.sm.client_id = g_strdup (desktop_autostart_id);
|
context_main->options.sm.client_id = g_strdup (desktop_autostart_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PROFILER
|
||||||
|
meta_context_set_trace_file (context, context_main->options.trace_file);
|
||||||
|
#endif
|
||||||
|
|
||||||
g_unsetenv ("DESKTOP_AUTOSTART_ID");
|
g_unsetenv ("DESKTOP_AUTOSTART_ID");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -662,6 +667,12 @@ meta_context_main_add_option_entries (MetaContextMain *context_main)
|
|||||||
N_("Run with X11 backend")
|
N_("Run with X11 backend")
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
"profile", 0, 0, G_OPTION_ARG_FILENAME,
|
||||||
|
&context_main->options.trace_file,
|
||||||
|
N_("Profile performance using trace instrumentation"),
|
||||||
|
"FILE"
|
||||||
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,6 +86,9 @@ gboolean meta_context_is_x11_sync (MetaContext *context);
|
|||||||
#ifdef HAVE_PROFILER
|
#ifdef HAVE_PROFILER
|
||||||
MetaProfiler *
|
MetaProfiler *
|
||||||
meta_context_get_profiler (MetaContext *context);
|
meta_context_get_profiler (MetaContext *context);
|
||||||
|
|
||||||
|
void meta_context_set_trace_file (MetaContext *context,
|
||||||
|
const char *trace_file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* META_CONTEXT_PRIVATE_H */
|
#endif /* META_CONTEXT_PRIVATE_H */
|
||||||
|
@ -98,6 +98,7 @@ typedef struct _MetaContextPrivate
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PROFILER
|
#ifdef HAVE_PROFILER
|
||||||
|
char *trace_file;
|
||||||
MetaProfiler *profiler;
|
MetaProfiler *profiler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -292,6 +293,15 @@ meta_context_get_profiler (MetaContext *context)
|
|||||||
|
|
||||||
return priv->profiler;
|
return priv->profiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_context_set_trace_file (MetaContext *context,
|
||||||
|
const char *trace_file)
|
||||||
|
{
|
||||||
|
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
||||||
|
|
||||||
|
priv->trace_file = g_strdup (trace_file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -343,6 +353,10 @@ meta_context_configure (MetaContext *context,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PROFILER
|
||||||
|
priv->profiler = meta_profiler_new (priv->trace_file);
|
||||||
|
#endif
|
||||||
|
|
||||||
compositor_type = meta_context_get_compositor_type (context);
|
compositor_type = meta_context_get_compositor_type (context);
|
||||||
switch (compositor_type)
|
switch (compositor_type)
|
||||||
{
|
{
|
||||||
@ -739,6 +753,7 @@ meta_context_finalize (GObject *object)
|
|||||||
|
|
||||||
#ifdef HAVE_PROFILER
|
#ifdef HAVE_PROFILER
|
||||||
g_clear_object (&priv->profiler);
|
g_clear_object (&priv->profiler);
|
||||||
|
g_clear_pointer (&priv->trace_file, g_free);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_clear_pointer (&priv->gnome_wm_keybindings, g_free);
|
g_clear_pointer (&priv->gnome_wm_keybindings, g_free);
|
||||||
@ -801,10 +816,6 @@ meta_context_init (MetaContext *context)
|
|||||||
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_PROFILER
|
|
||||||
priv->profiler = meta_profiler_new ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
priv->plugin_gtype = G_TYPE_NONE;
|
priv->plugin_gtype = G_TYPE_NONE;
|
||||||
priv->gnome_wm_keybindings = g_strdup ("Mutter");
|
priv->gnome_wm_keybindings = g_strdup ("Mutter");
|
||||||
|
|
||||||
|
@ -265,8 +265,6 @@ meta_profiler_class_init (MetaProfilerClass *klass)
|
|||||||
static void
|
static void
|
||||||
meta_profiler_init (MetaProfiler *self)
|
meta_profiler_init (MetaProfiler *self)
|
||||||
{
|
{
|
||||||
const char *env_trace_file;
|
|
||||||
|
|
||||||
g_mutex_init (&self->mutex);
|
g_mutex_init (&self->mutex);
|
||||||
self->cancellable = g_cancellable_new ();
|
self->cancellable = g_cancellable_new ();
|
||||||
|
|
||||||
@ -274,9 +272,16 @@ meta_profiler_init (MetaProfiler *self)
|
|||||||
self->cancellable,
|
self->cancellable,
|
||||||
on_bus_acquired_cb,
|
on_bus_acquired_cb,
|
||||||
self);
|
self);
|
||||||
|
}
|
||||||
|
|
||||||
env_trace_file = g_getenv ("MUTTER_DEBUG_TRACE_FILE");
|
MetaProfiler *
|
||||||
if (env_trace_file && env_trace_file[0])
|
meta_profiler_new (const char *trace_file)
|
||||||
|
{
|
||||||
|
MetaProfiler *profiler;
|
||||||
|
|
||||||
|
profiler = g_object_new (META_TYPE_PROFILER, NULL);
|
||||||
|
|
||||||
|
if (trace_file)
|
||||||
{
|
{
|
||||||
GMainContext *main_context = g_main_context_default ();
|
GMainContext *main_context = g_main_context_default ();
|
||||||
const char *group_name;
|
const char *group_name;
|
||||||
@ -286,15 +291,11 @@ meta_profiler_init (MetaProfiler *self)
|
|||||||
|
|
||||||
cogl_set_tracing_enabled_on_thread (main_context,
|
cogl_set_tracing_enabled_on_thread (main_context,
|
||||||
group_name,
|
group_name,
|
||||||
env_trace_file);
|
trace_file);
|
||||||
self->persistent = TRUE;
|
profiler->persistent = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MetaProfiler *
|
return profiler;
|
||||||
meta_profiler_new (void)
|
|
||||||
{
|
|
||||||
return g_object_new (META_TYPE_PROFILER, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -34,7 +34,7 @@ G_DECLARE_FINAL_TYPE (MetaProfiler,
|
|||||||
PROFILER,
|
PROFILER,
|
||||||
MetaDBusSysprof3ProfilerSkeleton)
|
MetaDBusSysprof3ProfilerSkeleton)
|
||||||
|
|
||||||
MetaProfiler * meta_profiler_new (void);
|
MetaProfiler * meta_profiler_new (const char *trace_file);
|
||||||
|
|
||||||
void meta_profiler_register_thread (MetaProfiler *profiler,
|
void meta_profiler_register_thread (MetaProfiler *profiler,
|
||||||
GMainContext *main_context,
|
GMainContext *main_context,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user