Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
618abf3
Retrieve the recent autoland pushes in their own function
marco-c Nov 19, 2026
76cf0d8
Select configs among the configs of the latest backstop push's tasks,…
marco-c Nov 19, 2026
b4610fd
Don't select configs on tasks which test selection doesn't optimize
marco-c Nov 19, 2026
4e5cac9
Don't select configs on shippable tasks
marco-c Nov 20, 2026
af3c05f
Set timeouts on the requests for the config selection tasks
marco-c Nov 20, 2026
a992132
Use an older backstop push's tasks if the graph of a newer one isn't …
marco-c Nov 19, 2026
b15c1e3
Give the taskgraph the labels of the tasks of the selected configs
marco-c Nov 19, 2026
c426e8f
Don't compute and store the configs seen recently with the config sel…
marco-c Nov 19, 2026
4c23c3a
Retrieve the definitions of some tasks from a full task graph without…
marco-c Nov 19, 2026
be34c4c
Give the taskgraph the labels of new tasks for the groups selected on…
marco-c Nov 19, 2026
92fcc22
Select configs on the tasks of the pushes after the backstop push too
marco-c Nov 20, 2026
c211c62
Ignore the target tasks of the backstop push which aren't in its task…
marco-c Nov 20, 2026
60a2784
Keep ignoring the tasks found not to be eligible after a newer backst…
marco-c Nov 20, 2026
364d263
Update the config selection tasks every 10 minutes
marco-c Nov 20, 2026
b35c469
Keep the config selection tasks between updates
marco-c Nov 20, 2026
1027f26
Remember the pushes known not to be backstop pushes
marco-c Nov 20, 2026
98accf4
Only write the config selection tasks when they change
marco-c Nov 20, 2026
a4eca73
Compute the configurations of the config selection tasks with the tes…
marco-c Nov 19, 2026
316b502
Try again to compute the configurations of the config selection tasks…
marco-c Nov 20, 2026
0a2bcd4
Don't retrieve the full task graph of other pushes for the pending co…
marco-c Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ repos:
- types-python-dateutil==2.9.0.20261104
- types-orjson==3.6.2
- types-tabulate==0.10.0.20261006
- types-PyYAML==6.0.12.20261113
- repo: local
hooks:
- id: hackbot-deploy-names
Expand Down
6 changes: 2 additions & 4 deletions bugbug/models/testconfigdimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,9 @@ def __init__(self, lemmatization=False):
Model.__init__(self, lemmatization)
self.training_dbs = [test_scheduling.PUSH_DATA_CONFIG_GROUP_DB]
self.history = DimensionHistory()
self.known_configs: set[str] = set()

def train(self, importance_cutoff=0.15, limit=None):
regressions, self.known_configs, _ = load_regressions(with_patches=False)
regressions, _ = load_regressions(with_patches=False)
split = split_push_index(regressions)

self.history = DimensionHistory()
Expand Down Expand Up @@ -387,7 +386,6 @@ def __init__(self, lemmatization=False):
self.entire_dataset_training = True

self.history = DimensionHistory()
self.known_configs: set[str] = set()
self._data: tuple | None = None
self.row_weights: list[float] = []
self.row_push_index: list[int] = []
Expand Down Expand Up @@ -419,7 +417,7 @@ def __getstate__(self):

def _load(self):
if self._data is None:
regressions, self.known_configs, patches = load_regressions()
regressions, patches = load_regressions()
self._data = (regressions, patches, split_push_index(regressions))
return self._data

Expand Down
103 changes: 57 additions & 46 deletions bugbug/models/testconfigselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
"""

import collections
import fnmatch
import functools
import logging
import math
import os
import random
import re
from typing import Any, Collection, Iterable, Iterator, Mapping, NamedTuple, Sequence

import numpy as np
Expand Down Expand Up @@ -312,49 +310,66 @@ def generate_rows(
history.add(regression)


def _label_without_chunk(label: str) -> str:
parts = label.split("-")
return "-".join(parts[:-1] if parts[-1].isdigit() else parts)
class LiveTask(NamedTuple):
"""A test task of the current task graph, by label without chunk number (see live_candidates)."""

# Its config, as mozci names it (see mozci.task.get_configuration).
config: str
# The manifests run by its chunks.
manifests: Sequence[str]

def live_candidates(
manifests_by_task: Mapping[str, Iterable[str]], known_configs: Iterable[str]
) -> dict[str, list[str]]:
"""The configs of the tasks in the current task graph that run each group.

`manifests_by_task` maps the labels of the tasks scheduled on the push's project to the manifests
they run (the decision task's manifests-by-task.json, restricted to its target tasks, as it comes
from the full task graph, which also has tasks of other projects, e.g. shippable variants). The
configs are patterns over task labels without their chunk number (e.g.
test-macosx1500-aarch64/debug-*-swr), as the taskgraph matches them: each task is named after
the most specific `known_configs` pattern it matches, or after its own label without the chunk
number if none matches (e.g. for a new platform).
def live_tasks(tasks: Mapping[str, LiveTask]) -> dict[str, dict[str, list[str]]]:
"""The tasks of the current task graph running each group, by config.

As the candidates come from the current task graph, configs that don't exist anymore (e.g. after
a platform migration) are never selected. Groups are named as by the models (see
`tasks` are the test tasks of the push's project among which configs are selected (see
bugbug_http.boot), by label without chunk number. Groups are named as by the models (see
test_scheduling.normalize_group).
"""
patterns = sorted(
((len(c), c, re.compile(fnmatch.translate(c))) for c in set(known_configs)),
reverse=True,
result: dict[str, dict[str, set[str]]] = collections.defaultdict(
lambda: collections.defaultdict(set)
)
for label, task in tasks.items():
for manifest in task.manifests:
result[test_scheduling.normalize_group(manifest)][task.config].add(label)

return {
group: {config: sorted(labels) for config, labels in configs.items()}
for group, configs in result.items()
}


def live_candidates(
tasks_by_group: Mapping[str, Mapping[str, Sequence[str]]],
) -> dict[str, list[str]]:
"""The configs of the tasks in the current task graph that run each group (see live_tasks).

@functools.cache
def config_of(label: str) -> str:
for _, config, pattern in patterns:
if pattern.match(label):
return config
return label
As the candidates come from the current task graph, configs that don't exist anymore (e.g. after
a platform migration) are never selected.
"""
return {group: sorted(configs) for group, configs in tasks_by_group.items()}

result: dict[str, set[str]] = collections.defaultdict(set)
for label, manifests in manifests_by_task.items():
if not label.startswith("test-"):
continue
config = config_of(_label_without_chunk(label))
for manifest in manifests:
result[test_scheduling.normalize_group(manifest)].add(config)

return {group: sorted(configs) for group, configs in result.items()}
def task_labels(
tasks_by_group: Mapping[str, Mapping[str, Sequence[str]]],
group: str,
configs: Iterable[str],
new_tasks: Mapping[str, str] | None = None,
) -> list[str]:
"""The labels (without chunk number) of the tasks running a group on the given configs.

The taskgraph matches them with the labels of its tasks. `tasks_by_group` comes from live_tasks.
`new_tasks` are tasks whose manifests aren't known (e.g. renamed since the task graph the others
come from), by label, with their config: they are given for every group selected on their config,
as the taskgraph only runs a task for a group if the task runs it.
"""
configs = set(configs)
tasks = tasks_by_group.get(group, {})
labels = {label for config in configs for label in tasks.get(config, ())}
labels |= {
label for label, config in (new_tasks or {}).items() if config in configs
}
return sorted(labels)


class GroupCandidates(NamedTuple):
Expand All @@ -380,11 +395,9 @@ def _plainest_cheapest(configs: Iterable[str]) -> str:

def load_regressions(
with_patches: bool = True,
) -> tuple[
list[test_scheduling.ConfigSelectRegression], set[str], dict[int, PatchInfo]
]:
"""The regressions of the push data, the configs seen recently, and the patch of each regression's push."""
regressions, known_configs = test_scheduling.get_config_select_regressions(
) -> tuple[list[test_scheduling.ConfigSelectRegression], dict[int, PatchInfo]]:
"""The regressions of the push data, and the patch of each regression's push."""
regressions = test_scheduling.get_config_select_regressions(
lambda: db.read(test_scheduling.PUSH_DATA_CONFIG_GROUP_DB)
)
logger.info(
Expand All @@ -394,7 +407,7 @@ def load_regressions(
)

if not with_patches:
return regressions, known_configs, {}
return regressions, {}

revs = {rev: r.push_index for r in regressions for rev in r.revs}
files: dict[int, list[str]] = collections.defaultdict(list)
Expand All @@ -408,7 +421,7 @@ def load_regressions(
for push_index, push_files in files.items()
}
logger.info("Patches found for %d pushes", len(patches))
return regressions, known_configs, patches
return regressions, patches


def split_push_index(
Expand Down Expand Up @@ -671,10 +684,8 @@ def __init__(self, lemmatization=False):
self.calculate_importance = False
self.entire_dataset_training = True

# Inference state: the failure history up to the end of the training data, and the configs
# seen recently (to name the tasks of the current task graph, see live_candidates).
# Inference state: the failure history up to the end of the training data.
self.history = ConfigHistory()
self.known_configs: set[str] = set()

self._regressions: list[test_scheduling.ConfigSelectRegression] | None = None
self._patches: dict[int, PatchInfo] = {}
Expand Down Expand Up @@ -735,7 +746,7 @@ def __getstate__(self):

def _load_regressions(self) -> list[test_scheduling.ConfigSelectRegression]:
if self._regressions is None:
self._regressions, self.known_configs, self._patches = load_regressions()
self._regressions, self._patches = load_regressions()
return self._regressions

def _split_push_index(self) -> int:
Expand Down
17 changes: 4 additions & 13 deletions bugbug/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ def _configs_by_group(config_groups: Iterable[Runnable]) -> dict[Group, set[str]

def get_config_select_regressions(
push_data_factory: Callable[[], Iterable[PushResult]],
recent_pushes: int = 1000,
) -> tuple[list[ConfigSelectRegression], set[str]]:
) -> list[ConfigSelectRegression]:
"""The regressions of config/group push data, with the configs they failed on and passed on.

A config the regressed group ran on without failing passed, both on the culprit push and on the
Expand All @@ -412,9 +411,6 @@ def get_config_select_regressions(
run after the culprit failed and the failure was attributed to a later push (e.g. because the config
didn't run on the culprit): with no run in between, the attribution can't tell the pushes apart, so
the config didn't verifiably pass. A failure after a pass doesn't matter (as in get_non_run_negatives).

Also returns the configs that ran in the last `recent_pushes` pushes, used to name the configs of
the tasks in the current task graph (see testconfigselect.live_candidates).
"""
rev_index: dict[Revision, int] = {}
culprits: list[
Expand All @@ -427,7 +423,6 @@ def get_config_select_regressions(
]
] = []
failures_at: dict[int, dict[Group, set[str]]] = {}
num_pushes = 0
for index, push in enumerate(push_data_factory()):
(
revisions,
Expand All @@ -436,7 +431,6 @@ def get_config_select_regressions(
possible_regressions,
likely_regressions,
) = push
num_pushes += 1
for revision in revisions:
rev_index[revision] = index
if possible_regressions or likely_regressions:
Expand Down Expand Up @@ -470,16 +464,13 @@ def get_config_select_regressions(

# The first push of the window each config ran the group on.
later_runs: dict[tuple[int, Group], dict[str, int]] = collections.defaultdict(dict)
recent: set[str] = set()
for index, push in enumerate(push_data_factory()):
groups_needed = needed.get(index)
if groups_needed is None and index < num_pushes - recent_pushes:
if groups_needed is None:
continue

for group, configs in _configs_by_group(push[2]).items():
if index >= num_pushes - recent_pushes:
recent |= configs
for culprit in groups_needed.get(group, ()) if groups_needed else ():
for culprit in groups_needed.get(group, ()):
for config in configs:
later_runs[(culprit, group)].setdefault(config, index)

Expand All @@ -505,7 +496,7 @@ def get_config_select_regressions(
)
)

return regressions, recent
return regressions


def get_push_data(
Expand Down
Loading