From e30925995f249fe94e2e9dac090efaec9d3a540e Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 26 Jun 2014 20:34:15 -0400 Subject: [PATCH] Make frame-timestamp logging optional Instead of always logging frame timestamps for every frame - which was using >26 bytes of memory per frame, or 5MB per hour of continuous redrawing - make frame timestamps something that defaults off and is turned turned on using a new ShellGlobal::frame-timestamps property by the perf scripts. https://bugzilla.gnome.org/show_bug.cgi?id=732350 --- js/perf/core.js | 3 +++ src/gnome-shell-plugin.c | 14 +++++++++++--- src/shell-global.c | 33 +++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/js/perf/core.js b/js/perf/core.js index b9f5494d5..51bdf43c4 100644 --- a/js/perf/core.js +++ b/js/perf/core.js @@ -72,6 +72,9 @@ function run() { Scripting.defineScriptEvent("applicationsShowStart", "Starting to switch to applications view"); Scripting.defineScriptEvent("applicationsShowDone", "Done switching to applications view"); + // Enable recording of timestamps for different points in the frame cycle + global.frame_timestamps = true; + Main.overview.connect('shown', function() { Scripting.scriptEvent('overviewShowDone'); }); diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c index 24323103d..8edc7b69a 100644 --- a/src/gnome-shell-plugin.c +++ b/src/gnome-shell-plugin.c @@ -389,9 +389,17 @@ gnome_shell_plugin_xevent_filter (MetaPlugin *plugin, * can send this with a ust of 0. Simplify life for consumers * by ignoring such events */ if (swap_complete_event->ust != 0) - shell_perf_log_event_x (shell_perf_log_get_default (), - "glx.swapComplete", - swap_complete_event->ust); + { + gboolean frame_timestamps; + g_object_get (shell_plugin->global, + "frame-timestamps", &frame_timestamps, + NULL); + + if (frame_timestamps) + shell_perf_log_event_x (shell_perf_log_get_default (), + "glx.swapComplete", + swap_complete_event->ust); + } } #endif diff --git a/src/shell-global.c b/src/shell-global.c index dab830408..571483e81 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -96,6 +96,7 @@ struct _ShellGlobal { guint32 xdnd_timestamp; gboolean has_modal; + gboolean frame_timestamps; }; enum { @@ -116,6 +117,7 @@ enum { PROP_IMAGEDIR, PROP_USERDATADIR, PROP_FOCUS_MANAGER, + PROP_FRAME_TIMESTAMPS, }; /* Signals */ @@ -146,6 +148,9 @@ shell_global_set_property(GObject *object, g_clear_pointer (&global->session_mode, g_free); global->session_mode = g_ascii_strdown (g_value_get_string (value), -1); break; + case PROP_FRAME_TIMESTAMPS: + global->frame_timestamps = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -217,6 +222,9 @@ shell_global_get_property(GObject *object, case PROP_FOCUS_MANAGER: g_value_set_object (value, global->focus_manager); break; + case PROP_FRAME_TIMESTAMPS: + g_value_set_boolean (value, global->frame_timestamps); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -500,6 +508,13 @@ shell_global_class_init (ShellGlobalClass *klass) "The shell's StFocusManager", ST_TYPE_FOCUS_MANAGER, G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, + PROP_FRAME_TIMESTAMPS, + g_param_spec_boolean ("frame-timestamps", + "Frame Timestamps", + "Whether to log frame timestamps in the performance log", + FALSE, + G_PARAM_READWRITE)); } /* @@ -756,8 +771,11 @@ global_stage_notify_height (GObject *gobject, static gboolean global_stage_before_paint (gpointer data) { - shell_perf_log_event (shell_perf_log_get_default (), - "clutter.stagePaintStart"); + ShellGlobal *global = SHELL_GLOBAL (data); + + if (global->frame_timestamps) + shell_perf_log_event (shell_perf_log_get_default (), + "clutter.stagePaintStart"); return TRUE; } @@ -765,8 +783,11 @@ global_stage_before_paint (gpointer data) static gboolean global_stage_after_paint (gpointer data) { - shell_perf_log_event (shell_perf_log_get_default (), - "clutter.stagePaintDone"); + ShellGlobal *global = SHELL_GLOBAL (data); + + if (global->frame_timestamps) + shell_perf_log_event (shell_perf_log_get_default (), + "clutter.stagePaintDone"); return TRUE; } @@ -951,11 +972,11 @@ _shell_global_set_plugin (ShellGlobal *global, clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_PRE_PAINT, global_stage_before_paint, - NULL, NULL); + global, NULL); clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, global_stage_after_paint, - NULL, NULL); + global, NULL); shell_perf_log_define_event (shell_perf_log_get_default(), "clutter.stagePaintStart",