1Optimization
2============
3
4The objective of optimization to remove as many tasks from the graph as
5possible, as efficiently as possible, thereby delivering useful results as
6quickly as possible. For example, ideally if only a test script is modified in
7a push, then the resulting graph contains only the corresponding test suite
8task.
9
10A task is said to be "optimized" when it is either replaced with an equivalent,
11already-existing task, or dropped from the graph entirely.
12
13Optimization Strategies
14-----------------------
15
16Each task has a single named optimization strategy, and can provide an argument
17to that strategy. Each strategy is defined as an ``OptimizationStrategy``
18instance in ``taskcluster/taskgraph/optimization.py``.
19
20Each task has a ``task.optimization`` property describing the optimization
21strategy that applies, specified as a dictionary mapping strategy to argument. For
22example::
23
24    task.optimization = {'skip-unless-changed': ['js/**', 'tests/**']}
25
26Strategy implementations are shared across all tasks, so they may cache
27commonly-used information as instance variables.
28
29Optimizing Target Tasks
30-----------------------
31
32In some cases, such as try pushes, tasks in the target task set have been
33explicitly requested and are thus excluded from optimization. In other cases,
34the target task set is almost the entire task graph, so targeted tasks are
35considered for optimization. This behavior is controlled with the
36``optimize_target_tasks`` parameter.
37
38.. note::
39
40    Because it is a mix of "what the push author wanted" and "what should run
41    when necessary", try pushes with the old option syntax (``-b do -p all``,
42    etc.) *do* optimize target tasks.  This can cause unexpected results when
43    requested jobs are optimized away.  If those jobs were actually necessary,
44    then a try push with ``try_task_config.json`` is the solution.
45
46More Information
47----------------
48
49.. toctree::
50
51    optimization-process
52    optimization-schedules
53