[gnome-shell] perf-tool: Spawn perf-tool-helper from gnome-shell
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] perf-tool: Spawn perf-tool-helper from gnome-shell
- Date: Mon, 27 Jan 2020 13:51:27 +0000 (UTC)
commit ee7e62c9c8854ec5e0936ba0f1b49e8aed07c265
Author: Olivier Fourdan <ofourdan redhat com>
Date: Fri Jan 24 10:59:31 2020 +0100
perf-tool: Spawn perf-tool-helper from gnome-shell
On Wayland, the display server is the Wayland compositor, i.e.
`gnome-shell` itself.
As a result, we cannot spawn `gnome-shell-perf-helper` before
`gnome-shell` is started, as `gnome-shell-perf-helper` needs to connect
to the display server.
So, instead of spawning `gnome-shell-perf-helper` from the perf tool,
start it from `gnome-shell` itself.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/941
js/ui/scripting.js | 51 ++++++++++++++++++++++++++++--------------
src/gnome-shell-perf-tool.in | 53 --------------------------------------------
2 files changed, 34 insertions(+), 70 deletions(-)
---
diff --git a/js/ui/scripting.js b/js/ui/scripting.js
index ee775e4f01..b93de7196e 100644
--- a/js/ui/scripting.js
+++ b/js/ui/scripting.js
@@ -5,8 +5,10 @@
const { Gio, GLib, Meta, Shell } = imports.gi;
+const Config = imports.misc.config;
const Main = imports.ui.main;
const Params = imports.misc.params;
+const Util = imports.misc.util;
const { loadInterfaceXML } = imports.misc.fileUtils;
@@ -77,6 +79,12 @@ function _getPerfHelper() {
return _perfHelper;
}
+function _spawnPerfHelper() {
+ let path = Config.LIBEXECDIR;
+ let command = `${path}/gnome-shell-perf-helper`;
+ Util.trySpawnCommandLine(command);
+}
+
function _callRemote(obj, method, ...args) {
return new Promise((resolve, reject) => {
args.push((result, excp) => {
@@ -276,6 +284,25 @@ function _collect(scriptModule, outputFile) {
}
}
+async function _runPerfScript(scriptModule, outputFile) {
+ for (let step of scriptModule.run()) {
+ try {
+ await step; // eslint-disable-line no-await-in-loop
+ } catch (err) {
+ log(`Script failed: ${err}\n${err.stack}`);
+ Meta.exit(Meta.ExitCode.ERROR);
+ }
+ }
+
+ try {
+ _collect(scriptModule, outputFile);
+ } catch (err) {
+ log(`Script failed: ${err}\n${err.stack}`);
+ Meta.exit(Meta.ExitCode.ERROR);
+ }
+ Meta.exit(Meta.ExitCode.SUCCESS);
+}
+
/**
* runPerfScript
* @param {Object} scriptModule: module object with run and finish
@@ -317,23 +344,13 @@ function _collect(scriptModule, outputFile) {
* After running the script and collecting statistics from the
* event log, GNOME Shell will exit.
**/
-async function runPerfScript(scriptModule, outputFile) {
+function runPerfScript(scriptModule, outputFile) {
Shell.PerfLog.get_default().set_enabled(true);
+ _spawnPerfHelper();
- for (let step of scriptModule.run()) {
- try {
- await step; // eslint-disable-line no-await-in-loop
- } catch (err) {
- log(`Script failed: ${err}\n${err.stack}`);
- Meta.exit(Meta.ExitCode.ERROR);
- }
- }
-
- try {
- _collect(scriptModule, outputFile);
- } catch (err) {
- log(`Script failed: ${err}\n${err.stack}`);
- Meta.exit(Meta.ExitCode.ERROR);
- }
- Meta.exit(Meta.ExitCode.SUCCESS);
+ Gio.bus_watch_name(Gio.BusType.SESSION,
+ 'org.gnome.Shell.PerfHelper',
+ Gio.BusNameWatcherFlags.NONE,
+ () => _runPerfScript(scriptModule, outputFile),
+ null);
}
diff --git a/src/gnome-shell-perf-tool.in b/src/gnome-shell-perf-tool.in
index f4b48f7300..050c66b30a 100755
--- a/src/gnome-shell-perf-tool.in
+++ b/src/gnome-shell-perf-tool.in
@@ -24,52 +24,6 @@ def show_version(option, opt_str, value, parser):
print("GNOME Shell Performance Test @VERSION@")
sys.exit()
-def wait_for_dbus_name(wait_name):
- loop = GLib.MainLoop()
-
- def on_name_appeared(connection, name, new_owner, *args):
- if not (name == wait_name and new_owner != ''):
- return
- loop.quit()
- return
-
- watch_id = Gio.bus_watch_name(Gio.BusType.SESSION,
- wait_name,
- Gio.BusNameWatcherFlags.NONE,
- on_name_appeared,
- None)
-
- def on_timeout():
- print("\nFailed to start %s: timed out" % (wait_name,))
- sys.exit(1)
- GLib.timeout_add_seconds(7, on_timeout)
-
- loop.run()
- Gio.bus_unwatch_name(watch_id)
-
-PERF_HELPER_NAME = "org.gnome.Shell.PerfHelper"
-PERF_HELPER_IFACE = "org.gnome.Shell.PerfHelper"
-PERF_HELPER_PATH = "/org/gnome/Shell/PerfHelper"
-
-def start_perf_helper():
- self_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
- perf_helper_path = "@libexecdir@/gnome-shell-perf-helper"
-
- subprocess.Popen([perf_helper_path])
- wait_for_dbus_name (PERF_HELPER_NAME)
-
-def stop_perf_helper():
- bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
-
- proxy = Gio.DBusProxy.new_sync(bus,
- Gio.DBusProxyFlags.NONE,
- None,
- PERF_HELPER_NAME,
- PERF_HELPER_PATH,
- PERF_HELPER_IFACE,
- None)
- proxy.Exit()
-
def start_shell(perf_output=None):
# Set up environment
env = dict(os.environ)
@@ -204,8 +158,6 @@ def run_performance_test():
logs = []
metric_summaries = {}
- start_perf_helper()
-
for i in range(0, iters):
# We create an empty temporary file that the shell will overwrite
# with the contents.
@@ -217,14 +169,12 @@ def run_performance_test():
try:
normal_exit = run_shell(perf_output=output_file)
except:
- stop_perf_helper()
raise
finally:
if not normal_exit:
os.remove(output_file)
if not normal_exit:
- stop_perf_helper()
return False
try:
@@ -232,7 +182,6 @@ def run_performance_test():
output = json.load(f)
f.close()
except:
- stop_perf_helper()
raise
finally:
os.remove(output_file)
@@ -260,8 +209,6 @@ def run_performance_test():
logs.append(output['log'])
- stop_perf_helper()
-
if options.perf_output or options.perf_upload:
# Write a complete report, formatted as JSON. The Javascript/C code that
# generates the individual reports we are summarizing here is very careful
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]