From a60bc04de24e5a2054a2bf7d185181c2ad1fc10d Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 28 Aug 2023 13:32:27 -0700 Subject: [PATCH] sysprof: add UI to toggle merge-similar-processes flags Related #93 --- src/sysprof/sysprof-callgraph-view-private.h | 1 + src/sysprof/sysprof-callgraph-view.c | 41 +++++++++++++++ src/sysprof/sysprof-callgraph-view.h | 55 +++++++++++--------- src/sysprof/sysprof-callgraph-view.ui | 4 ++ src/sysprof/sysprof-samples-section.ui | 5 ++ src/sysprof/sysprof-session.c | 21 ++++++-- src/sysprof/sysprof-window.c | 1 + src/sysprof/sysprof-window.ui | 4 ++ 8 files changed, 103 insertions(+), 29 deletions(-) diff --git a/src/sysprof/sysprof-callgraph-view-private.h b/src/sysprof/sysprof-callgraph-view-private.h index 20ddefb4..21d5acf4 100644 --- a/src/sysprof/sysprof-callgraph-view-private.h +++ b/src/sysprof/sysprof-callgraph-view-private.h @@ -58,6 +58,7 @@ struct _SysprofCallgraphView guint ignore_process_0 : 1; guint include_threads : 1; guint left_heavy : 1; + guint merge_similar_processes : 1; }; struct _SysprofCallgraphViewClass diff --git a/src/sysprof/sysprof-callgraph-view.c b/src/sysprof/sysprof-callgraph-view.c index cd3a208b..20df65fb 100644 --- a/src/sysprof/sysprof-callgraph-view.c +++ b/src/sysprof/sysprof-callgraph-view.c @@ -39,6 +39,7 @@ enum { PROP_IGNORE_PROCESS_0, PROP_INCLUDE_THREADS, PROP_LEFT_HEAVY, + PROP_MERGE_SIMILAR_PROCESSES, PROP_TRACEABLES, PROP_UTILITY_SUMMARY, PROP_UTILITY_TRACEABLES, @@ -399,6 +400,10 @@ sysprof_callgraph_view_get_property (GObject *object, g_value_set_boolean (value, sysprof_callgraph_view_get_left_heavy (self)); break; + case PROP_MERGE_SIMILAR_PROCESSES: + g_value_set_boolean (value, sysprof_callgraph_view_get_merge_similar_processes (self)); + break; + case PROP_TRACEABLES: g_value_set_object (value, sysprof_callgraph_view_get_traceables (self)); break; @@ -454,6 +459,10 @@ sysprof_callgraph_view_set_property (GObject *object, sysprof_callgraph_view_set_left_heavy (self, g_value_get_boolean (value)); break; + case PROP_MERGE_SIMILAR_PROCESSES: + sysprof_callgraph_view_set_merge_similar_processes (self, g_value_get_boolean (value)); + break; + case PROP_TRACEABLES: sysprof_callgraph_view_set_traceables (self, g_value_get_object (value)); break; @@ -513,6 +522,11 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) FALSE, (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties[PROP_MERGE_SIMILAR_PROCESSES] = + g_param_spec_boolean ("merge-similar-processes", NULL, NULL, + FALSE, + (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties[PROP_TRACEABLES] = g_param_spec_object ("traceables", NULL, NULL, G_TYPE_LIST_MODEL, @@ -697,6 +711,9 @@ sysprof_callgraph_view_reload (SysprofCallgraphView *self) if (self->left_heavy) flags |= SYSPROF_CALLGRAPH_FLAGS_LEFT_HEAVY; + if (self->merge_similar_processes) + flags |= SYSPROF_CALLGRAPH_FLAGS_MERGE_SIMILAR_PROCESSES; + sysprof_document_callgraph_async (self->document, flags, self->traceables, @@ -974,3 +991,27 @@ sysprof_callgraph_view_set_left_heavy (SysprofCallgraphView *self, sysprof_callgraph_view_queue_reload (self); } } + +gboolean +sysprof_callgraph_view_get_merge_similar_processes (SysprofCallgraphView *self) +{ + g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), FALSE); + + return self->merge_similar_processes; +} + +void +sysprof_callgraph_view_set_merge_similar_processes (SysprofCallgraphView *self, + gboolean merge_similar_processes) +{ + g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self)); + + merge_similar_processes = !!merge_similar_processes; + + if (self->merge_similar_processes != merge_similar_processes) + { + self->merge_similar_processes = merge_similar_processes; + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MERGE_SIMILAR_PROCESSES]); + sysprof_callgraph_view_queue_reload (self); + } +} diff --git a/src/sysprof/sysprof-callgraph-view.h b/src/sysprof/sysprof-callgraph-view.h index 71e81fa7..963327f1 100644 --- a/src/sysprof/sysprof-callgraph-view.h +++ b/src/sysprof/sysprof-callgraph-view.h @@ -35,32 +35,35 @@ G_BEGIN_DECLS typedef struct _SysprofCallgraphView SysprofCallgraphView; typedef struct _SysprofCallgraphViewClass SysprofCallgraphViewClass; -GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST; -SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self); -SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_document (SysprofCallgraphView *self, - SysprofDocument *document); -GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self, - GListModel *model); -gboolean sysprof_callgraph_view_get_bottom_up (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_bottom_up (SysprofCallgraphView *self, - gboolean bottom_up); -gboolean sysprof_callgraph_view_get_categorize_frames (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_categorize_frames (SysprofCallgraphView *self, - gboolean categorize_frames); -gboolean sysprof_callgraph_view_get_ignore_process_0 (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_ignore_process_0 (SysprofCallgraphView *self, - gboolean ignore_process_0); -gboolean sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_include_threads (SysprofCallgraphView *self, - gboolean include_threads); -gboolean sysprof_callgraph_view_get_hide_system_libraries (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_hide_system_libraries (SysprofCallgraphView *self, - gboolean hide_system_libraries); -gboolean sysprof_callgraph_view_get_left_heavy (SysprofCallgraphView *self); -void sysprof_callgraph_view_set_left_heavy (SysprofCallgraphView *self, - gboolean left_heavy); +GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST; +SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self); +SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_document (SysprofCallgraphView *self, + SysprofDocument *document); +GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self, + GListModel *model); +gboolean sysprof_callgraph_view_get_bottom_up (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_bottom_up (SysprofCallgraphView *self, + gboolean bottom_up); +gboolean sysprof_callgraph_view_get_categorize_frames (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_categorize_frames (SysprofCallgraphView *self, + gboolean categorize_frames); +gboolean sysprof_callgraph_view_get_ignore_process_0 (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_ignore_process_0 (SysprofCallgraphView *self, + gboolean ignore_process_0); +gboolean sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_include_threads (SysprofCallgraphView *self, + gboolean include_threads); +gboolean sysprof_callgraph_view_get_hide_system_libraries (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_hide_system_libraries (SysprofCallgraphView *self, + gboolean hide_system_libraries); +gboolean sysprof_callgraph_view_get_left_heavy (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_left_heavy (SysprofCallgraphView *self, + gboolean left_heavy); +gboolean sysprof_callgraph_view_get_merge_similar_processes (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_merge_similar_processes (SysprofCallgraphView *self, + gboolean merge_similar_processes); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCallgraphView, g_object_unref) diff --git a/src/sysprof/sysprof-callgraph-view.ui b/src/sysprof/sysprof-callgraph-view.ui index a12f097c..5670201f 100644 --- a/src/sysprof/sysprof-callgraph-view.ui +++ b/src/sysprof/sysprof-callgraph-view.ui @@ -275,6 +275,10 @@ Ignore Process 0 win.callgraph.ignore-process-0 + + Merge Similar Processes + win.callgraph.merge-similar-processes + diff --git a/src/sysprof/sysprof-samples-section.ui b/src/sysprof/sysprof-samples-section.ui index a3c246f7..2d398ce5 100644 --- a/src/sysprof/sysprof-samples-section.ui +++ b/src/sysprof/sysprof-samples-section.ui @@ -109,6 +109,11 @@ SysprofSamplesSection + + + SysprofSamplesSection + + SysprofSamplesSection diff --git a/src/sysprof/sysprof-session.c b/src/sysprof/sysprof-session.c index ac77c87e..3b001f0a 100644 --- a/src/sysprof/sysprof-session.c +++ b/src/sysprof/sysprof-session.c @@ -41,23 +41,25 @@ struct _SysprofSession guint bottom_up : 1; guint categorize_frames : 1; + guint hide_system_libraries : 1; guint ignore_process_0 : 1; guint include_threads : 1; guint left_heavy : 1; - guint hide_system_libraries : 1; + guint merge_similar_processes : 1; }; enum { PROP_0, PROP_BOTTOM_UP, + PROP_CATEGORIZE_FRAMES, PROP_DOCUMENT, PROP_DOCUMENT_TIME, PROP_FILTER, - PROP_LEFT_HEAVY, PROP_HIDE_SYSTEM_LIBRARIES, PROP_IGNORE_PROCESS_0, PROP_INCLUDE_THREADS, - PROP_CATEGORIZE_FRAMES, + PROP_LEFT_HEAVY, + PROP_MERGE_SIMILAR_PROCESSES, PROP_SELECTED_TIME, PROP_SELECTED_TIME_AXIS, PROP_VISIBLE_TIME, @@ -162,6 +164,10 @@ sysprof_session_get_property (GObject *object, g_value_set_boolean (value, self->left_heavy); break; + case PROP_MERGE_SIMILAR_PROCESSES: + g_value_set_boolean (value, self->merge_similar_processes); + break; + case PROP_SELECTED_TIME: g_value_set_boxed (value, sysprof_session_get_selected_time (self)); break; @@ -221,6 +227,10 @@ sysprof_session_set_property (GObject *object, self->left_heavy = g_value_get_boolean (value); break; + case PROP_MERGE_SIMILAR_PROCESSES: + self->merge_similar_processes = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -280,6 +290,11 @@ sysprof_session_class_init (SysprofSessionClass *klass) FALSE, (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties [PROP_MERGE_SIMILAR_PROCESSES] = + g_param_spec_boolean ("merge-similar-processes", NULL, NULL, + FALSE, + (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties [PROP_SELECTED_TIME] = g_param_spec_boxed ("selected-time", NULL, NULL, SYSPROF_TYPE_TIME_SPAN, diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index 12123d06..ae65a137 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -225,6 +225,7 @@ sysprof_window_set_document (SysprofWindow *self, "ignore-process-0", "include-threads", "left-heavy", + "merge-similar-processes", }; g_autofree char *title = NULL; g_autofree char *full_title = NULL; diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index a8a7a234..49093169 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -381,6 +381,10 @@ Ignore Process 0 win.callgraph.ignore-process-0 + + Merge Similar Processes + win.callgraph.merge-similar-processes +
Flamegraph