Skip to content

Commit

Permalink
Bug 1652184: Report to perherder stats about bugbug timings; r=ahal
Browse files Browse the repository at this point in the history
  • Loading branch information
tomprince committed Jul 13, 2020
1 parent f4c2e30 commit 1691c98
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ tasks:
GECKO_HEAD_REV: '${push.revision}'
HG_STORE_PATH: /builds/worker/checkouts/hg-store
TASKCLUSTER_CACHES: /builds/worker/checkouts
MOZ_AUTOMATION: '1'
# mach generates pyc files when reading `mach_commands.py`
# This causes cached_task digest generation to be random for
# some tasks. Disable bytecode generation to work around that.
Expand Down
12 changes: 12 additions & 0 deletions taskcluster/taskgraph/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@
def responses():
with RequestsMock() as rsps:
yield rsps


@pytest.fixture(scope="session", autouse=True)
def patch_prefherder(request):
from _pytest.monkeypatch import MonkeyPatch

m = MonkeyPatch()
m.setattr(
"taskgraph.util.bugbug._write_perfherder_data", lambda lower_is_better: None,
)
yield
m.undo()
32 changes: 31 additions & 1 deletion taskcluster/taskgraph/util/bugbug.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

from __future__ import absolute_import, print_function, unicode_literals

import os
import json
import sys
import time

import requests
Expand Down Expand Up @@ -45,10 +48,31 @@ def get_session():
return requests_retry_session(retries=5, session=s)


def _write_perfherder_data(lower_is_better):
if os.environ.get("MOZ_AUTOMATION", "0") == "1":
perfherder_data = {
"framework": {"name": "build_metrics"},
"suites": [
{
"name": suite,
"value": value,
"lowerIsBetter": True,
"shouldAlert": False,
"subtests": [],
}
for suite, value in lower_is_better.items()
],
}
print(
"PERFHERDER_DATA: {}".format(json.dumps(perfherder_data)), file=sys.stderr
)


@memoize
def push_schedules(branch, rev):
url = BUGBUG_BASE_URL + '/push/{branch}/{rev}/schedules'.format(branch=branch, rev=rev)

# TODO(py3): use time.monotonic()
start = time.clock()
session = get_session()
attempts = RETRY_TIMEOUT / RETRY_INTERVAL
i = 0
Expand All @@ -61,6 +85,12 @@ def push_schedules(branch, rev):

time.sleep(RETRY_INTERVAL)
i += 1
end = time.clock()

_write_perfherder_data(lower_is_better={
'bugbug_push_schedules_time': end-start,
'bugbug_push_schedules_retries': i,
})

data = r.json()
if r.status_code == 202:
Expand Down
1 change: 1 addition & 0 deletions tools/lint/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ black:
- python/mozrelease/mozrelease/scriptworker_canary.py
- taskcluster/docker/funsize-update-generator
- taskcluster/taskgraph/actions/scriptworker_canary.py
- taskcluster/taskgraph/test/conftest.py
- taskcluster/taskgraph/transforms/scriptworker_canary.py
- testing/condprofile/condprof
- tools/crashreporter/system-symbols
Expand Down

0 comments on commit 1691c98

Please sign in to comment.