commit 095424a9b5152a1b1e327ca3ca7d33ad1be26cea
parent 40813494e727c457dfb3c78522e36efca0abf8b3
Author: Ben Hearsum <ben@mozilla.com>
Date: Thu, 27 Nov 2025 21:36:39 +0000
Bug 2002681: recorded timings of mozharness actions in perfherder artifact r=releng-reviewers,jcristau
We have an ongoing effort to improve try push turnaround times. One area where we have a blind spot at the moment is the breakdown of time spent on different parts of tasks. For the majority of the tasks that we care about (builds and tests), having timings for the different mozharness steps they run would be a sufficient starting point. In particular, this would let us see how much time is spent in set-up vs. actually making builds or running tests.
Differential Revision: https://phabricator.services.mozilla.com/D274236
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/testing/mozharness/mozharness/base/script.py b/testing/mozharness/mozharness/base/script.py
@@ -34,6 +34,7 @@ import zipfile
import zlib
from contextlib import contextmanager
from io import BytesIO
+from pathlib import Path
from queue import Empty, Queue
import mozinfo
@@ -2385,16 +2386,38 @@ class BaseScript(ScriptMixin, LogMixin):
self.fatal("Aborting due to failure in pre-run listener.")
self.dump_config()
+ perfherder_data = {
+ "framework": {"name": "mozharness"},
+ "suites": [],
+ }
try:
for action in self.all_actions:
if action not in self.actions:
self.action_message(f"Skipping {action} step.")
continue
+ start = time.monotonic()
self.run_action(action)
+ end = time.monotonic()
+ perfherder_data["suites"].append(
+ {
+ "name": action,
+ "value": end - start,
+ "lowerIsBetter": True,
+ "unit": "s",
+ "shouldAlert": False,
+ "subtests": [],
+ }
+ )
except Exception:
self.fatal("Uncaught exception: %s" % traceback.format_exc())
finally:
+ if "MOZ_AUTOMATION" in os.environ and "UPLOAD_DIR" in os.environ:
+ upload_dir = Path(os.environ["UPLOAD_DIR"])
+ upload_dir.mkdir(parents=True, exist_ok=True)
+ upload_path = upload_dir / "perfherder-data-mozharness-actions.json"
+ with upload_path.open("w", encoding="utf-8") as f:
+ json.dump(perfherder_data, f)
post_success = True
for fn in self._listeners["post_run"]:
try: