From e92e4fe64d6627897f970d3c68c624f2ace4e066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 26 Oct 2022 12:11:42 +0200 Subject: [PATCH] thread: Register with profiler This means we can add COGL_TRACE*() instrumentation that is grouped correctly in sysprof. If kernel threading is enabled, they will end up in a "Compositor (KMS thread)" group (ignoring translations). Part-of: --- src/backends/native/meta-thread.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-thread.c b/src/backends/native/meta-thread.c index 4fbd13a37..bc192b42a 100644 --- a/src/backends/native/meta-thread.c +++ b/src/backends/native/meta-thread.c @@ -294,10 +294,20 @@ thread_impl_func (gpointer user_data) { MetaThread *thread = META_THREAD (user_data); MetaThreadPrivate *priv = meta_thread_get_instance_private (thread); + MetaContext *context = meta_backend_get_context (priv->backend); + MetaThreadImpl *impl = priv->impl; +#ifdef HAVE_PROFILER + GMainContext *thread_context = meta_thread_impl_get_main_context (impl); + MetaProfiler *profiler = meta_context_get_profiler (context); +#endif g_mutex_lock (&priv->kernel.init_mutex); g_mutex_unlock (&priv->kernel.init_mutex); +#ifdef HAVE_PROFILER + meta_profiler_register_thread (profiler, thread_context, priv->name); +#endif + if (priv->wants_realtime) { g_autoptr (GError) error = NULL; @@ -313,7 +323,11 @@ thread_impl_func (gpointer user_data) } } - meta_thread_impl_run (priv->impl); + meta_thread_impl_run (impl); + +#ifdef HAVE_PROFILER + meta_profiler_unregister_thread (profiler, thread_context); +#endif return GINT_TO_POINTER (TRUE); }