Bug 1624859 - [taskgraph] Always optimize build tasks with ./mach try auto, r=tomprince

This ensures we don't run every build with every push via ./mach try auto. It
introduces a new 'optimization-overrides' try_config that can be used to
replace optimizations. For now, there is no user interface to pass this in via
the 'mach try' command line.

Differential Revision: https://phabricator.services.mozilla.com/D68207
This commit is contained in:
Andrew Halberstadt 2020-04-22 15:51:35 +00:00
Родитель a0bcf43891
Коммит 5454fdd8bb
7 изменённых файлов: 48 добавлений и 8 удалений

Просмотреть файл

@ -259,6 +259,12 @@ class OptimizationStrategy(object):
return False
@register_strategy('always')
class Always(OptimizationStrategy):
def should_remove_task(self, task, params, arg):
return True
@six.add_metaclass(ABCMeta)
class CompositeStrategy(OptimizationStrategy):
@ -369,12 +375,15 @@ import_sibling_modules()
# Register composite strategies.
register_strategy('build', args=('skip-unless-schedules',))(Alias)
register_strategy('test', args=(Any('skip-unless-schedules', 'seta'), 'backstop'))(All)
register_strategy('test-inclusive', args=('skip-unless-schedules',))(Alias)
register_strategy('test-try', args=('skip-unless-schedules',))(Alias)
register_strategy('fuzzing-builds', args=('skip-unless-schedules', 'seta'))(Any)
# Strategy overrides used by |mach try| and/or shadow-scheduler tasks.
class experimental(object):
"""Experimental strategies either under development or used as benchmarks.
@ -425,3 +434,30 @@ class experimental(object):
}
"""Provides a stable history of SETA's performance in the event we make it
non-default in the future. Only useful as a benchmark."""
class ExperimentalOverride(object):
"""Overrides dictionaries that are stored in a container with new values.
This can be used to modify all strategies in a collection the same way,
presumably with strategies affecting kinds of tasks tangential to the
current context.
Args:
base (object): A container class supporting attribute access.
overrides (dict): Values to update any accessed dictionaries with.
"""
def __init__(self, base, overrides):
self.base = base
self.overrides = overrides
def __getattr__(self, name):
val = getattr(self.base, name).copy()
val.update(self.overrides)
return val
tryselect = ExperimentalOverride(experimental, {
'build': Alias('always'),
'fuzzing-builds': Alias('always'),
})

Просмотреть файл

@ -45,5 +45,5 @@ def set_schedules_optimization(config, jobs):
build_platform = job['attributes']['build_platform']
job.setdefault('optimization',
{'skip-unless-schedules': [platform_family(build_platform)]})
{'build': [platform_family(build_platform)]})
yield job

Просмотреть файл

@ -197,6 +197,10 @@ class Schema(voluptuous.Schema):
OptimizationSchema = voluptuous.Any(
# always run this task (default)
None,
# always optimize this task
{'always': None},
# optimize strategy aliases for build kind
{'build': list(schedules.ALL_COMPONENTS)},
# search the index for the given index namespaces, and replace this task if found
# the search occurs in order, with the first match winning
{'index-search': [text_type]},

Просмотреть файл

@ -29,7 +29,7 @@ def run(message='{msg}', push=True, closed_tree=False, try_config=None):
# XXX Remove once an intelligent scheduling algorithm is running on
# autoland by default. This ensures `mach try auto` doesn't run SETA.
try_config.setdefault('optimize-strategies',
'taskgraph.optimize:experimental.bugbug_debug')
'taskgraph.optimize:tryselect.bugbug_debug')
task_config = {
'version': 2,

Просмотреть файл

@ -318,7 +318,7 @@ class OptimizeStrategies(TryConfig):
def try_config(self, strategy, **kwargs):
if strategy:
if ':' not in strategy:
strategy = "taskgraph.optimize:experimental.{}".format(strategy)
strategy = "taskgraph.optimize:tryselect.{}".format(strategy)
try:
obj = find_object(strategy)

Просмотреть файл

@ -17,7 +17,7 @@ Test auto selector
"target_tasks_method": "try_auto",
"try_mode": "try_auto",
"try_task_config": {
"optimize-strategies": "taskgraph.optimize:experimental.bugbug_debug"
"optimize-strategies": "taskgraph.optimize:tryselect.bugbug_debug"
}
},
"version": 2
@ -37,7 +37,7 @@ Test auto selector
"target_tasks_method": "try_auto",
"try_mode": "try_auto",
"try_task_config": {
"optimize-strategies": "taskgraph.optimize:experimental.bugbug_debug"
"optimize-strategies": "taskgraph.optimize:tryselect.bugbug_debug"
}
},
"version": 2
@ -56,7 +56,7 @@ Test auto selector
"target_tasks_method": "try_auto",
"try_mode": "try_auto",
"try_task_config": {
"optimize-strategies": "taskgraph.optimize:experimental.bugbug_debug"
"optimize-strategies": "taskgraph.optimize:tryselect.bugbug_debug"
}
},
"version": 2

Просмотреть файл

@ -42,9 +42,9 @@ TASK_CONFIG_TESTS = {
],
'strategy': [
([], None),
(['--strategy', 'seta'], {'optimize-strategies': 'taskgraph.optimize:experimental.seta'}),
(['--strategy', 'seta'], {'optimize-strategies': 'taskgraph.optimize:tryselect.seta'}),
(['--strategy', 'taskgraph.optimize:experimental.seta'], {'optimize-strategies': 'taskgraph.optimize:experimental.seta'}), # noqa
(['--strategy', 'taskgraph.optimize:experimental'], SystemExit),
(['--strategy', 'taskgraph.optimize:tryselect'], SystemExit),
(['--strategy', 'foo'], SystemExit),
(['--strategy', 'foo:bar'], SystemExit),
],