Skip to content

feat: support optimizations at the graph level - #1122

Merged
bhearsum merged 4 commits into
taskcluster:mainfrom
bhearsum:refactor-move-indexsearch-look
Dec 1, 2026
Merged

bhearsum merged 4 commits into
taskcluster:mainfrom
bhearsum:refactor-move-indexsearch-look

Conversation

@bhearsum

Copy link
Copy Markdown
Contributor

The high level of this is introducing should_replace_tasks and should_remove_tasks to OptimizationStrategy. These become the new entry points for optimization, and the default implementations fall back to the existing singular implementations to maintain backwards compatibility. I've done my best to minimize the amount of change here, remove_tasks and replace_tasks needed some amount of reworking to allow things to operate at the graph level.

As far as I know, this is completely backwards compatible, and no there are no differences in generated taskgraphs as a result of it. I tested with various Gecko graphs to confirm this.

This is best looked at commit-by-commit due to the necessary refactor in the first commit. The last commit could move to its own PR, but it seemed fairly reasonable to include here seeing as it's a refactor enabled by this work.

This work was motivated by https://bugzilla.mozilla.org/show_bug.cgi?id=1927227.

@bhearsum
bhearsum marked this pull request as ready for review November 27, 2026 16:11
@bhearsum
bhearsum requested a review from a team as a code owner November 27, 2026 16:11
@bhearsum
bhearsum requested a review from jcristau November 27, 2026 16:11

@ahal ahal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks like a great improvement!

This gets rid of the (IMO) confusing `optimizations` closure, and paves the way evaluating graph-level optimizations.

This does mean we will resolve strategies for all tasks all of the time, which is slightly different than now: during early returns in `remove_tasks` and `replace_tasks` we currently avoid this for some tasks. As far as I can tell, this has no notable impact on performance even in a graph of Gecko's size.
This changes the entry point to removals from optimization to `should_remove_tasks`, which allows OptimizationStrategy's to make decisions based on the entire graph, not individual tasks.

The default implementation simply calls the existing `should_remove_task`, so this is more or less backwards compatible (at least when it comes to the main interface), and allows OptimizationStrategy implementations to continue operating at the task-level when desired.
Similar to the previous commit, this changes the replacement entry point to `should_replace_tasks` and defaults to calling `should_replace_task` for each task.
Now that we have the ability to do graph-level replacement, we can move the IndexSearch special case out of `optimize_task_graph` and into `IndexSearch` where it belongs.

As a bonus, IndexSearch will now work if we ever use it in a composite strategy.
@bhearsum
bhearsum force-pushed the refactor-move-indexsearch-look branch from 0044b07 to f18b3d3 Compare December 1, 2026 14:13
@bhearsum
bhearsum merged commit b55d537 into taskcluster:main Dec 1, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants