Bug 1546757 - [tryselect] Always cache both the full_task_set and target_task_set when generating tasks, r=tomprince
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 03 May 2019 02:26:57 +0000
changeset 472430 5a253216d75bddddd0a959e623df45d93cae556a
parent 472429 82b12442ef447627526f43bab6101e5047dbc07a
child 472431 4ff116b9d729055b866bb9fadf35065bba8f1c63
push id113012
push userdluca@mozilla.com
push dateFri, 03 May 2019 13:13:31 +0000
treeherdermozilla-inbound@d12dfc397c08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1546757
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546757 - [tryselect] Always cache both the full_task_set and target_task_set when generating tasks, r=tomprince Since we need to generate the full_task_set as a prereq to the target_task_set, and since getting from full_task_set -> target_task_set is trivial.. we might as well save both computed sets to the cache while we have them. This means users that run: $ ./mach try fuzzy and then run: $ ./mach try fuzzy --full (or vice versa) Will only incur task generation once. It also means that the 'watchman' trigger will cache both taskgraphs. Differential Revision: https://phabricator.services.mozilla.com/D29557
tools/tryselect/tasks.py
--- a/tools/tryselect/tasks.py
+++ b/tools/tryselect/tasks.py
@@ -81,27 +81,41 @@ def generate_tasks(params=None, full=Fal
     print("Task configuration changed, generating {}".format(attr.replace('_', ' ')))
 
     taskgraph.fast = True
     cwd = os.getcwd()
     os.chdir(root)
 
     root = os.path.join(root, 'taskcluster', 'ci')
     params = parameters_loader(params, strict=False, overrides={'try_mode': 'try_select'})
-    try:
-        tg = getattr(TaskGraphGenerator(root_dir=root, parameters=params), attr)
-    except ParameterMismatch as e:
-        print(PARAMETER_MISMATCH.format(e.args[0]))
-        sys.exit(1)
+
+    # Cache both full_task_set and target_task_set regardless of whether or not
+    # --full was requested. Caching is cheap and can potentially save a lot of
+    # time.
+    generator = TaskGraphGenerator(root_dir=root, parameters=params)
+
+    def generate(attr):
+        try:
+            tg = getattr(generator, attr)
+        except ParameterMismatch as e:
+            print(PARAMETER_MISMATCH.format(e.args[0]))
+            sys.exit(1)
+
+        # write cache
+        with open(os.path.join(cache_dir, attr), 'w') as fh:
+            json.dump(tg.to_json(), fh)
+        return tg
+
+    tg_full = generate('full_task_set')
+    tg_target = generate('target_task_set')
 
     os.chdir(cwd)
-
-    with open(cache, 'w') as fh:
-        json.dump(tg.to_json(), fh)
-    return tg
+    if full:
+        return tg_full
+    return tg_target
 
 
 def filter_tasks_by_paths(tasks, paths):
     resolver = TestResolver.from_environment(cwd=here)
     run_suites, run_tests = resolver.resolve_metadata(paths)
     flavors = set([(t['flavor'], t.get('subsuite')) for t in run_tests])
 
     task_regexes = set()