From 058f14a7cd5b57f1e2f1218bdb76c563b57d5373 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 20 Jul 2023 17:31:36 -0700 Subject: [PATCH] sysprof: generate summaries and display in utility pane --- src/sysprof/sysprof-callgraph-view-private.h | 1 + src/sysprof/sysprof-callgraph-view.c | 56 ++++++++++++- src/sysprof/sysprof-samples-section.c | 1 + src/sysprof/sysprof-samples-section.ui | 87 ++++++++++++++++++-- 4 files changed, 136 insertions(+), 9 deletions(-) diff --git a/src/sysprof/sysprof-callgraph-view-private.h b/src/sysprof/sysprof-callgraph-view-private.h index fa3076ae..55443808 100644 --- a/src/sysprof/sysprof-callgraph-view-private.h +++ b/src/sysprof/sysprof-callgraph-view-private.h @@ -37,6 +37,7 @@ struct _SysprofCallgraphView GSignalGroup *traceables_signals; GListModel *traceables; GListModel *utility_traceables; + GListModel *utility_summary; GtkColumnView *callers_column_view; GtkColumnView *descendants_column_view; diff --git a/src/sysprof/sysprof-callgraph-view.c b/src/sysprof/sysprof-callgraph-view.c index 1c98c35b..1fa37221 100644 --- a/src/sysprof/sysprof-callgraph-view.c +++ b/src/sysprof/sysprof-callgraph-view.c @@ -38,6 +38,7 @@ enum { PROP_HIDE_SYSTEM_LIBRARIES, PROP_INCLUDE_THREADS, PROP_TRACEABLES, + PROP_UTILITY_SUMMARY, PROP_UTILITY_TRACEABLES, N_PROPS }; @@ -67,6 +68,17 @@ sysprof_callgraph_view_set_utility_traceables (SysprofCallgraphView *self, g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UTILITY_TRACEABLES]); } +static void +sysprof_callgraph_view_set_utility_summary (SysprofCallgraphView *self, + GListModel *model) +{ + g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); + g_assert (!model || G_IS_LIST_MODEL (model)); + + if (g_set_object (&self->utility_summary, model)) + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UTILITY_SUMMARY]); +} + static void sysprof_callgraph_view_set_descendants (SysprofCallgraphView *self, GListModel *model) @@ -167,6 +179,25 @@ sysprof_callgraph_view_list_traceables_cb (GObject *object, sysprof_callgraph_view_set_utility_traceables (self, model); } +static void +sysprof_callgraph_view_summarize_cb (GObject *object, + GAsyncResult *result, + gpointer user_data) +{ + SysprofCallgraphFrame *frame = (SysprofCallgraphFrame *)object; + g_autoptr(SysprofCallgraphView) self = user_data; + g_autoptr(GListModel) model = NULL; + g_autoptr(GError) error = NULL; + + g_assert (SYSPROF_IS_CALLGRAPH_FRAME (frame)); + g_assert (G_IS_ASYNC_RESULT (result)); + g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); + + model = sysprof_callgraph_frame_summarize_finish (frame, result, &error); + + sysprof_callgraph_view_set_utility_summary (self, model); +} + static void descendants_selection_changed_cb (SysprofCallgraphView *self, guint position, @@ -179,16 +210,23 @@ descendants_selection_changed_cb (SysprofCallgraphView *self, g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); g_assert (GTK_IS_SINGLE_SELECTION (single)); + sysprof_callgraph_view_set_utility_summary (self, NULL); sysprof_callgraph_view_set_utility_traceables (self, NULL); if ((object = gtk_single_selection_get_selected_item (single)) && GTK_IS_TREE_LIST_ROW (object) && (item = gtk_tree_list_row_get_item (GTK_TREE_LIST_ROW (object))) && SYSPROF_IS_CALLGRAPH_FRAME (item)) - sysprof_callgraph_frame_list_traceables_async (SYSPROF_CALLGRAPH_FRAME (item), - NULL, - sysprof_callgraph_view_list_traceables_cb, - g_object_ref (self)); + { + sysprof_callgraph_frame_summarize_async (SYSPROF_CALLGRAPH_FRAME (item), + NULL, + sysprof_callgraph_view_summarize_cb, + g_object_ref (self)); + sysprof_callgraph_frame_list_traceables_async (SYSPROF_CALLGRAPH_FRAME (item), + NULL, + sysprof_callgraph_view_list_traceables_cb, + g_object_ref (self)); + } } static void @@ -305,6 +343,7 @@ sysprof_callgraph_view_dispose (GObject *object) g_clear_object (&self->callgraph); g_clear_object (&self->document); g_clear_object (&self->traceables); + g_clear_object (&self->utility_summary); g_clear_object (&self->utility_traceables); G_OBJECT_CLASS (sysprof_callgraph_view_parent_class)->dispose (object); @@ -348,6 +387,10 @@ sysprof_callgraph_view_get_property (GObject *object, g_value_set_object (value, sysprof_callgraph_view_get_traceables (self)); break; + case PROP_UTILITY_SUMMARY: + g_value_set_object (value, self->utility_summary); + break; + case PROP_UTILITY_TRACEABLES: g_value_set_object (value, self->utility_traceables); break; @@ -441,6 +484,11 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) G_TYPE_LIST_MODEL, (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties[PROP_UTILITY_SUMMARY] = + g_param_spec_object ("utility-summary", NULL, NULL, + G_TYPE_LIST_MODEL, + (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties[PROP_UTILITY_TRACEABLES] = g_param_spec_object ("utility-traceables", NULL, NULL, G_TYPE_LIST_MODEL, diff --git a/src/sysprof/sysprof-samples-section.c b/src/sysprof/sysprof-samples-section.c index c876cbf4..3cbf54da 100644 --- a/src/sysprof/sysprof-samples-section.c +++ b/src/sysprof/sysprof-samples-section.c @@ -82,6 +82,7 @@ sysprof_samples_section_class_init (SysprofSamplesSectionClass *klass) g_type_ensure (SYSPROF_TYPE_TRACEABLES_UTILITY); g_type_ensure (SYSPROF_TYPE_VALUE_AXIS); g_type_ensure (SYSPROF_TYPE_WEIGHTED_CALLGRAPH_VIEW); + g_type_ensure (SYSPROF_TYPE_CATEGORY_SUMMARY); } static void diff --git a/src/sysprof/sysprof-samples-section.ui b/src/sysprof/sysprof-samples-section.ui index e37b6521..e8416292 100644 --- a/src/sysprof/sysprof-samples-section.ui +++ b/src/sysprof/sysprof-samples-section.ui @@ -146,14 +146,91 @@ - - - SysprofSamplesSection + + vertical + + + true + + SysprofSamplesSection + + + callgraph_view + + + + + + + + + true + true + + + + + + callgraph_view + + + + + + + + + + ]]> + + + + + + +