gecko_taskgraph.optimize package
Submodules
gecko_taskgraph.optimize.backstop module
- class gecko_taskgraph.optimize.backstop.SkipUnlessAndroidPerftestBackstop
Bases:
OptimizationStrategyAlways removes tasks except on backstop pushes.
- should_remove_task(task, params, _)
Determine whether to optimize this task by removing it. Returns True to remove.
- class gecko_taskgraph.optimize.backstop.SkipUnlessBackstop
Bases:
OptimizationStrategyAlways removes tasks except on backstop pushes.
- should_remove_task(task, params, _)
Determine whether to optimize this task by removing it. Returns True to remove.
- class gecko_taskgraph.optimize.backstop.SkipUnlessPushInterval(push_interval, remove_on_projects=None)
Bases:
OptimizationStrategyAlways removes tasks except every N pushes.
- Parameters:
push_interval (int) – Number of pushes
- property description
- should_remove_task(task, params, _)
Determine whether to optimize this task by removing it. Returns True to remove.
gecko_taskgraph.optimize.bugbug module
- class gecko_taskgraph.optimize.bugbug.BugBugPushSchedules(confidence_threshold, tasks_only=False, use_reduced_tasks=False, fallback=None, num_pushes=1, select_configs=False)
Bases:
OptimizationStrategyQuery the ‘bugbug’ service to retrieve relevant tasks and manifests.
- Parameters:
confidence_threshold (float) – The minimum confidence threshold (in range [0, 1]) needed for a task to be scheduled.
tasks_only (bool) – Whether or not to only use tasks and no groups (default: False)
use_reduced_tasks (bool) – Whether or not to use the reduced set of tasks provided by the bugbug service (default: False).
fallback (str) – The fallback strategy to use if there was a failure in bugbug (default: None)
num_pushes (int) – The number of pushes to consider for the selection (default: 1).
select_configs (bool) – Whether to select configurations for manifests too (default: False).
- should_remove_task(task, params, importance)
Determine whether to optimize this task by removing it. Returns True to remove.
- class gecko_taskgraph.optimize.bugbug.DisperseGroups(target_counts=None, unseen_modifier=DEFAULT_UNSEEN_MODIFIER)
Bases:
OptimizationStrategyDisperse groups across test configs.
Each task has an associated ‘importance’ dict passed in via the arg. This is of the form {<group>: <importance>}.
Where ‘group’ is a test group id (usually a path to a manifest), and ‘importance’ is one of {‘lowest’, ‘low’, ‘medium’, ‘high’}.
Each importance value has an associated ‘count’ as defined in self.target_counts. It guarantees that ‘manifest’ will run in at least ‘count’ different configurations (assuming there are enough tasks containing ‘manifest’).
On configurations that haven’t been seen before, we’ll increase the target count by self.unseen_modifier to increase the likelihood of scheduling a task on that configuration.
- Parameters:
target_counts (dict) – Override DEFAULT_TARGET_COUNTS with custom counts. This is a dict mapping the importance value (‘lowest’, ‘low’, etc) to the minimum number of configurations manifests with this value should run on.
unseen_modifier (int) – Override DEFAULT_UNSEEN_MODIFIER to a custom value. This is the amount we’ll increase ‘target_count’ by for unseen configurations.
- DEFAULT_TARGET_COUNTS = {'high': 3, 'low': 1, 'lowest': 0, 'medium': 2}
- DEFAULT_UNSEEN_MODIFIER = 1
- should_remove_task(task, params, importance)
Determine whether to optimize this task by removing it. Returns True to remove.
- class gecko_taskgraph.optimize.bugbug.SkipUnlessDebug
Bases:
OptimizationStrategyOnly run debug platforms.
- should_remove_task(task, params, arg)
Determine whether to optimize this task by removing it. Returns True to remove.
- gecko_taskgraph.optimize.bugbug.merge_bugbug_replies(data, new_data)
Merge a bugbug reply (stored in the new_data argument) into another (stored in the data argument).
gecko_taskgraph.optimize.docs module
- class gecko_taskgraph.optimize.docs.SkipUnlessSphinxJs
Bases:
OptimizationStrategyOptimization strategy for tasks using Sphinx JS.
This strategy checks if any changed files match the js_source_paths configured in docs/config.yml.
- should_remove_task(task, params, _)
Determine whether to optimize this task by removing it. Returns True to remove.
gecko_taskgraph.optimize.mozlint module
- class gecko_taskgraph.optimize.mozlint.SkipUnlessMozlint(linters_path: str)
Bases:
OptimizationStrategyOptimization strategy for mozlint tests.
Uses the mozlint YAML file for each test to determine whether or not a test should run.
- Using:
The optimization relies on having files_changed set in the decision task parameters.
Register with register_strategy. The argument is the path to MozLint YAML configuration files (“/tools/lint” for mozilla-central):
In source-test/mozlint.yml, set the optimization strategy for each job by filename:
For Mozlint jobs that run multiple linters at once use a list of filenames:
- should_remove_task(task, params, mozlint_confs: str | list[str]) bool
Determine whether to optimize this task by removing it. Returns True to remove.
gecko_taskgraph.optimize.perf_batching module
Batching strategies that change the cadence performance tests run at on autoland. Performance tasks are optimized through the perf-cadence-* aliases (registered in gecko_taskgraph.optimize and assigned by the perf transforms), which by default behave exactly like the strategies they wrap. The batching strategies are currently only referenced by the shadow schedulers defined in taskcluster/kinds/source-test/shadow-scheduler.yml, which override those aliases to evaluate alternative cadences without affecting what production schedules.
- class gecko_taskgraph.optimize.perf_batching.SkipUnlessBatchDue(state_name)
Bases:
OptimizationStrategyBase class of the stateful batching strategies, which remove tasks except on the pushes where a batch is due.
Whether a batch is due depends on every push since the last batch, but the shadow scheduler runs that carry the state overlap, fail, or are missing for some pushes, so a running total handed from run to run would lose pushes. Instead, each run replays the pushes since the most recent batch recorded by any previous run, re-deriving the batches of the runs it cannot see. Batching decisions only depend on the pushlog (and on bugbug’s cached risk scores), so every run reaches the same decisions whichever state it loaded.
The decision task strips every task from a push whose commit message says DONTBUILD, so no shadow scheduler runs on it and no batch can run on it either: the replay observes such a push, so its commits count towards the next decision, but never makes it a batch.
Tasks are kept when no previous batch can be found (first run, state expired, too many pushes to replay); the recorded state marks this as a cold start so evaluation can discount it. The decision is computed and recorded once per push and reused for every task.
- Parameters:
state_name (str) – Name of the shadow scheduler task whose runs carry this strategy’s state, as used in its index job-name.
- batch_due(params, last_batch, pending)
Return whether a batch is due on the last of the
pendingpushes, which all came afterlast_batch, along with the score that decision is based on.
- property config
The strategy’s parameters, recorded in the state.
- push_details(params, push)
Return extra information about
pushto record in the state.
- should_remove_task(task, params, _)
Remove the task unless this push is a batch push. The batch decision is per-push, so it is computed once and cached for all the tasks of the same push.
- class gecko_taskgraph.optimize.perf_batching.SkipUnlessPushesSinceLastBatch(push_interval, state_name)
Bases:
SkipUnlessBatchDueRemoves tasks unless at least
push_intervalpushes have been made since the last batch, counted by pushlog id like the backstop’s push interval. Unlike a fixed grid of pushlog ids, a batch that falls on a push nothing runs on is deferred to the next push rather than lost.- Parameters:
push_interval (int) – Minimum number of pushes between batches.
state_name (str) – See SkipUnlessBatchDue.
- batch_due(params, last_batch, pending)
Return whether a batch is due on the last of the
pendingpushes, which all came afterlast_batch, along with the score that decision is based on.
- property config
The strategy’s parameters, recorded in the state.
- property description
Human-readable label shown in optimization log messages.
- class gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold(threshold, aggregation, state_name, aging_rate=0)
Bases:
SkipUnlessBatchDueRemoves tasks unless the risk of the commits pushed since the last batch reaches
threshold.The risk r of a commit is the probability that it regresses performance, as predicted by bugbug’s perf regression predictor and calibrated against the culprit rate of past commits; commits bugbug does not score (merges, web-platform-tests imports, …) are left out. With aging, the score of a commit that has waited w hours rises towards 1 as 1 - (1 - r) * exp(-aging_rate * w), so that low-risk commits eventually get tested too. Commit scores are aggregated either as the probability that at least one commit regressed, 1 - prod(1 - score), computed in log space, or as their sum.
- Parameters:
threshold (float) – Aggregated score at which a batch is due.
aggregation (str) – “product” or “linear”.
state_name (str) – See SkipUnlessBatchDue.
aging_rate (float) – Aging rate per hour waited, 0 to disable aging.
- batch_due(params, last_batch, pending)
Return whether a batch is due on the last of the
pendingpushes, which all came afterlast_batch, along with the score that decision is based on.
- property config
The strategy’s parameters, recorded in the state.
- property description
Human-readable label shown in optimization log messages.
- push_details(params, push)
Return extra information about
pushto record in the state.
- class gecko_taskgraph.optimize.perf_batching.SkipUnlessTimeSinceLastBatch(hours, state_name)
Bases:
SkipUnlessBatchDueRemoves tasks unless at least
hourshave passed since the last batch.- Parameters:
hours (float) – Minimum time between batches.
state_name (str) – See SkipUnlessBatchDue.
- batch_due(params, last_batch, pending)
Return whether a batch is due on the last of the
pendingpushes, which all came afterlast_batch, along with the score that decision is based on.
- property config
The strategy’s parameters, recorded in the state.
- property description
Human-readable label shown in optimization log messages.
- gecko_taskgraph.optimize.perf_batching.get_pushes_between(params, first_pushlog_id, last_pushlog_id)
Return the pushes from
first_pushlog_idtolast_pushlog_id(inclusive) on the project ofparams, oldest first.dontbuildtells whether the decision task ran no task at all on the push, which it decides from the head commit’s message as in decision.py.
- gecko_taskgraph.optimize.perf_batching.load_state(project, state_name)
Load the state recorded by the last successful run of the
state_nameshadow scheduler onproject, or None when no usable state exists (first run, expired, previous runs failed).
- gecko_taskgraph.optimize.perf_batching.perf_batch_overrides(base_overrides, batch_strategy)
Build a strategy override dict that applies
batch_strategyto all performance tasks while keeping the behavior ofbase_overridesfor everything else.
- gecko_taskgraph.optimize.perf_batching.save_state(state)
Write
stateas JSON to the path named by the SHADOW_SCHEDULER_STATE_PATH environment variable, where the worker picks it up as an artifact. No-op when the variable is unset (local runs, try pushes).
gecko_taskgraph.optimize.schema module
- class gecko_taskgraph.optimize.schema.OptimizationSchema(*, always: None = None, build: list[str] | None = None, docs: None = None, index_search: list[str] | None = None, never: None = None, skip_unless_expanded: None = None, skip_unless_backstop: None = None, skip_unless_android_perftest_backstop: None = None, perf_cadence_android: None = None, perf_cadence_backstop: None = None, perf_cadence_default: list[str] | None = None, perf_cadence_expanded: None = None, skip_unless_changed: list[str] | None = None, skip_unless_missing_or_changed: list[str | list[str]] | None = None, skip_unless_schedules: list[str] | None = None, test: list[str] | None = None, test_inclusive: list[str] | None = None, test_verify: list[str] | None = None, upload_symbols: None = None, reprocess_symbols: None = None, skip_unless_mozlint: str | list[str] | None = None, skip_unless_sphinx_js: None = None)
Bases:
Schema- always: None
- build: list[str] | None
- docs: None
- index_search: list[str] | None
- never: None
- perf_cadence_android: None
- perf_cadence_backstop: None
- perf_cadence_default: list[str] | None
- perf_cadence_expanded: None
- reprocess_symbols: None
- skip_unless_android_perftest_backstop: None
- skip_unless_backstop: None
- skip_unless_changed: list[str] | None
- skip_unless_expanded: None
- skip_unless_missing_or_changed: list[str | list[str]] | None
- skip_unless_mozlint: str | list[str] | None
- skip_unless_schedules: list[str] | None
- skip_unless_sphinx_js: None
- test: list[str] | None
- test_inclusive: list[str] | None
- test_verify: list[str] | None
- upload_symbols: None
- classmethod validate(data)
Validate data against this schema.
- gecko_taskgraph.optimize.schema.set_optimization_schema(schema_tuple)
Sets LegacyOptimizationSchema so it can be imported by the task transform. This function is called by projects that extend Firefox’s taskgraph. It should be called by the project’s taskgraph:register function before any transport or job runner code is imported.
- Parameters:
schema_tuple (tuple) – Tuple of possible optimization strategies
gecko_taskgraph.optimize.strategies module
- class gecko_taskgraph.optimize.strategies.SkipConstrained
Bases:
OptimizationStrategySkips tasks on constrained worker pools.
Always skips tasks that are on pools with capacity issues, typically hardware.
- should_remove_task(task, params, _)
Determine whether to optimize this task by removing it. Returns True to remove.
- class gecko_taskgraph.optimize.strategies.SkipUnlessHasRelevantTests
Bases:
OptimizationStrategyOptimizes tasks that don’t run any tests that were in child directories of a modified file.
- get_changed_dirs(files_changed)
- should_remove_task(task, params, _)
Determine whether to optimize this task by removing it. Returns True to remove.
- class gecko_taskgraph.optimize.strategies.SkipUnlessMissing
Bases:
OptimizationStrategySkips a task unless it is missing from a specified index.
This simply defers to Taskgraph’s index-search optimization. The reason we need this shim is because replacement and removal optimizations can’t be joined together in a composite strategy as removal and replacement happen at different times.
- index_search = <taskgraph.optimize.strategies.IndexSearch object>
- should_remove_task(task, params, index)
Determine whether to optimize this task by removing it. Returns True to remove.
Module contents
The objective of optimization is to remove as many tasks from the graph as possible, as efficiently as possible, thereby delivering useful results as quickly as possible. For example, ideally if only a test script is modified in a push, then the resulting graph contains only the corresponding test suite task.
See taskcluster/docs/optimization.rst for more information.
- class gecko_taskgraph.optimize.ExperimentalOverride(base, overrides)
Bases:
objectOverrides 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.
- Parameters:
base (object) – A container class supporting attribute access.
overrides (dict) – Values to update any accessed dictionaries with.
- class gecko_taskgraph.optimize.experimental
Bases:
objectExperimental strategies either under development or used as benchmarks.
These run as “shadow-schedulers” on each autoland push (tier 3) and/or can be used with ./mach try auto. E.g:
./mach try auto –strategy relevant_tests
- bugbug_debug_disperse = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Restricts tests to debug platforms.
- bugbug_disperse_high = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Disperse tests across platforms, high confidence threshold.
- bugbug_disperse_low = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Disperse tests across platforms, low confidence threshold.
- bugbug_disperse_medium = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Disperse tests across platforms, medium confidence threshold.
- bugbug_disperse_medium_no_unseen = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Disperse tests across platforms (no modified for unseen configurations), medium confidence threshold.
- bugbug_disperse_medium_only_one = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Disperse tests across platforms (one platform per group), medium confidence threshold.
- bugbug_disperse_reduced_medium = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Disperse tests across platforms, medium confidence threshold with reduced tasks.
- bugbug_reduced = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Use the reduced set of tasks (and no groups) chosen by bugbug.
- bugbug_reduced_high = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Use the reduced set of tasks (and no groups) chosen by bugbug, high confidence threshold.
- bugbug_reduced_manifests_config_selection_high = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Choose configs selected by bugbug, medium confidence threshold with reduced tasks.
- bugbug_reduced_manifests_config_selection_low = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Choose configs selected by bugbug, low confidence threshold with reduced tasks.
- bugbug_reduced_manifests_config_selection_medium = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Choose configs selected by bugbug, medium confidence threshold with reduced tasks.
- bugbug_tasks_high = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Doesn’t limit platforms, high confidence threshold.
- bugbug_tasks_medium = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Doesn’t limit platforms, medium confidence threshold.
- perf_fixed_batch = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-android': <gecko_taskgraph.optimize.perf_batching.SkipUnlessPushesSinceLastBatch object>, 'perf-cadence-backstop': <gecko_taskgraph.optimize.perf_batching.SkipUnlessPushesSinceLastBatch object>, 'perf-cadence-default': <gecko_taskgraph.optimize.perf_batching.SkipUnlessPushesSinceLastBatch object>, 'perf-cadence-expanded': <gecko_taskgraph.optimize.perf_batching.SkipUnlessPushesSinceLastBatch object>, 'test': <taskgraph.optimize.base.Any object>}
Runs all performance tests when 18 pushes have been made since the last batch, other tasks as on autoland.
- perf_rapb = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-android': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-backstop': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-default': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-expanded': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'test': <taskgraph.optimize.base.Any object>}
RASB with commit risk scores aged at a rate of 0.02 per hour waited, and a threshold of 0.6.
- Type:
Risk-aged priority batching (RAPB)
- perf_rapb_la = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-android': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-backstop': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-default': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-expanded': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'test': <taskgraph.optimize.base.Any object>}
RASB-la with commit risk scores aged at a rate of 0.01 per hour waited, and a threshold of 0.55.
- Type:
RAPB with linear aggregation
- perf_rasb = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-android': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-backstop': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-default': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-expanded': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'test': <taskgraph.optimize.base.Any object>}
runs all performance tests when the probability that a commit pushed since the last batch regressed performance reaches 0.28, other tasks as on autoland.
- Type:
Risk-aware stream batching (RASB)
- perf_rasb_la = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-android': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-backstop': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-default': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'perf-cadence-expanded': <gecko_taskgraph.optimize.perf_batching.SkipUnlessRiskThreshold object>, 'test': <taskgraph.optimize.base.Any object>}
runs all performance tests when the sum of the risk scores of the commits pushed since the last batch reaches 0.32, other tasks as on autoland.
- Type:
RASB with linear aggregation
- perf_time_batch = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-android': <gecko_taskgraph.optimize.perf_batching.SkipUnlessTimeSinceLastBatch object>, 'perf-cadence-backstop': <gecko_taskgraph.optimize.perf_batching.SkipUnlessTimeSinceLastBatch object>, 'perf-cadence-default': <gecko_taskgraph.optimize.perf_batching.SkipUnlessTimeSinceLastBatch object>, 'perf-cadence-expanded': <gecko_taskgraph.optimize.perf_batching.SkipUnlessTimeSinceLastBatch object>, 'test': <taskgraph.optimize.base.Any object>}
Runs all performance tests when 3 hours have passed since the last batch, other tasks as on autoland.
- relevant_tests = {'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Runs task containing tests in the same directories as modified files.
- class gecko_taskgraph.optimize.project
Bases:
objectStrategies that should be applied per-project.
- autoland = {'build': <taskgraph.optimize.base.All object>, 'perf-cadence-default': <taskgraph.optimize.base.Any object>, 'test': <taskgraph.optimize.base.Any object>}
Strategy overrides that apply to autoland.
- beta = {'perf-cadence-default': <taskgraph.optimize.base.Alias object>, 'test': <taskgraph.optimize.base.Alias object>, 'test-backstop': <taskgraph.optimize.base.Alias object>}
Strategy overrides that apply to beta.
- pull_request = {'reprocess-symbols': <taskgraph.optimize.base.Alias object>, 'upload-symbols': <taskgraph.optimize.base.Alias object>}
Strategy overrides that apply to pull requests.
- gecko_taskgraph.optimize.split_bugbug_arg(arg, substrategies)
Split args for bugbug based strategies.
Many bugbug based optimizations require passing an empty dict by reference to communicate to downstream strategies. This function passes the provided arg to the first (non bugbug) strategies and a shared empty dict to the bugbug strategy and all substrategies after it.